aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-05-23 11:04:27 -0700
committerJunio C Hamano <gitster@pobox.com>2024-05-23 11:04:27 -0700
commit86a49253a62dcecd927af6008b3e8d0f4e506936 (patch)
tree5e1e5366162fd807655ac048b17438e37d18c5b2
parent7593d669284b16db4dc43f9b9bd8cd96ec862377 (diff)
parent9339fca23efbe1a2f9dc916356be9d0a22d233c2 (diff)
downloadgit-86a49253a62dcecd927af6008b3e8d0f4e506936.tar.gz
Merge branch 'it/refs-name-conflict'
Expose "name conflict" error when a ref creation fails due to D/F conflict in the ref namespace, to improve an error message given by "git fetch". * it/refs-name-conflict: refs: return conflict error when checking packed refs
-rw-r--r--refs/files-backend.c4
-rwxr-xr-xt/t5510-fetch.sh16
2 files changed, 19 insertions, 1 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 3957bfa579..3dce0c2a34 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -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;
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 9441793d06..6c20fe1871 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 &&
+ test_grep "error: some local refs could not be updated; try running" err &&
+ test_grep " ${SQ}git remote prune origin${SQ} to remove any old, conflicting branches" 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-packed &&
+ test_grep " ${SQ}git remote prune origin${SQ} to remove any old, conflicting branches" err-packed
+ )
+'
+
test_expect_success 'fetching a one-level ref works' '
test_commit extra &&
git reset --hard HEAD^ &&