git/builtin
Justin Tobler ecdda043e0 odb/transaction: add transaction finalize interface
When committing an ODB transaction via `odb_transaction_commit()`, the
staged objects are made visible and the underlying transaction is freed
at the same time. Coupling these two steps does not leave room for any
post-commit transaction operations to be introduced though. Such a
capability is useful if an ODB transaction backend needs to hold on to
lockfiles after transaction commit until references are updated, as is
the case with the existing "files" backend in git-receive-pack(1).

Stop freeing the transaction in `odb_transaction_commit()` and introduce
`odb_transaction_finalize()` to explicitly clean up the transaction
accordingly. Note that the finalize interface also provides an optional
callback for any backend-specific deferred cleanup. In a subsequent
commit, the "files" transaction backend will use this to remove ".keep"
files generated for packfiles received via git-receive-pack(1) after
references have been updated. In preparation for this, the
`odb_transaction_finalize()` call site in git-receive-pack(1) is made
after the reference updates are finished.

All other callers commit a transaction and immediately finalize it
without any work happening in between those two operations.
Consequently, they cannot meaningfully recover in case either of them
would fail, and spelling out these two separate steps with proper error
handling would be quite repetitive and pointless. Introduce a helper
`odb_transaction_commit_and_finalize_or_die()` for those call sites and
update them accordingly.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-20 20:28:01 -07:00
..
add.c odb/transaction: add transaction finalize interface 2026-08-20 20:28:01 -07:00
am.c hook: mark non-parallelizable hooks 2026-04-10 07:58:53 -07:00
annotate.c
apply.c
archive.c connect: use "service" enum for "name" argument 2026-05-19 15:05:46 +09:00
backfill.c path-walk: add pl_sparse_trees to control tree pruning 2026-05-24 18:41:06 +09:00
bisect.c bisect: ensure non-NULL `head` before using it 2026-07-10 08:13:55 -07:00
blame.c Merge branch 'bc/parse-options-exit-0-on-help' 2026-07-19 10:42:16 -07:00
branch.c Merge branch 'rs/branch-delete-bisect-warning' 2026-08-05 11:10:51 -07:00
bugreport.c
bundle.c
cat-file.c Merge branch 'jk/cat-file-batch-wo-type-fix' 2026-08-07 14:48:00 -07:00
check-attr.c environment: stop using `the_repository` in `is_bare_repository()` 2026-06-11 05:05:54 -07:00
check-ignore.c
check-mailmap.c mailmap: stop using the_repository 2026-02-20 08:13:58 -08:00
check-ref-format.c refs: remove remaining uses of `the_repository` 2026-07-16 07:40:22 -07:00
checkout--worker.c
checkout-index.c setup: stop using `the_repository` in `prefix_path()` 2026-05-19 19:36:24 +09:00
checkout.c refs: remove remaining uses of `the_repository` 2026-07-16 07:40:22 -07:00
clean.c Merge branch 'jk/color-variable-fixes' 2025-09-29 11:40:35 -07:00
clone.c Merge branch 'af/clone-revision-v0-segfault-fix' 2026-08-03 09:31:29 -07:00
column.c
commit-graph.c commit-graph: add new config for changed-paths & recommend it in scalar 2025-10-22 10:40:11 -07:00
commit-tree.c commit: rename `free_commit_list()` to conform to coding guidelines 2026-01-15 05:32:31 -08:00
commit.c sequencer: teach autostash apply to take optional conflict marker labels 2026-04-29 21:46:03 +09:00
config.c worktree: pass repository to public functions 2026-07-16 07:40:22 -07:00
count-objects.c packfile: introduce macro to iterate through packs 2025-10-16 14:42:39 -07:00
credential-cache--daemon.c
credential-cache.c
credential-store.c builtin/credential-store: move is_rfc3986_unreserved to url.[ch] 2026-01-12 11:56:56 -08:00
credential.c
describe.c Merge branch 'kk/prio-queue-get-put-fusion' 2026-07-13 08:27:27 -07:00
diagnose.c
diff-files.c
diff-index.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
diff-pairs.c
diff-tree.c Merge branch 'ps/commit-list-functions-renamed' 2026-02-13 13:39:25 -08:00
diff.c diff: handle NULL return from repo_get_commit_tree() 2026-07-10 08:13:54 -07:00
difftool.c Merge branch 'rs/tempfile-wo-the-repository' 2026-07-30 10:32:02 -07:00
fast-export.c Merge branch 'ps/refspec-wo-the-repository' 2026-07-27 09:09:00 -07:00
fast-import.c Merge branch 'jk/hash-algo-leak-fixes' 2026-07-16 23:05:47 -07:00
fetch-pack.c connect: use "service" enum for "name" argument 2026-05-19 15:05:46 +09:00
fetch.c Merge branch 'ps/refspec-wo-the-repository' 2026-07-27 09:09:00 -07:00
fmt-merge-msg.c
for-each-ref.c
for-each-repo.c for-each-repo: simplify passing of parameters 2026-03-03 10:20:00 -08:00
fsck.c worktree: pass repository to public functions 2026-07-16 07:40:22 -07:00
fsmonitor--daemon.c fsmonitor: plug token-data leak on early daemon-startup failures 2026-07-05 09:12:10 -07:00
gc.c Merge branch 'ps/odb-pluggable-housekeeping' 2026-08-05 11:10:51 -07:00
get-tar-commit-id.c
grep.c Merge branch 'ps/odb-generalize-prepare' 2026-07-13 08:27:28 -07:00
hash-object.c setup: stop using `the_repository` in `setup_git_directory()` 2026-05-19 19:36:25 +09:00
help.c setup: stop using `the_repository` in `setup_git_directory_gently()` 2026-05-19 19:36:24 +09:00
history.c Merge branch 'rs/tempfile-wo-the-repository' 2026-07-30 10:32:02 -07:00
hook.c hook: allow hook.jobs=-1 to use all available CPU cores 2026-04-10 07:58:55 -07:00
index-pack.c Merge branch 'jk/git-hash-cleanups' 2026-07-16 23:05:48 -07:00
init-db.c setup: pass worktree to `init_db()` 2026-07-07 10:49:41 -07:00
interpret-trailers.c Merge branch 'kh/doc-interpret-trailers-1' 2026-03-27 11:00:02 -07:00
last-modified.c prio-queue: rename .nr to .nr_ and add accessor helpers 2026-06-09 11:11:46 -07:00
log.c Merge branch 'jk/format-patch-leakfix' 2026-07-13 08:27:27 -07:00
ls-files.c Merge branch 'js/objects-larger-than-4gb-on-windows-more' 2026-06-21 16:41:38 -07:00
ls-remote.c ref-filter: propagate peeled object ID 2025-11-04 07:32:25 -08:00
ls-tree.c odb: use size_t for object_info.sizep and the size APIs 2026-06-15 07:45:41 -07:00
mailinfo.c
mailsplit.c mailsplit: move NULL check before first use of file handle 2026-07-10 08:13:54 -07:00
merge-base.c commit-reach: early exit paint_down_to_common for single merge-base 2026-05-12 09:33:43 +09:00
merge-file.c setup: stop using `the_repository` in `setup_git_directory()` 2026-05-19 19:36:25 +09:00
merge-index.c
merge-ours.c merge-ours: integrate with sparse-index 2026-02-06 11:45:33 -08:00
merge-recursive.c
merge-tree.c odb: use size_t for object_info.sizep and the size APIs 2026-06-15 07:45:41 -07:00
merge.c Merge branch 'tc/merge-default-to-upstream-leakfix' 2026-08-07 14:48:01 -07:00
mktag.c odb: use size_t for object_info.sizep and the size APIs 2026-06-15 07:45:41 -07:00
mktree.c builtin/mktree: remove USE_THE_REPOSITORY_VARIABLE 2026-03-12 10:03:23 -07:00
multi-pack-index.c midx: refactor interfaces to work on "packed" source 2026-06-17 05:00:01 -07:00
mv.c Merge branch 'lo/mv-missing-dest-dir-check' 2026-08-11 10:07:00 -07:00
name-rev.c Merge branch 'kh/name-rev-custom-format' 2026-05-19 09:57:44 +09:00
notes.c worktree: pass repository to public functions 2026-07-16 07:40:22 -07:00
pack-objects.c Merge branch 'ps/odb-move-loose-object-writing' 2026-07-30 10:32:05 -07:00
pack-redundant.c pack-redundant: fix memory leak when open_pack_index() fails 2026-02-21 21:26:53 -08:00
pack-refs.c builtin/pack-refs: factor out core logic into a shared library 2025-09-19 10:02:55 -07:00
patch-id.c hash: use git_hash_init() consistently 2026-07-07 21:56:00 -07:00
prune-packed.c
prune.c
pull.c refspec: let callers pass in hash algorithm when parsing items 2026-07-16 13:58:25 -07:00
push.c Merge branch 'ty/migrate-excludes-file' 2026-07-30 10:32:03 -07:00
range-diff.c Merge branch 'kh/format-patch-range-diff-notes' 2025-10-14 12:56:09 -07:00
read-tree.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
rebase.c reset: introduce ability to skip updating HEAD 2026-07-03 10:32:33 -07:00
receive-pack.c odb/transaction: add transaction finalize interface 2026-08-20 20:28:01 -07:00
reflog.c worktree: pass repository to public functions 2026-07-16 07:40:22 -07:00
refs.c worktree: pass repository to public functions 2026-07-16 07:40:22 -07:00
remote-ext.c
remote-fd.c
remote.c odb: rename `odb_has_object()` flags 2026-03-31 20:43:14 -07:00
repack.c Merge branch 'ps/odb-source-packed' 2026-07-06 15:50:21 -07:00
replace.c hex: add and use strbuf_add_oid_hex() 2026-05-14 15:59:25 +09:00
replay.c replay: allow to specify a ref with option --ref 2026-04-01 21:34:25 -07:00
repo.c setup: move prefix into repository 2026-07-07 10:49:40 -07:00
rerere.c
reset.c environment: stop using `the_repository` in `is_bare_repository()` 2026-06-11 05:05:54 -07:00
rev-list.c pack-bitmap: allow aborting iteration of bitmapped objects 2026-07-15 07:19:16 -07:00
rev-parse.c setup: move prefix into repository 2026-07-07 10:49:40 -07:00
revert.c Merge branch 'pw/3.0-commentchar-auto-deprecation' 2025-09-18 10:07:00 -07:00
rm.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
send-pack.c refspec: stop depending on `the_repository` 2026-07-16 13:58:25 -07:00
shortlog.c parse-options: exit 0 on -h 2026-07-07 17:48:57 -07:00
show-branch.c prio-queue: fold lazy_queue into prio_queue for automatic get+put fusion 2026-06-09 11:11:46 -07:00
show-index.c show-index: use gettext wrapping in user facing error messages 2026-01-30 08:58:12 -08:00
show-ref.c odb: rename `odb_has_object()` flags 2026-03-31 20:43:14 -07:00
sparse-checkout.c use repo_hold_lock_file_for_update{,_mode,_timeout}() with custom repos 2026-07-14 12:54:25 -07:00
stash.c stash: avoid sparse-index expansion for in-cone paths 2026-07-21 10:33:25 -07:00
stripspace.c setup: stop using `the_repository` in `setup_git_directory_gently()` 2026-05-19 19:36:24 +09:00
submodule--helper.c Merge branch 'ps/refspec-wo-the-repository' 2026-07-27 09:09:00 -07:00
symbolic-ref.c
tag.c odb: use size_t for object_info.sizep and the size APIs 2026-06-15 07:45:41 -07:00
unpack-file.c odb: use size_t for object_info.sizep and the size APIs 2026-06-15 07:45:41 -07:00
unpack-objects.c odb/transaction: add transaction finalize interface 2026-08-20 20:28:01 -07:00
update-index.c odb/transaction: add transaction finalize interface 2026-08-20 20:28:01 -07:00
update-ref.c update-ref: handle rejections while adding updates 2026-05-05 16:34:08 +09:00
update-server-info.c
upload-archive.c setup: stop using `the_repository` in `enter_repo()` 2026-05-19 19:36:24 +09:00
upload-pack.c setup: stop using `the_repository` in `enter_repo()` 2026-05-19 19:36:24 +09:00
url-parse.c builtin: create url-parse command 2026-05-06 09:48:28 +09:00
var.c
verify-commit.c
verify-pack.c
verify-tag.c tag: support arbitrary repositories in gpg_verify_tag() 2025-12-29 22:02:53 +09:00
worktree.c Merge branch 'ps/copy-wo-the-repository' 2026-07-27 09:09:00 -07:00
write-tree.c