]> git.ipfire.org Git - thirdparty/git.git/commit
refs/reftable: fix D/F conflict error message on ref copy
authorPatrick Steinhardt <ps@pks.im>
Mon, 8 Apr 2024 12:23:52 +0000 (14:23 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Apr 2024 23:59:01 +0000 (16:59 -0700)
commitf57cc987a937bef3f6c8e4911cf98e0f51eee1e2
treed6958bf0832e84865c7db36adf8ba185ba3f3dd7
parent7774cfed6261ce2900c84e55906da708c711d601
refs/reftable: fix D/F conflict error message on ref copy

The `write_copy_table()` function is shared between the reftable
implementations for renaming and copying refs. The only difference
between those two cases is that the rename will also delete the old
reference, whereas copying won't.

This has resulted in a bug though where we don't properly verify refname
availability. When calling `refs_verify_refname_available()`, we always
add the old ref name to the list of refs to be skipped when computing
availability, which indicates that the name would be available even if
it already exists at the current point in time. This is only the right
thing to do for renames though, not for copies.

The consequence of this bug is quite harmless because the reftable
backend has its own checks for D/F conflicts further down in the call
stack, and thus we refuse the update regardless of the bug. But all the
user gets in this case is an uninformative message that copying the ref
has failed, without any further details.

Fix the bug and only add the old name to the skip-list in case we rename
the ref. Consequently, this error case will now be handled by
`refs_verify_refname_available()`, which knows to provide a proper error
message.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/reftable-backend.c
t/t0610-reftable-basics.sh