Merge branch 'nd/style-opening-brace'
[git.git] / t / t3505-cherry-pick-empty.sh
blob5f911bb5290f33126380c45f3f5874d03f78a677
1 #!/bin/sh
3 test_description='test cherry-picking an empty commit'
5 . ./test-lib.sh
7 test_expect_success setup '
9 echo first > file1 &&
10 git add file1 &&
11 test_tick &&
12 git commit -m "first" &&
14 git checkout -b empty-message-branch &&
15 echo third >> file1 &&
16 git add file1 &&
17 test_tick &&
18 git commit --allow-empty-message -m "" &&
20 git checkout master &&
21 git checkout -b empty-change-branch &&
22 test_tick &&
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 &&
54 git add 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 &&
71 git branch fork &&
72 echo foo >file2 &&
73 git add file2 &&
74 test_tick &&
75 git commit -m "add file2 on master" &&
77 git checkout fork &&
78 echo foo >file2 &&
79 git add file2 &&
80 test_tick &&
81 git commit -m "add file2 on the side"
84 test_expect_success 'cherry-pick a no-op without --keep-redundant' '
85 git reset --hard &&
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' '
91 git reset --hard &&
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
99 test_done