git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 1/3] t3201: test multiple branch filter combinations

From
Aaron Lipman <alipman88@gmail.com>
Date
Sep 13, 2020, 19:31 UTC
Message-ID
<20200913193140.66906-2-alipman88@gmail.com>
In-Reply-To
<20200913193140.66906-1-alipman88@gmail.com>

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 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>
---
 t/t3201-branch-contains.sh | 44 ++++++++++++++++++++++++++++++++++----
 1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh
index 40251c9f8f..cd205b5560 100755
--- a/t/t3201-branch-contains.sh
+++ b/t/t3201-branch-contains.sh
@@ -200,15 +200,51 @@ 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 &&
+# The next series of tests covers multiple filter combinations
+test_expect_success 'set up repo for multiple filter combination tests' '
+	git checkout master &&
+	git branch | grep -v master | xargs git branch -D &&
+	git checkout -b feature_a master &&
+	>feature_a &&
+	git add feature_a &&
+	git commit -m "add feature a" &&
+	git checkout -b feature_b master &&
+	>feature_b &&
+	git add feature_b &&
+	git commit -m "add feature b"
+'
+
+test_expect_success 'multiple branch --contains' '
+	git checkout -b next master &&
+	git merge feature_a &&
+	git branch --contains feature_a --contains feature_b >actual &&
+	cat >expect <<-\EOF &&
+	  feature_a
+	  feature_b
+	* next
+	EOF
+	test_cmp expect actual
+'
+
+test_expect_success 'multiple branch --no-contains' '
+	git branch --no-contains feature_a --no-contains feature_b >actual &&
 	cat >expect <<-\EOF &&
 	  master
-	  side
-	  zzz
 	EOF
 	test_cmp expect actual
+'
 
+test_expect_success 'branch --contains combined with --no-contains' '
+	git checkout master &&
+	git merge feature_a &&
+	git checkout next &&
+	git merge feature_b &&
+	git branch --contains feature_a --no-contains feature_b >actual &&
+	cat >expect <<-\EOF &&
+	  feature_a
+	  master
+	EOF
+	test_cmp expect actual
 '
 
 test_done
-- 
2.24.3 (Apple Git-128)
Previous: Aaron LipmanNext: Eric Sunshine
Message 10 of 36 in “ref-filter: allow merged and no-merged filters”
  1. ref-filter: allow merged and no-merged filtersAaron Lipman, Sep 8, 2020
  2. Junio C HamanoSep 8, 2020
  3. Aaron LipmanSep 8, 2020
  4. Junio C HamanoSep 9, 2020
  5. 0/2 git branch: allow combining merged and no-merged filtersAaron Lipman, Sep 11, 2020
  6. 1/2 t3201: test multiple branch filter combinationsAaron Lipman, Sep 11, 2020
  7. 2/2 ref-filter: allow merged and no-merged filtersAaron Lipman, Sep 11, 2020
  8. Junio C HamanoSep 11, 2020
  9. 0/3 git branch: allow combining merged and no-merged filtersAaron Lipman, Sep 13, 2020
  10. 1/3 t3201: test multiple branch filter combinationsAaron Lipman, Sep 13, 2020
  11. Eric SunshineSep 13, 2020
  12. Junio C HamanoSep 14, 2020
  13. 2/3 Doc: cover multiple contains/no-contains filtersAaron Lipman, Sep 13, 2020
  14. Eric SunshineSep 13, 2020
  15. Junio C HamanoSep 14, 2020
  16. 3/3 ref-filter: allow merged and no-merged filtersAaron Lipman, Sep 13, 2020
  17. Eric SunshineSep 13, 2020
  18. Junio C HamanoSep 13, 2020
  19. Eric SunshineSep 13, 2020
  20. 0/3 git branch: allow combining merged and no-merged filtersAaron Lipman, Sep 16, 2020
  21. 1/3 t3201: test multiple branch filter combinationsAaron Lipman, Sep 16, 2020
  22. 2/3 Doc: cover multiple contains/no-contains filtersAaron Lipman, Sep 16, 2020
  23. Junio C HamanoSep 16, 2020
  24. 3/3 ref-filter: allow merged and no-merged filtersAaron Lipman, Sep 16, 2020
  25. Junio C HamanoSep 16, 2020
  26. Eric SunshineSep 16, 2020
  27. 0/2 ref-filter: merged & no-merged touch-upsAaron Lipman, Sep 18, 2020
  28. 1/2 ref-filter: refactor do_merge_filter()Aaron Lipman, Sep 18, 2020
  29. Eric SunshineSep 18, 2020
  30. Eric SunshineSep 18, 2020
  31. Junio C HamanoSep 18, 2020
  32. 2/2 Doc: prefer more specific file nameAaron Lipman, Sep 18, 2020
  33. Eric SunshineSep 18, 2020
  34. 0/2 ref-filter: merged & no-merged touch-upsAaron Lipman, Sep 18, 2020
  35. 1/2 ref-filter: make internal reachable-filter API more preciseAaron Lipman, Sep 18, 2020
  36. 2/2 Doc: prefer more specific file nameAaron Lipman, Sep 18, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.