Skip to content

Commit 86a4925

Browse files
committed
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
2 parents 7593d66 + 9339fca commit 86a4925

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

refs/files-backend.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,10 @@ static int lock_raw_ref(struct files_ref_store *refs,
794794
*/
795795
if (refs_verify_refname_available(
796796
refs->packed_ref_store, refname,
797-
extras, NULL, err))
797+
extras, NULL, err)) {
798+
ret = TRANSACTION_NAME_CONFLICT;
798799
goto error_return;
800+
}
799801
}
800802

801803
ret = 0;

t/t5510-fetch.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,22 @@ test_expect_success 'branchname D/F conflict resolved by --prune' '
10911091
test_cmp expect actual
10921092
'
10931093

1094+
test_expect_success 'branchname D/F conflict rejected with targeted error message' '
1095+
git clone . df-conflict-error &&
1096+
git branch dir_conflict &&
1097+
(
1098+
cd df-conflict-error &&
1099+
git update-ref refs/remotes/origin/dir_conflict/file HEAD &&
1100+
test_must_fail git fetch 2>err &&
1101+
test_grep "error: some local refs could not be updated; try running" err &&
1102+
test_grep " ${SQ}git remote prune origin${SQ} to remove any old, conflicting branches" err &&
1103+
git pack-refs --all &&
1104+
test_must_fail git fetch 2>err-packed &&
1105+
test_grep "error: some local refs could not be updated; try running" err-packed &&
1106+
test_grep " ${SQ}git remote prune origin${SQ} to remove any old, conflicting branches" err-packed
1107+
)
1108+
'
1109+
10941110
test_expect_success 'fetching a one-level ref works' '
10951111
test_commit extra &&
10961112
git reset --hard HEAD^ &&

0 commit comments

Comments
 (0)