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 git cherry-pick empty-branch^
37 test_expect_success
'index lockfile was removed' '
39 test ! -f .git/index.lock
43 test_expect_success
'cherry-pick a commit with an empty message' '
44 git checkout master && {
45 git cherry-pick empty-branch
50 test_expect_success
'index lockfile was removed' '
52 test ! -f .git/index.lock
56 test_expect_success
'cherry-pick a commit with an empty message with --allow-empty-message' '
57 git checkout -f master &&
58 git cherry-pick --allow-empty-message empty-branch
61 test_expect_success
'cherry pick an empty non-ff commit without --allow-empty' '
62 git checkout master &&
63 echo fourth >>file2 &&
65 git commit -m "fourth" &&
66 test_must_fail git cherry-pick empty-branch2
69 test_expect_success
'cherry pick an empty non-ff commit with --allow-empty' '
70 git checkout master &&
71 git cherry-pick --allow-empty empty-branch2
74 test_expect_success
'cherry pick with --keep-redundant-commits' '
75 git checkout master &&
76 git cherry-pick --keep-redundant-commits HEAD^
79 test_expect_success
'cherry-pick a commit that becomes no-op (prep)' '
80 git checkout master &&
85 git commit -m "add file2 on master" &&
91 git commit -m "add file2 on the side"
94 test_expect_success
'cherry-pick a no-op without --keep-redundant' '
96 git checkout fork^0 &&
97 test_must_fail git cherry-pick master
100 test_expect_success
'cherry-pick a no-op with --keep-redundant' '
102 git checkout fork^0 &&
103 git cherry-pick --keep-redundant-commits master &&
104 git show -s --format='%s
' >actual &&
105 echo "add file2 on master" >expect &&
106 test_cmp expect actual