refs: return conflict error when checking packed refs

The TRANSACTION_NAME_CONFLICT error code refers to a failure to create a
ref due to a name conflict with another ref. An example of this is a
directory/file conflict such as ref names A/B and A.

"git fetch" uses this error code to more accurately describe the error
by recommending to the user that they try running "git remote prune" to
remove any old refs that are deleted by the remote which would clear up
any directory/file conflicts.

This helpful error message is not displayed when the conflicted ref is
stored in packed refs. This change fixes this by ensuring error return
code consistency in `lock_raw_ref`.

Signed-off-by: Ivan Tse <ivan.tse1@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ivan Tse
2024-05-04 03:04:08 +00:00
committed by Junio C Hamano
parent 786a3e4b8d
commit 9339fca23e
2 changed files with 19 additions and 1 deletions

View File

@ -794,8 +794,10 @@ retry:
*/
if (refs_verify_refname_available(
refs->packed_ref_store, refname,
extras, NULL, err))
extras, NULL, err)) {
ret = TRANSACTION_NAME_CONFLICT;
goto error_return;
}
}
ret = 0;