]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3505-cherry-pick-empty.sh
help: add "-a --verbose" to list all commands with synopsis
[thirdparty/git.git] / t / t3505-cherry-pick-empty.sh
CommitLineData
0d66e959
CJ
1#!/bin/sh
2
3test_description='test cherry-picking an empty commit'
4
5. ./test-lib.sh
6
7test_expect_success setup '
8
9 echo first > file1 &&
10 git add file1 &&
11 test_tick &&
12 git commit -m "first" &&
13
14 git checkout -b empty-branch &&
15 test_tick &&
2c048a30
CC
16 git commit --allow-empty -m "empty" &&
17
18 echo third >> file1 &&
19 git add file1 &&
20 test_tick &&
bedfe86c
NH
21 git commit --allow-empty-message -m "" &&
22
23 git checkout master &&
24 git checkout -b empty-branch2 &&
25 test_tick &&
26 git commit --allow-empty -m "empty"
0d66e959
CJ
27
28'
29
c6720cfa 30test_expect_success 'cherry-pick an empty commit' '
15c7348e
FC
31 git checkout master &&
32 test_expect_code 1 git cherry-pick empty-branch^
2c048a30
CC
33'
34
35test_expect_success 'index lockfile was removed' '
2c048a30 36 test ! -f .git/index.lock
2c048a30
CC
37'
38
39test_expect_success 'cherry-pick a commit with an empty message' '
15c7348e
FC
40 git checkout master &&
41 test_expect_code 1 git cherry-pick empty-branch
0d66e959
CJ
42'
43
44test_expect_success 'index lockfile was removed' '
0d66e959 45 test ! -f .git/index.lock
0d66e959
CJ
46'
47
4bee9584
CW
48test_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
51'
52
bedfe86c
NH
53test_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
59'
60
61test_expect_success 'cherry pick an empty non-ff commit with --allow-empty' '
62 git checkout master &&
63 git cherry-pick --allow-empty empty-branch2
64'
65
66test_expect_success 'cherry pick with --keep-redundant-commits' '
67 git checkout master &&
68 git cherry-pick --keep-redundant-commits HEAD^
69'
70
ac2b0e8f
JH
71test_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" &&
78
79 git checkout fork &&
80 echo foo >file2 &&
81 git add file2 &&
82 test_tick &&
83 git commit -m "add file2 on the side"
84'
85
86test_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
90'
91
92test_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 &&
15c7348e 96 git show -s --format=%s >actual &&
ac2b0e8f
JH
97 echo "add file2 on master" >expect &&
98 test_cmp expect actual
99'
100
0d66e959 101test_done