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

Re: [PATCH 3/8] tag: Change misleading --list <pattern> documentation

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 18, 2017, 18:43 UTC
Message-ID
<xmqqmvci2zoc.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170318103256.27141-4-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
Show 5 quoted lines
> However, documenting this as "-l <pattern>" was never correct, as
> these both worked before Jeff's change:
>
>     git tag -l 'v*'
>     git tag 'v*' -l

Actually, we do not particularly care about the latter, and quite honestly, I'd prefer we do not advertise and encourage the latter. Most Git commands take dashed options first and then non-dashed arguments, and so should "git tag". A more important example to show why "-l <pattern>" that pretends <pattern> is an argument to the option is wrong is this:

	git tag -l --merged X 'v*'
and this one
>     git tag --list 'v*rc*' '*2.8*'
Show 19 quoted lines
> diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
> index 74fc82a3c0..d36cd51fe2 100755
> --- a/t/t7004-tag.sh
> +++ b/t/t7004-tag.sh
> @@ -118,6 +118,18 @@ test_expect_success 'listing all tags if one exists should succeed' '
>  	git tag
>  '
>  
> +cat >expect <<EOF
> +mytag
> +EOF
> +test_expect_success 'Multiple -l or --list options are equivalent to one -l option' '
> +	git tag -l -l >actual &&
> +	test_cmp expect actual &&
> +	git tag --list --list >actual &&
> +	test_cmp expect actual &&
> +	git tag --list -l --list >actual &&
> +	test_cmp expect actual
> +'

OK. I do not care too deeply about this one, but somebody may want to tighten up the command line parsing to detect conflicting or duplicated cmdmode as an error in the future, and at that time this will require updating. I am not sure if we want to promise that giving multiple -l will keep working.

> +test_expect_success 'tag -l can accept multiple patterns interleaved with -l or --list options' '
> +	git tag -l "v1*" "v0*" >actual &&
This is good thing to promise that we will keep it working.
Show 5 quoted lines
> +	test_cmp expect actual &&
> +	git tag -l "v1*" --list "v0*" >actual &&
> +	test_cmp expect actual &&
> +	git tag -l "v1*" "v0*" -l --list >actual &&
> +	test_cmp expect actual

I'd prefer we do *not* promise that it will keep working if you give pattern and then later any dashed-option like -l to the command by having tests like these.

Thanks.
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 25 of 41 in “Various changes to the "tag" command”
  1. 0/8 Various changes to the "tag" commandÆvar Arnfjörð Bjarmason, Mar 18, 2017
  2. 1/8 tag: Remove a TODO item from the test suiteÆvar Arnfjörð Bjarmason, Mar 18, 2017
  3. Junio C HamanoMar 18, 2017
  4. 0/2 doc/SubmittingPatches: A couple of minor improvementsÆvar Arnfjörð Bjarmason, Mar 18, 2017
  5. 1/2 doc/SubmittingPatches: clarify the casing convention for "area: change..."Ævar Arnfjörð Bjarmason, Mar 18, 2017
  6. Junio C HamanoMar 18, 2017
  7. Ævar Arnfjörð BjarmasonMar 18, 2017
  8. Junio C HamanoMar 18, 2017
  9. 2/2 doc/SubmittingPatches: show how to get a CLI commit summaryÆvar Arnfjörð Bjarmason, Mar 18, 2017
  10. Junio C HamanoMar 18, 2017
  11. Jakub NarębskiMar 19, 2017
  12. Ævar Arnfjörð BjarmasonMar 19, 2017
  13. 5/8 tag: Implicitly supply --list given the -n optionÆvar Arnfjörð Bjarmason, Mar 18, 2017
  14. Jeff KingMar 20, 2017
  15. 2/8 tag: Refactor the options handling code to be less bizarroÆvar Arnfjörð Bjarmason, Mar 18, 2017
  16. Junio C HamanoMar 18, 2017
  17. Ævar Arnfjörð BjarmasonMar 18, 2017
  18. Junio C HamanoMar 18, 2017
  19. Ævar Arnfjörð BjarmasonMar 18, 2017
  20. 7/8 tag: Add tests for --with and --withoutÆvar Arnfjörð Bjarmason, Mar 18, 2017
  21. 8/8 tag: Change --point-at to default to HEADÆvar Arnfjörð Bjarmason, Mar 18, 2017
  22. Junio C HamanoMar 18, 2017
  23. Ævar Arnfjörð BjarmasonMar 18, 2017
  24. 3/8 tag: Change misleading --list <pattern> documentationÆvar Arnfjörð Bjarmason, Mar 18, 2017
  25. Junio C HamanoMar 18, 2017
  26. Ævar Arnfjörð BjarmasonMar 18, 2017
  27. Jeff KingMar 20, 2017
  28. Junio C HamanoMar 20, 2017
  29. Junio C HamanoMar 20, 2017
  30. Ævar Arnfjörð BjarmasonMar 20, 2017
  31. Jeff KingMar 20, 2017
  32. 4/8 tag: Implicitly supply --list given another list-like optionÆvar Arnfjörð Bjarmason, Mar 18, 2017
  33. Jeff KingMar 20, 2017
  34. Ævar Arnfjörð BjarmasonMar 20, 2017
  35. 6/8 ref-filter: Add --no-contains option to tag/branch/for-each-refÆvar Arnfjörð Bjarmason, Mar 18, 2017
  36. Jeff KingMar 20, 2017
  37. Ævar Arnfjörð BjarmasonMar 20, 2017
  38. Jeff KingMar 20, 2017
  39. Ævar Arnfjörð BjarmasonMar 20, 2017
  40. Jeff KingMar 20, 2017
  41. Junio C HamanoMar 20, 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.