Merge branch 'hy/read-cache-lock-error-fix'

A failure to open the index file for writing due to conflicting
access did not state what went wrong, which has been corrected.

* hy/read-cache-lock-error-fix:
  read-cache: report lock error when refreshing index
maint
Junio C Hamano 2025-07-14 11:19:26 -07:00
commit 69ea767bc3
2 changed files with 8 additions and 13 deletions

View File

@ -1456,7 +1456,8 @@ int repo_refresh_and_write_index(struct repository *repo,
struct lock_file lock_file = LOCK_INIT;
int fd, ret = 0;

fd = repo_hold_locked_index(repo, &lock_file, 0);
fd = repo_hold_locked_index(repo, &lock_file,
gentle ? 0 : LOCK_REPORT_ON_ERROR);
if (!gentle && fd < 0)
return -1;
if (refresh_index(repo->index, refresh_flags, pathspec, seen, header_msg))

View File

@ -1672,11 +1672,9 @@ test_expect_success 'stash create reports a locked index' '
echo change >A.file &&
touch .git/index.lock &&

cat >expect <<-EOF &&
error: could not write index
EOF
test_must_fail git stash create 2>err &&
test_cmp expect err
test_grep "error: could not write index" err &&
test_grep "error: Unable to create '.*index.lock'" err
)
'

@ -1689,11 +1687,9 @@ test_expect_success 'stash push reports a locked index' '
echo change >A.file &&
touch .git/index.lock &&

cat >expect <<-EOF &&
error: could not write index
EOF
test_must_fail git stash push 2>err &&
test_cmp expect err
test_grep "error: could not write index" err &&
test_grep "error: Unable to create '.*index.lock'" err
)
'

@ -1707,11 +1703,9 @@ test_expect_success 'stash apply reports a locked index' '
git stash push &&
touch .git/index.lock &&

cat >expect <<-EOF &&
error: could not write index
EOF
test_must_fail git stash apply 2>err &&
test_cmp expect err
test_grep "error: could not write index" err &&
test_grep "error: Unable to create '.*index.lock'" err
)
'