3 test_description='test cherry-picking an empty commit'
7 test_expect_success setup '
12 git commit -m "first" &&
14 git checkout -b empty-message-branch &&
15 echo third >> file1 &&
18 git commit --allow-empty-message -m "" &&
20 git checkout master &&
21 git checkout -b empty-change-branch &&
23 git commit --allow-empty -m "empty"
27 test_expect_success 'cherry-pick an empty commit' '
28 git checkout master &&
29 test_expect_code 1 git cherry-pick empty-change-branch
32 test_expect_success 'index lockfile was removed' '
33 test ! -f .git/index.lock
36 test_expect_success 'cherry-pick a commit with an empty message' '
37 test_when_finished "git reset --hard empty-message-branch~1" &&
38 git checkout master &&
39 git cherry-pick empty-message-branch
42 test_expect_success 'index lockfile was removed' '
43 test ! -f .git/index.lock
46 test_expect_success 'cherry-pick a commit with an empty message with --allow-empty-message' '
47 git checkout -f master &&
48 git cherry-pick --allow-empty-message empty-message-branch
51 test_expect_success 'cherry pick an empty non-ff commit without --allow-empty' '
52 git checkout master &&
53 echo fourth >>file2 &&
55 git commit -m "fourth" &&
56 test_must_fail git cherry-pick empty-change-branch
59 test_expect_success 'cherry pick an empty non-ff commit with --allow-empty' '
60 git checkout master &&
61 git cherry-pick --allow-empty empty-change-branch
64 test_expect_success 'cherry pick with --keep-redundant-commits' '
65 git checkout master &&
66 git cherry-pick --keep-redundant-commits HEAD^
69 test_expect_success 'cherry-pick a commit that becomes no-op (prep)' '
70 git checkout master &&
75 git commit -m "add file2 on master" &&
81 git commit -m "add file2 on the side"
84 test_expect_success 'cherry-pick a no-op without --keep-redundant' '
86 git checkout fork^0 &&
87 test_must_fail git cherry-pick master
90 test_expect_success 'cherry-pick a no-op with --keep-redundant' '
92 git checkout fork^0 &&
93 git cherry-pick --keep-redundant-commits master &&
94 git show -s --format=%s >actual &&
95 echo "add file2 on master" >expect &&
96 test_cmp expect actual