]>
Commit | Line | Data |
---|---|---|
3f7dfe77 JH |
1 | #!/bin/sh |
2 | ||
ac3f5a34 | 3 | test_description='branch --contains <commit>, --no-contains <commit> --merged, and --no-merged' |
3f7dfe77 JH |
4 | |
5 | . ./test-lib.sh | |
6 | ||
7 | test_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 | ||
28 | test_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 | ||
38 | test_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 |
48 | test_expect_success 'branch --no-contains=master' ' |
49 | ||
50 | git branch --no-contains=master >actual && | |
51 | >expect && | |
52 | test_cmp expect actual | |
53 | ||
54 | ' | |
55 | ||
56 | test_expect_success 'branch --no-contains master' ' | |
57 | ||
58 | git branch --no-contains master >actual && | |
59 | >expect && | |
60 | test_cmp expect actual | |
61 | ||
62 | ' | |
63 | ||
3f7dfe77 JH |
64 | test_expect_success 'branch --contains=side' ' |
65 | ||
66 | git branch --contains=side >actual && | |
67 | { | |
68 | echo "* side" | |
69 | } >expect && | |
82ebb0b6 | 70 | test_cmp expect actual |
3f7dfe77 JH |
71 | |
72 | ' | |
73 | ||
ac3f5a34 ÆAB |
74 | test_expect_success 'branch --no-contains=side' ' |
75 | ||
76 | git branch --no-contains=side >actual && | |
77 | { | |
78 | echo " master" | |
79 | } >expect && | |
80 | test_cmp expect actual | |
81 | ||
82 | ' | |
83 | ||
d0403508 JK |
84 | test_expect_success 'branch --contains with pattern implies --list' ' |
85 | ||
86 | git branch --contains=master master >actual && | |
87 | { | |
88 | echo " master" | |
89 | } >expect && | |
90 | test_cmp expect actual | |
91 | ||
92 | ' | |
93 | ||
ac3f5a34 ÆAB |
94 | test_expect_success 'branch --no-contains with pattern implies --list' ' |
95 | ||
96 | git branch --no-contains=master master >actual && | |
97 | >expect && | |
98 | test_cmp expect actual | |
99 | ||
100 | ' | |
101 | ||
f9fd5210 LH |
102 | test_expect_success 'side: branch --merged' ' |
103 | ||
104 | git branch --merged >actual && | |
105 | { | |
106 | echo " master" && | |
107 | echo "* side" | |
108 | } >expect && | |
109 | test_cmp expect actual | |
110 | ||
111 | ' | |
112 | ||
d0403508 JK |
113 | test_expect_success 'branch --merged with pattern implies --list' ' |
114 | ||
115 | git branch --merged=side master >actual && | |
116 | { | |
117 | echo " master" | |
118 | } >expect && | |
119 | test_cmp expect actual | |
120 | ||
121 | ' | |
122 | ||
f9fd5210 LH |
123 | test_expect_success 'side: branch --no-merged' ' |
124 | ||
125 | git branch --no-merged >actual && | |
126 | >expect && | |
127 | test_cmp expect actual | |
128 | ||
129 | ' | |
130 | ||
131 | test_expect_success 'master: branch --merged' ' | |
132 | ||
133 | git checkout master && | |
134 | git branch --merged >actual && | |
135 | { | |
136 | echo "* master" | |
137 | } >expect && | |
138 | test_cmp expect actual | |
139 | ||
140 | ' | |
141 | ||
142 | test_expect_success 'master: branch --no-merged' ' | |
143 | ||
144 | git branch --no-merged >actual && | |
145 | { | |
146 | echo " side" | |
147 | } >expect && | |
148 | test_cmp expect actual | |
149 | ||
150 | ' | |
151 | ||
d0403508 JK |
152 | test_expect_success 'branch --no-merged with pattern implies --list' ' |
153 | ||
154 | git branch --no-merged=master master >actual && | |
155 | >expect && | |
156 | test_cmp expect actual | |
157 | ||
158 | ' | |
159 | ||
160 | test_expect_success 'implicit --list conflicts with modification options' ' | |
161 | ||
162 | test_must_fail git branch --contains=master -d && | |
ac3f5a34 ÆAB |
163 | test_must_fail git branch --contains=master -m foo && |
164 | test_must_fail git branch --no-contains=master -d && | |
165 | test_must_fail git branch --no-contains=master -m foo | |
d0403508 JK |
166 | |
167 | ' | |
168 | ||
b643827b ÆAB |
169 | test_expect_success 'Assert that --contains only works on commits, not trees & blobs' ' |
170 | test_must_fail git branch --contains master^{tree} && | |
171 | blob=$(git hash-object -w --stdin <<-\EOF | |
172 | Some blob | |
173 | EOF | |
174 | ) && | |
ac3f5a34 ÆAB |
175 | test_must_fail git branch --contains $blob && |
176 | test_must_fail git branch --no-contains $blob | |
b643827b ÆAB |
177 | ' |
178 | ||
8376a704 JK |
179 | # We want to set up a case where the walk for the tracking info |
180 | # of one branch crosses the tip of another branch (and make sure | |
181 | # that the latter walk does not mess up our flag to see if it was | |
182 | # merged). | |
183 | # | |
184 | # Here "topic" tracks "master" with one extra commit, and "zzz" points to the | |
185 | # same tip as master The name "zzz" must come alphabetically after "topic" | |
186 | # as we process them in that order. | |
187 | test_expect_success 'branch --merged with --verbose' ' | |
188 | git branch --track topic master && | |
189 | git branch zzz topic && | |
190 | git checkout topic && | |
191 | test_commit foo && | |
192 | git branch --merged topic >actual && | |
193 | cat >expect <<-\EOF && | |
194 | master | |
195 | * topic | |
196 | zzz | |
197 | EOF | |
198 | test_cmp expect actual && | |
199 | git branch --verbose --merged topic >actual && | |
200 | cat >expect <<-\EOF && | |
201 | master c77a0a9 second on master | |
202 | * topic 2c939f4 [ahead 1] foo | |
203 | zzz c77a0a9 second on master | |
204 | EOF | |
1edbaac3 | 205 | test_i18ncmp expect actual |
8376a704 JK |
206 | ' |
207 | ||
ac3f5a34 ÆAB |
208 | test_expect_success 'branch --contains combined with --no-contains' ' |
209 | git branch --contains zzz --no-contains topic >actual && | |
210 | cat >expect <<-\EOF && | |
211 | master | |
212 | side | |
213 | zzz | |
214 | EOF | |
215 | test_cmp expect actual | |
216 | ||
217 | ' | |
218 | ||
3f7dfe77 | 219 | test_done |