]> git.ipfire.org Git - thirdparty/git.git/commit
refs: move object parsing to the generic layer
authorKarthik Nayak <karthik.188@gmail.com>
Mon, 4 May 2026 17:44:11 +0000 (19:44 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 May 2026 07:34:08 +0000 (16:34 +0900)
commitb32c23be3bf444ad8d56e8daee4a704ff8cae0ea
tree9152bc5c74faaa9b0420a451ab3d0e5dd6ec0ed1
parente31a10418a4c2270651bab326f4715892db9c3ee
refs: move object parsing to the generic layer

Regular reference updates made via reference transactions validate that
the provided object ID exists in the object database, which is done by
calling 'parse_object()'. This check is done independently by the
backends which leads to duplicated logic.

Let's move this to the generic layer, ensuring the backends only have to
care about reference storage and not about validation of the object IDs.
With this also remove the 'REF_TRANSACTION_ERROR_INVALID_NEW_VALUE'
error type as its no longer used.

Since we don't iterate over individual references in
`ref_transaction_prepare()`, we add this check to
`ref_transaction_update()`. This means that the validation is done as
soon as an update is queued, without needing to prepare the
transaction. It can be argued that this is more ideal, since this
validation has no dependency on the reference transaction being
prepared.

It must be noted that the change in behavior means that this error
cannot be ignored even with usage of batched updates, since this happens
when the update is being added to the transaction. But since the caller
gets specific error codes, they can either abort the transaction or
continue adding other updates to the transaction.

Modify 'builtin/receive-pack.c' to now capture the error type so that
the error propagated to the client stays the same. Also remove two of
the tests which validates batch-updates with invalid new_oid.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/receive-pack.c
refs.c
refs/files-backend.c
refs/reftable-backend.c
t/t1400-update-ref.sh