diff options
Diffstat (limited to 'refs')
-rw-r--r-- | refs/files-backend.c | 18 | ||||
-rw-r--r-- | refs/refs-internal.h | 18 |
2 files changed, 25 insertions, 11 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c index 561c33ac8a..6516c7bc8c 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -2565,16 +2565,18 @@ static void files_transaction_cleanup(struct files_ref_store *refs, } } - if (backend_data->packed_transaction && - ref_transaction_abort(backend_data->packed_transaction, &err)) { - error("error aborting transaction: %s", err.buf); - strbuf_release(&err); - } + if (backend_data) { + if (backend_data->packed_transaction && + ref_transaction_abort(backend_data->packed_transaction, &err)) { + error("error aborting transaction: %s", err.buf); + strbuf_release(&err); + } - if (backend_data->packed_refs_locked) - packed_refs_unlock(refs->packed_ref_store); + if (backend_data->packed_refs_locked) + packed_refs_unlock(refs->packed_ref_store); - free(backend_data); + free(backend_data); + } transaction->state = REF_TRANSACTION_CLOSED; } diff --git a/refs/refs-internal.h b/refs/refs-internal.h index ff2436c0fb..4271362d26 100644 --- a/refs/refs-internal.h +++ b/refs/refs-internal.h @@ -347,9 +347,13 @@ int is_empty_ref_iterator(struct ref_iterator *ref_iterator); /* * Return an iterator that goes over each reference in `refs` for * which the refname begins with prefix. If trim is non-zero, then - * trim that many characters off the beginning of each refname. flags - * can be DO_FOR_EACH_INCLUDE_BROKEN to include broken references in - * the iteration. The output is ordered by refname. + * trim that many characters off the beginning of each refname. + * The output is ordered by refname. The following flags are supported: + * + * DO_FOR_EACH_INCLUDE_BROKEN: include broken references in + * the iteration. + * + * DO_FOR_EACH_PER_WORKTREE_ONLY: only produce REF_TYPE_PER_WORKTREE refs. */ struct ref_iterator *refs_ref_iterator_begin( struct ref_store *refs, @@ -438,6 +442,14 @@ void base_ref_iterator_free(struct ref_iterator *iter); /* Virtual function declarations for ref_iterators: */ +/* + * backend-specific implementation of ref_iterator_advance. For symrefs, the + * function should set REF_ISSYMREF, and it should also dereference the symref + * to provide the OID referent. If DO_FOR_EACH_INCLUDE_BROKEN is set, symrefs + * with non-existent referents and refs pointing to non-existent object names + * should also be returned. If DO_FOR_EACH_PER_WORKTREE_ONLY, only + * REF_TYPE_PER_WORKTREE refs should be returned. + */ typedef int ref_iterator_advance_fn(struct ref_iterator *ref_iterator); typedef int ref_iterator_peel_fn(struct ref_iterator *ref_iterator, |