On Fri, May 03, 2024 at 04:50:29AM +0000, Ivan Tse via GitGitGadget wrote: > From: Ivan Tse <ivan.tse1@xxxxxxxxx> > > 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@xxxxxxxxx> > --- > refs: return conflict error when checking packed refs > > Changes against v1: > > * added test for the error message during git fetch > > Thanks for reviewing! I've gone ahead and attempted to add tests for > this behavior. It tests that the error message is shown for both cases > when the ref is stored as loose vs packed-refs. How does this test look? > Also, should this test have a REFFILES prerequisite? There is no need for the REFFILES prerequisite as you never access refs on disk directly, but instead use our plumbing commands. Furthermore, we do want to verify that both backends behave the same here. If the test failed with the "reftable" backend I'd consider that to be a bug in the backend. [snip] > diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh > index 33d34d5ae9e..ae0828e26a1 100755 > --- a/t/t5510-fetch.sh > +++ b/t/t5510-fetch.sh > @@ -1091,6 +1091,22 @@ test_expect_success 'branchname D/F conflict resolved by --prune' ' > test_cmp expect actual > ' > > +test_expect_success 'branchname D/F conflict rejected with targeted error message' ' > + git clone . df-conflict-error && > + git branch dir_conflict && > + ( > + cd df-conflict-error && > + git update-ref refs/remotes/origin/dir_conflict/file HEAD && > + test_must_fail git fetch 2>../err && > + git pack-refs --all && > + test_must_fail git fetch 2>../err-packed > + ) && > + test_grep "error: some local refs could not be updated; try running" err && > + test_grep " '\''git remote prune origin'\'' to remove any old, conflicting branches" err && > + test_grep "error: some local refs could not be updated; try running" err-packed && > + test_grep " '\''git remote prune origin'\'' to remove any old, conflicting branches" err-packed I would personally add those calls to `test_grep` right after the respective fetches to make the test a bit easier to follow. Also, instead of using '\''`, you can use the "${SQ}" variable to insert single quotes. So, something like this: test_grep " ${SQ}git remote prune origin${SQ} to remove any old, conflicting branches" err && Other than that this patch looks good to me, thanks! Patrick > +' > + > test_expect_success 'fetching a one-level ref works' ' > test_commit extra && > git reset --hard HEAD^ && > > base-commit: d4cc1ec35f3bcce816b69986ca41943f6ce21377 > -- > gitgitgadget >
Attachment:
signature.asc
Description: PGP signature