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@xxxxxxxxx> --- 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)