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

[PATCH v3 05/16] ref-filter: add test for --contains on a non-commit

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 23, 2017, 13:05 UTC
Message-ID
<20170323130529.11361-6-avarab@gmail.com>
In-Reply-To
<20170323130529.11361-1-avarab@gmail.com>

Change the tag test suite to test for --contains on a tree & blob. It only accepts commits and will spew out "<object> is a tree, not a commit".

It's sufficient to test this just for the "tag" and "branch" commands, because it covers all the machinery shared between "branch" and "for-each-ref".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t3201-branch-contains.sh | 9 +++++++++
 t/t7004-tag.sh             | 4 +++-
 2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh
index 7f3ec47241..daa3ae82b7 100755
--- a/t/t3201-branch-contains.sh
+++ b/t/t3201-branch-contains.sh
@@ -130,6 +130,15 @@ test_expect_success 'implicit --list conflicts with modification options' '
 
 '
 
+test_expect_success 'Assert that --contains only works on commits, not trees & blobs' '
+	test_must_fail git branch --contains master^{tree} &&
+	blob=$(git hash-object -w --stdin <<-\EOF
+	Some blob
+	EOF
+	) &&
+	test_must_fail git branch --contains $blob
+'
+
 # 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
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 45790664c1..3439913488 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -1461,7 +1461,9 @@ test_expect_success 'mixing incompatibles modes and options is forbidden' '
 	test_must_fail git tag -n 100 &&
 	test_must_fail git tag -l -m msg &&
 	test_must_fail git tag -l -F some file &&
-	test_must_fail git tag -v -s
+	test_must_fail git tag -v -s &&
+	test_must_fail git tag --contains tag-tree &&
+	test_must_fail git tag --contains tag-blob
 '
 
 # check points-at
-- 
2.11.0
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 6 of 25 in “Various changes to the "tag" command & related”
  1. 00/16 Various changes to the "tag" command & relatedÆvar Arnfjörð Bjarmason, Mar 23, 2017
  2. 01/16 tag doc: move the description of --[no-]merged earlierÆvar Arnfjörð Bjarmason, Mar 23, 2017
  3. 02/16 tag doc: split up the --[no-]merged documentationÆvar Arnfjörð Bjarmason, Mar 23, 2017
  4. 03/16 tag doc: reword --[no-]merged to talk about commits, not tipsÆvar Arnfjörð Bjarmason, Mar 23, 2017
  5. 04/16 ref-filter: make combining --merged & --no-merged an errorÆvar Arnfjörð Bjarmason, Mar 23, 2017
  6. 05/16 ref-filter: add test for --contains on a non-commitÆvar Arnfjörð Bjarmason, Mar 23, 2017
  7. 06/16 tag: remove a TODO item from the test suiteÆvar Arnfjörð Bjarmason, Mar 23, 2017
  8. 08/16 for-each-ref: partly change <object> to <commit> in helpÆvar Arnfjörð Bjarmason, Mar 23, 2017
  9. 07/16 tag tests: fix a typo in a test descriptionÆvar Arnfjörð Bjarmason, Mar 23, 2017
  10. 11/16 tag: change misleading --list <pattern> documentationÆvar Arnfjörð Bjarmason, Mar 23, 2017
  11. Junio C HamanoMar 23, 2017
  12. 13/16 tag: change --point-at to default to HEADÆvar Arnfjörð Bjarmason, Mar 23, 2017
  13. 12/16 tag: implicitly supply --list given another list-like optionÆvar Arnfjörð Bjarmason, Mar 23, 2017
  14. Junio C HamanoMar 23, 2017
  15. Ævar Arnfjörð BjarmasonMar 23, 2017
  16. Junio C HamanoMar 23, 2017
  17. 14/16 ref-filter: add --no-contains option to tag/branch/for-each-refÆvar Arnfjörð Bjarmason, Mar 23, 2017
  18. 15/16 ref-filter: reflow recently changed branch/tag/for-each-ref docsÆvar Arnfjörð Bjarmason, Mar 23, 2017
  19. 10/16 parse-options: add OPT_NONEG to the "contains" optionÆvar Arnfjörð Bjarmason, Mar 23, 2017
  20. 16/16 tag: add tests for --with and --withoutÆvar Arnfjörð Bjarmason, Mar 23, 2017
  21. 09/16 tag: add more incompatibles mode testsÆvar Arnfjörð Bjarmason, Mar 23, 2017
  22. Junio C HamanoMar 23, 2017
  23. Ævar Arnfjörð BjarmasonMar 23, 2017
  24. Junio C HamanoMar 23, 2017
  25. Ævar Arnfjörð BjarmasonMar 23, 2017

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.