tgupdate: merge release into t/config/homepage base
[git/gitweb.git] / t / t3505-cherry-pick-empty.sh
blobfbdc47cfbdae6e3cec7d6762faa4a8e13554d803
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-branch &&
15 test_tick &&
16 git commit --allow-empty -m "empty" &&
18 echo third >> file1 &&
19 git add file1 &&
20 test_tick &&
21 git commit --allow-empty-message -m "" &&
23 git checkout master &&
24 git checkout -b empty-branch2 &&
25 test_tick &&
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 &&
56 git add 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 &&
73 git branch fork &&
74 echo foo >file2 &&
75 git add file2 &&
76 test_tick &&
77 git commit -m "add file2 on master" &&
79 git checkout fork &&
80 echo foo >file2 &&
81 git add file2 &&
82 test_tick &&
83 git commit -m "add file2 on the side"
86 test_expect_success 'cherry-pick a no-op without --keep-redundant' '
87 git reset --hard &&
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' '
93 git reset --hard &&
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
101 test_done