]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t3201: test multiple branch filter combinations
authorAaron Lipman <alipman88@gmail.com>
Wed, 16 Sep 2020 02:08:38 +0000 (22:08 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 16 Sep 2020 19:38:09 +0000 (12:38 -0700)
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 <alipman88@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3201-branch-contains.sh

index 40251c9f8f68cbfba145976eb912ecdd3364dc65..3cb9dc6cca53faacc6b00d8f09206c32d421963f 100755 (executable)
@@ -171,6 +171,42 @@ test_expect_success 'Assert that --contains only works on commits, not trees & b
        test_must_fail git branch --no-contains $blob
 '
 
+test_expect_success 'multiple branch --contains' '
+       git checkout -b side2 master &&
+       >feature &&
+       git add feature &&
+       git commit -m "add feature" &&
+       git checkout -b next master &&
+       git merge side &&
+       git branch --contains side --contains side2 >actual &&
+       cat >expect <<-\EOF &&
+       * next
+         side
+         side2
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'multiple branch --no-contains' '
+       git branch --no-contains side --no-contains side2 >actual &&
+       cat >expect <<-\EOF &&
+         master
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'branch --contains combined with --no-contains' '
+       git checkout -b seen master &&
+       git merge side &&
+       git merge side2 &&
+       git branch --contains side --no-contains side2 >actual &&
+       cat >expect <<-\EOF &&
+         next
+         side
+       EOF
+       test_cmp expect actual
+'
+
 # We want to set up a case where the walk for the tracking info
 # of one branch crosses the tip of another branch (and make sure
 # 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' '
        test_i18ncmp expect actual
 '
 
-test_expect_success 'branch --contains combined with --no-contains' '
-       git branch --contains zzz --no-contains topic >actual &&
-       cat >expect <<-\EOF &&
-         master
-         side
-         zzz
-       EOF
-       test_cmp expect actual
-
-'
-
 test_done