]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3201-branch-contains.sh
Merge branch 'js/update-index-ignore-removal-for-skip-worktree'
[thirdparty/git.git] / t / t3201-branch-contains.sh
CommitLineData
3f7dfe77
JH
1#!/bin/sh
2
ac3f5a34 3test_description='branch --contains <commit>, --no-contains <commit> --merged, and --no-merged'
3f7dfe77
JH
4
5. ./test-lib.sh
6
7test_expect_success setup '
8
9 >file &&
10 git add file &&
11 test_tick &&
12 git commit -m initial &&
13 git branch side &&
14
15 echo 1 >file &&
16 test_tick &&
17 git commit -a -m "second on master" &&
18
19 git checkout side &&
20 echo 1 >file &&
21 test_tick &&
22 git commit -a -m "second on side" &&
23
24 git merge master
25
26'
27
28test_expect_success 'branch --contains=master' '
29
30 git branch --contains=master >actual &&
31 {
32 echo " master" && echo "* side"
33 } >expect &&
82ebb0b6 34 test_cmp expect actual
3f7dfe77
JH
35
36'
37
38test_expect_success 'branch --contains master' '
39
40 git branch --contains master >actual &&
41 {
42 echo " master" && echo "* side"
43 } >expect &&
82ebb0b6 44 test_cmp expect actual
3f7dfe77
JH
45
46'
47
ac3f5a34
ÆAB
48test_expect_success 'branch --no-contains=master' '
49
50 git branch --no-contains=master >actual &&
d3c6751b 51 test_must_be_empty actual
ac3f5a34
ÆAB
52
53'
54
55test_expect_success 'branch --no-contains master' '
56
57 git branch --no-contains master >actual &&
d3c6751b 58 test_must_be_empty actual
ac3f5a34
ÆAB
59
60'
61
3f7dfe77
JH
62test_expect_success 'branch --contains=side' '
63
64 git branch --contains=side >actual &&
65 {
66 echo "* side"
67 } >expect &&
82ebb0b6 68 test_cmp expect actual
3f7dfe77
JH
69
70'
71
ac3f5a34
ÆAB
72test_expect_success 'branch --no-contains=side' '
73
74 git branch --no-contains=side >actual &&
75 {
76 echo " master"
77 } >expect &&
78 test_cmp expect actual
79
80'
81
d0403508
JK
82test_expect_success 'branch --contains with pattern implies --list' '
83
84 git branch --contains=master master >actual &&
85 {
86 echo " master"
87 } >expect &&
88 test_cmp expect actual
89
90'
91
ac3f5a34
ÆAB
92test_expect_success 'branch --no-contains with pattern implies --list' '
93
94 git branch --no-contains=master master >actual &&
d3c6751b 95 test_must_be_empty actual
ac3f5a34
ÆAB
96
97'
98
f9fd5210
LH
99test_expect_success 'side: branch --merged' '
100
101 git branch --merged >actual &&
102 {
103 echo " master" &&
104 echo "* side"
105 } >expect &&
106 test_cmp expect actual
107
108'
109
d0403508
JK
110test_expect_success 'branch --merged with pattern implies --list' '
111
112 git branch --merged=side master >actual &&
113 {
114 echo " master"
115 } >expect &&
116 test_cmp expect actual
117
118'
119
f9fd5210
LH
120test_expect_success 'side: branch --no-merged' '
121
122 git branch --no-merged >actual &&
d3c6751b 123 test_must_be_empty actual
f9fd5210
LH
124
125'
126
127test_expect_success 'master: branch --merged' '
128
129 git checkout master &&
130 git branch --merged >actual &&
131 {
132 echo "* master"
133 } >expect &&
134 test_cmp expect actual
135
136'
137
138test_expect_success 'master: branch --no-merged' '
139
140 git branch --no-merged >actual &&
141 {
142 echo " side"
143 } >expect &&
144 test_cmp expect actual
145
146'
147
d0403508
JK
148test_expect_success 'branch --no-merged with pattern implies --list' '
149
150 git branch --no-merged=master master >actual &&
d3c6751b 151 test_must_be_empty actual
d0403508
JK
152
153'
154
155test_expect_success 'implicit --list conflicts with modification options' '
156
157 test_must_fail git branch --contains=master -d &&
ac3f5a34
ÆAB
158 test_must_fail git branch --contains=master -m foo &&
159 test_must_fail git branch --no-contains=master -d &&
160 test_must_fail git branch --no-contains=master -m foo
d0403508
JK
161
162'
163
b643827b
ÆAB
164test_expect_success 'Assert that --contains only works on commits, not trees & blobs' '
165 test_must_fail git branch --contains master^{tree} &&
166 blob=$(git hash-object -w --stdin <<-\EOF
167 Some blob
168 EOF
169 ) &&
ac3f5a34
ÆAB
170 test_must_fail git branch --contains $blob &&
171 test_must_fail git branch --no-contains $blob
b643827b
ÆAB
172'
173
8376a704
JK
174# We want to set up a case where the walk for the tracking info
175# of one branch crosses the tip of another branch (and make sure
176# that the latter walk does not mess up our flag to see if it was
177# merged).
178#
179# Here "topic" tracks "master" with one extra commit, and "zzz" points to the
180# same tip as master The name "zzz" must come alphabetically after "topic"
181# as we process them in that order.
182test_expect_success 'branch --merged with --verbose' '
183 git branch --track topic master &&
184 git branch zzz topic &&
185 git checkout topic &&
186 test_commit foo &&
187 git branch --merged topic >actual &&
188 cat >expect <<-\EOF &&
189 master
190 * topic
191 zzz
192 EOF
193 test_cmp expect actual &&
194 git branch --verbose --merged topic >actual &&
a5f61c7d 195 cat >expect <<-EOF &&
196 master $(git rev-parse --short master) second on master
197 * topic $(git rev-parse --short topic ) [ahead 1] foo
198 zzz $(git rev-parse --short zzz ) second on master
8376a704 199 EOF
1edbaac3 200 test_i18ncmp expect actual
8376a704
JK
201'
202
ac3f5a34
ÆAB
203test_expect_success 'branch --contains combined with --no-contains' '
204 git branch --contains zzz --no-contains topic >actual &&
205 cat >expect <<-\EOF &&
206 master
207 side
208 zzz
209 EOF
210 test_cmp expect actual
211
212'
213
3f7dfe77 214test_done