Skip to content

Commit 69ea767

Browse files
committed
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
2 parents 38349d1 + 9455397 commit 69ea767

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

read-cache.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,8 @@ int repo_refresh_and_write_index(struct repository *repo,
14561456
struct lock_file lock_file = LOCK_INIT;
14571457
int fd, ret = 0;
14581458

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

t/t3903-stash.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,11 +1672,9 @@ test_expect_success 'stash create reports a locked index' '
16721672
echo change >A.file &&
16731673
touch .git/index.lock &&
16741674
1675-
cat >expect <<-EOF &&
1676-
error: could not write index
1677-
EOF
16781675
test_must_fail git stash create 2>err &&
1679-
test_cmp expect err
1676+
test_grep "error: could not write index" err &&
1677+
test_grep "error: Unable to create '.*index.lock'" err
16801678
)
16811679
'
16821680

@@ -1689,11 +1687,9 @@ test_expect_success 'stash push reports a locked index' '
16891687
echo change >A.file &&
16901688
touch .git/index.lock &&
16911689
1692-
cat >expect <<-EOF &&
1693-
error: could not write index
1694-
EOF
16951690
test_must_fail git stash push 2>err &&
1696-
test_cmp expect err
1691+
test_grep "error: could not write index" err &&
1692+
test_grep "error: Unable to create '.*index.lock'" err
16971693
)
16981694
'
16991695

@@ -1707,11 +1703,9 @@ test_expect_success 'stash apply reports a locked index' '
17071703
git stash push &&
17081704
touch .git/index.lock &&
17091705
1710-
cat >expect <<-EOF &&
1711-
error: could not write index
1712-
EOF
17131706
test_must_fail git stash apply 2>err &&
1714-
test_cmp expect err
1707+
test_grep "error: could not write index" err &&
1708+
test_grep "error: Unable to create '.*index.lock'" err
17151709
)
17161710
'
17171711

0 commit comments

Comments
 (0)