]> git.ipfire.org Git - thirdparty/git.git/commit - t/t7004-tag.sh
tag: implicitly supply --list given another list-like option
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 24 Mar 2017 18:40:55 +0000 (18:40 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Mar 2017 19:15:26 +0000 (12:15 -0700)
commit6a338149f623f493525324bc0f8d7bb9257cb840
treea163e31dd5963e4b25b10f641ad9474234927dbc
parentc485b24c427254fe36c2c6cc970519b797abd6bc
tag: implicitly supply --list given another list-like option

Change the "tag" command to implicitly turn on its --list mode when
provided with a list-like option such as --contains, --points-at etc.

This is for consistency with how "branch" works. When "branch" is
given a list-like option, such as --contains, it implicitly provides
--list. Before this change "tag" would error out on those sorts of
invocations. I.e. while both of these worked for "branch":

    git branch --contains v2.8.0 <pattern>
    git branch --list --contains v2.8.0 <pattern>

Only the latter form worked for "tag":

    git tag --contains v2.8.0 '*rc*'
    git tag --list --contains v2.8.0 '*rc*'

Now "tag", like "branch", will implicitly supply --list when a
list-like option is provided, and no other conflicting non-list
options (such as -d) are present on the command-line.

Spelunking through the history via:

    git log --reverse -p -G'only allowed with' -- '*builtin*tag*c'

Reveals that there was no good reason for not allowing this in the
first place. The --contains option added in 32c35cfb1e ("git-tag: Add
--contains option", 2009-01-26) made this an error. All the other
subsequent list-like options that were added copied its pattern of
making this usage an error.

The only tests that break as a result of this change are tests that
were explicitly checking that this "branch-like" usage wasn't
permitted. Change those failing tests to check that this invocation
mode is permitted, add extra tests for the list-like options we
weren't testing, and tests to ensure that e.g. we don't toggle the
list mode in the presence of other conflicting non-list options.

With this change errors messages such as "--contains option is only
allowed with -l" don't make sense anymore, since options like
--contain turn on -l. Instead we error out when list-like options such
as --contain are used in conjunction with conflicting options such as
-d or -v.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-tag.txt
builtin/tag.c
t/t7004-tag.sh