3 test_description
='test cherry-picking an empty commit'
7 test_expect_success setup
'
12 git commit -m "first" &&
14 git checkout -b empty-branch &&
16 git commit --allow-empty -m "empty" &&
18 echo third >> file1 &&
21 git commit --allow-empty-message -m "" &&
23 git checkout master &&
24 git checkout -b empty-branch2 &&
26 git commit --allow-empty -m "empty"
30 test_expect_success
'cherry-pick an empty commit' '
31 git checkout master &&
32 test_expect_code 1 git cherry-pick empty-branch^
35 test_expect_success
'index lockfile was removed' '
36 test ! -f .git/index.lock
39 test_expect_success
'cherry-pick a commit with an empty message' '
40 git checkout master &&
41 test_expect_code 1 git cherry-pick empty-branch
44 test_expect_success
'index lockfile was removed' '
45 test ! -f .git/index.lock
48 test_expect_success
'cherry-pick a commit with an empty message with --allow-empty-message' '
49 git checkout -f master &&
50 git cherry-pick --allow-empty-message empty-branch
53 test_expect_success
'cherry pick an empty non-ff commit without --allow-empty' '
54 git checkout master &&
55 echo fourth >>file2 &&
57 git commit -m "fourth" &&
58 test_must_fail git cherry-pick empty-branch2
61 test_expect_success
'cherry pick an empty non-ff commit with --allow-empty' '
62 git checkout master &&
63 git cherry-pick --allow-empty empty-branch2
66 test_expect_success
'cherry pick with --keep-redundant-commits' '
67 git checkout master &&
68 git cherry-pick --keep-redundant-commits HEAD^
71 test_expect_success
'cherry-pick a commit that becomes no-op (prep)' '
72 git checkout master &&
77 git commit -m "add file2 on master" &&
83 git commit -m "add file2 on the side"
86 test_expect_success
'cherry-pick a no-op without --keep-redundant' '
88 git checkout fork^0 &&
89 test_must_fail git cherry-pick master
92 test_expect_success
'cherry-pick a no-op with --keep-redundant' '
94 git checkout fork^0 &&
95 git cherry-pick --keep-redundant-commits master &&
96 git show -s --format=%s >actual &&
97 echo "add file2 on master" >expect &&
98 test_cmp expect actual