diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-04-29 16:15:31 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-04-29 16:15:31 -0700 |
commit | d2ea03ddeeeab6f703290af30ba89d5606858673 (patch) | |
tree | 6db161bf2172d4566c7ab1751c3128ec5d289d15 /refs | |
parent | Merge branch 'en/fill-directory-exponential' (diff) | |
parent | update-ref: implement interactive transaction handling (diff) | |
download | tgif-d2ea03ddeeeab6f703290af30ba89d5606858673.tar.xz |
Merge branch 'ps/transactional-update-ref-stdin'
"git update-ref --stdin" learned a handful of new verbs to let the
user control ref update transactions more explicitly, which helps
as an ingredient to implement two-phase commit-style atomic
ref-updates across multiple repositories.
* ps/transactional-update-ref-stdin:
update-ref: implement interactive transaction handling
update-ref: read commands in a line-wise fashion
update-ref: move transaction handling into `update_refs_stdin()`
update-ref: pass end pointer instead of strbuf
update-ref: drop unused argument for `parse_refname`
update-ref: organize commands in an array
strbuf: provide function to append whole lines
git-update-ref.txt: add missing word
refs: fix segfault when aborting empty transaction
Diffstat (limited to 'refs')
-rw-r--r-- | refs/files-backend.c | 18 |
1 files changed, 10 insertions, 8 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; } |