Skip to content

Commit b775d81

Browse files
alipman88gitster
authored andcommitted
t3201: test multiple branch filter combinations
Add tests covering the behavior of passing multiple contains/no-contains filters to git branch, e.g.: $ git branch --contains feature_a --contains feature_b $ git branch --no-contains feature_a --no-contains feature_b When passed more than one contains (or no-contains) filter, the tips of the branches returned must be reachable from any of the contains commits and from none of the the no-contains commits. This logic is useful to describe prior to enabling multiple merged/no-merged filters, so that future tests will demonstrate consistent behavior between merged/no-merged and contains/no-contains filters. Signed-off-by: Aaron Lipman <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 54e85e7 commit b775d81

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

t/t3201-branch-contains.sh

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,42 @@ test_expect_success 'Assert that --contains only works on commits, not trees & b
171171
test_must_fail git branch --no-contains $blob
172172
'
173173

174+
test_expect_success 'multiple branch --contains' '
175+
git checkout -b side2 master &&
176+
>feature &&
177+
git add feature &&
178+
git commit -m "add feature" &&
179+
git checkout -b next master &&
180+
git merge side &&
181+
git branch --contains side --contains side2 >actual &&
182+
cat >expect <<-\EOF &&
183+
* next
184+
side
185+
side2
186+
EOF
187+
test_cmp expect actual
188+
'
189+
190+
test_expect_success 'multiple branch --no-contains' '
191+
git branch --no-contains side --no-contains side2 >actual &&
192+
cat >expect <<-\EOF &&
193+
master
194+
EOF
195+
test_cmp expect actual
196+
'
197+
198+
test_expect_success 'branch --contains combined with --no-contains' '
199+
git checkout -b seen master &&
200+
git merge side &&
201+
git merge side2 &&
202+
git branch --contains side --no-contains side2 >actual &&
203+
cat >expect <<-\EOF &&
204+
next
205+
side
206+
EOF
207+
test_cmp expect actual
208+
'
209+
174210
# We want to set up a case where the walk for the tracking info
175211
# of one branch crosses the tip of another branch (and make sure
176212
# that the latter walk does not mess up our flag to see if it was
@@ -200,15 +236,4 @@ test_expect_success 'branch --merged with --verbose' '
200236
test_i18ncmp expect actual
201237
'
202238

203-
test_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-
214239
test_done

0 commit comments

Comments
 (0)