]> git.ipfire.org Git - thirdparty/git.git/commit
odb/transaction: propagate begin errors
authorJustin Tobler <jltobler@gmail.com>
Fri, 10 Jul 2026 16:37:17 +0000 (11:37 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Jul 2026 20:21:53 +0000 (13:21 -0700)
commit4576d6c5225fec402fa8d4190abb63e6f938b98d
treed4abbf7ed0ab8adcd13d2daabac5950f07940e00
parent6d017185e3b4052354fca3a40e8453bd85624896
odb/transaction: propagate begin errors

When `odb_transaction_begin()` is invoked, the function returns the
transaction pointer directly. There is no way for the backend to
signal that it failed to set up its state, such as when creating the
temporary object directory backing the transaction.

In a subsequent commit, git-receive-pack(1) starts using ODB
transactions and needs to be able to report such failures rather
than silently ignore them. Refactor `odb_transaction_begin()` to
return an int error code and write the resulting transaction into an
out parameter. Also introduce `odb_transaction_begin_or_die()` as a
convenience for callsites that do not need to handle errors
explicitly.

Note that `odb_transaction_begin()` now returns an error when the ODB
already has an inflight transaction pending. ODB transaction call sites
that may encounter an inflight transaction are updated to explicitly
handle this case.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/add.c
builtin/unpack-objects.c
builtin/update-index.c
cache-tree.c
object-file.c
odb/transaction.c
odb/transaction.h
read-cache.c