Skip to content

Commit c485b24

Browse files
avargitster
authored andcommitted
tag: change misleading --list <pattern> documentation
Change the documentation for --list so that it's described as a toggle, not as an option that takes a <pattern> as an argument. Junio initially documented this in b867c7c ("git-tag: -l to list tags (usability).", 2006-02-17), but later Jeff King changed "tag" to accept multiple patterns in 588d0e8 ("tag: accept multiple patterns for --list", 2011-06-20). 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 One would expect an option that was documented like that to only accept: git tag --list git tag --list 'v*rc*' And after Jeff's change, one that took multiple patterns: git tag --list 'v*rc*' --list '*2.8*' But since it's actually a toggle all of these work as well, and produce identical output to the last example above: git tag --list 'v*rc*' '*2.8*' git tag --list 'v*rc*' '*2.8*' --list --list --list git tag --list 'v*rc*' '*2.8*' --list -l --list -l --list Now the documentation is more in tune with how the "branch" command describes its --list option since commit cddd127 ("branch: introduce --list option", 2011-08-28). Change the test suite to assert that these invocations work for the cases that weren't already being tested for. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eab98ee commit c485b24

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

Documentation/git-tag.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,14 @@ OPTIONS
8787
If no number is given to `-n`, only the first line is printed.
8888
If the tag is not annotated, the commit message is displayed instead.
8989

90-
-l <pattern>::
91-
--list <pattern>::
92-
List tags with names that match the given pattern (or all if no
93-
pattern is given). Running "git tag" without arguments also
94-
lists all tags. The pattern is a shell wildcard (i.e., matched
95-
using fnmatch(3)). Multiple patterns may be given; if any of
96-
them matches, the tag is shown.
90+
-l::
91+
--list::
92+
List tags. With optional `<pattern>...`, e.g. `git tag --list
93+
'v-*'`, list only the tags that match the pattern(s).
94+
+
95+
Running "git tag" without arguments also lists all tags. The pattern
96+
is a shell wildcard (i.e., matched using fnmatch(3)). Multiple
97+
patterns may be given; if any of them matches, the tag is shown.
9798

9899
--sort=<key>::
99100
Sort based on the key given. Prefix `-` to sort in

t/t7004-tag.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ test_expect_success 'listing all tags if one exists should succeed' '
118118
git tag
119119
'
120120

121+
cat >expect <<EOF
122+
mytag
123+
EOF
124+
test_expect_success 'Multiple -l or --list options are equivalent to one -l option' '
125+
git tag -l -l >actual &&
126+
test_cmp expect actual &&
127+
git tag --list --list >actual &&
128+
test_cmp expect actual &&
129+
git tag --list -l --list >actual &&
130+
test_cmp expect actual
131+
'
132+
121133
test_expect_success 'listing all tags if one exists should output that tag' '
122134
test $(git tag -l) = mytag &&
123135
test $(git tag) = mytag
@@ -336,6 +348,19 @@ test_expect_success 'tag -l can accept multiple patterns' '
336348
test_cmp expect actual
337349
'
338350

351+
# Between v1.7.7 & v2.13.0 a fair reading of the git-tag documentation
352+
# could leave you with the impression that "-l <pattern> -l <pattern>"
353+
# was how we wanted to accept multiple patterns.
354+
#
355+
# This test should not imply that this is a sane thing to support. but
356+
# since the documentation was worded like it was let's at least find
357+
# out if we're going to break this long-documented form of taking
358+
# multiple patterns.
359+
test_expect_success 'tag -l <pattern> -l <pattern> works, as our buggy documentation previously suggested' '
360+
git tag -l "v1*" -l "v0*" >actual &&
361+
test_cmp expect actual
362+
'
363+
339364
test_expect_success 'listing tags in column' '
340365
COLUMNS=40 git tag -l --column=row >actual &&
341366
cat >expected <<\EOF &&

0 commit comments

Comments
 (0)