@matheusbsbs / matheus-bagliano / commits / 0d66e95903
Fork 0

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 4271666046. Signed-off-by: Chris Johnsen <chris_johnsen@pobox.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Chris Johnsen committed Mar 7, 2009 at 03:30 UTC 0d66e95903a5c2567baa61cc7299ce865abe41b1
2 files changed +34
builtin-revert.c
+1
@@ -387,6 +387,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
387 (write_cache(index_fd, active_cache, active_nr) ||
388 commit_locked_index(&index_lock)))
389 die("%s: Unable to write new index file", me);
390 + rollback_lock_file(&index_lock);
391
392 if (!clean) {
393 add_to_msg("\nConflicts:\n\n");
t/t3505-cherry-pick-empty.sh new
+33
@@ -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