Skip to content

Commit 0d66e95

Browse files
ChrisJohnsengitster
authored andcommitted
builtin-revert.c: release index lock when cherry-picking an empty commit
When a cherry-pick of an empty commit is done, release the lock held on the index. The fix is the same as was applied to similar code in 4271666. Signed-off-by: Chris Johnsen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dcc901b commit 0d66e95

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

builtin-revert.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
387387
(write_cache(index_fd, active_cache, active_nr) ||
388388
commit_locked_index(&index_lock)))
389389
die("%s: Unable to write new index file", me);
390+
rollback_lock_file(&index_lock);
390391

391392
if (!clean) {
392393
add_to_msg("\nConflicts:\n\n");

t/t3505-cherry-pick-empty.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
3+
test_description='test cherry-picking an empty commit'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success setup '
8+
9+
echo first > file1 &&
10+
git add file1 &&
11+
test_tick &&
12+
git commit -m "first" &&
13+
14+
git checkout -b empty-branch &&
15+
test_tick &&
16+
git commit --allow-empty -m "empty"
17+
18+
'
19+
20+
test_expect_code 1 'cherry-pick an empty commit' '
21+
22+
git checkout master &&
23+
git cherry-pick empty-branch
24+
25+
'
26+
27+
test_expect_success 'index lockfile was removed' '
28+
29+
test ! -f .git/index.lock
30+
31+
'
32+
33+
test_done

0 commit comments

Comments
 (0)