Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refs: return conflict error when checking packed refs #1716

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion refs/files-backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,10 @@ static int lock_raw_ref(struct files_ref_store *refs,
*/
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;
Expand Down
16 changes: 16 additions & 0 deletions t/t5510-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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^ &&
Expand Down