]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3505-cherry-pick-empty.sh
path.c: don't call the match function without value in trie_find()
[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
a3ec9eaf 14 git checkout -b empty-message-branch &&
2c048a30
CC
15 echo third >> file1 &&
16 git add file1 &&
17 test_tick &&
bedfe86c
NH
18 git commit --allow-empty-message -m "" &&
19
20 git checkout master &&
a3ec9eaf 21 git checkout -b empty-change-branch &&
bedfe86c
NH
22 test_tick &&
23 git commit --allow-empty -m "empty"
0d66e959
CJ
24
25'
26
c6720cfa 27test_expect_success 'cherry-pick an empty commit' '
15c7348e 28 git checkout master &&
a3ec9eaf 29 test_expect_code 1 git cherry-pick empty-change-branch
2c048a30
CC
30'
31
32test_expect_success 'index lockfile was removed' '
2c048a30 33 test ! -f .git/index.lock
2c048a30
CC
34'
35
36test_expect_success 'cherry-pick a commit with an empty message' '
a3ec9eaf 37 test_when_finished "git reset --hard empty-message-branch~1" &&
15c7348e 38 git checkout master &&
a3ec9eaf 39 git cherry-pick empty-message-branch
0d66e959
CJ
40'
41
42test_expect_success 'index lockfile was removed' '
0d66e959 43 test ! -f .git/index.lock
0d66e959
CJ
44'
45
4bee9584
CW
46test_expect_success 'cherry-pick a commit with an empty message with --allow-empty-message' '
47 git checkout -f master &&
a3ec9eaf 48 git cherry-pick --allow-empty-message empty-message-branch
4bee9584
CW
49'
50
bedfe86c
NH
51test_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" &&
a3ec9eaf 56 test_must_fail git cherry-pick empty-change-branch
bedfe86c
NH
57'
58
59test_expect_success 'cherry pick an empty non-ff commit with --allow-empty' '
60 git checkout master &&
a3ec9eaf 61 git cherry-pick --allow-empty empty-change-branch
bedfe86c
NH
62'
63
64test_expect_success 'cherry pick with --keep-redundant-commits' '
65 git checkout master &&
66 git cherry-pick --keep-redundant-commits HEAD^
67'
68
ac2b0e8f
JH
69test_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" &&
76
77 git checkout fork &&
78 echo foo >file2 &&
79 git add file2 &&
80 test_tick &&
81 git commit -m "add file2 on the side"
82'
83
84test_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
88'
89
90test_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 &&
15c7348e 94 git show -s --format=%s >actual &&
ac2b0e8f
JH
95 echo "add file2 on master" >expect &&
96 test_cmp expect actual
97'
98
0d66e959 99test_done