]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/update-index: end ODB transaction when --verbose is specified
authorJustin Tobler <jltobler@gmail.com>
Tue, 16 Sep 2025 18:29:34 +0000 (13:29 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Sep 2025 18:37:05 +0000 (11:37 -0700)
commit9c61d9aded98748aae949b83babbdbd11e695f32
treebb06f6bca5535c0468c41b4b4edcfd46096c4804
parentf3c1db4b2a23fac171a699b10f9328f8df52602f
builtin/update-index: end ODB transaction when --verbose is specified

With 23a3a303 (update-index: use the bulk-checkin infrastructure,
2022-04-04), object database transactions were added to
git-update-index(1) to facilitate writing objects in bulk. With
transactions, newly added objects are instead written to a temporary
object directory and migrated to the primary object database upon
transaction commit.

When the --verbose option is specified, the subsequent set of objects
written are explicitly flushed via flush_odb_transaction() prior to
reporting the update. Flushing the object database transaction migrates
pending objects to the primary object database without marking the
transaction as complete. This is done so objects are immediately visible
to git-update-index(1) callers using the --verbose option and that rely
on parsing verbose output to know when objects are written.

Due to how git-update-index(1) parses arguments, options that come after
a filename are not considered during the object update. Therefore, it
may not be known ahead of time whether the --verbose option is present
and thus object writes are considered transactional by default until a
--verbose option is parsed.

Flushing a transaction after individual object writes negates the
benefit of writing objects to a transaction in the first place.
Furthermore, the mechanism to flush a transaction without actually
committing is rather awkward. Drop the call to flush_odb_transaction()
in favor of ending the transaction altogether when the --verbose flag is
encountered. Subsequent object writes occur outside of a transaction and
are therefore immediately visible which matches the current behavior.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/update-index.c