From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, Jake Goulding <goulding@vivisimo.com>,
Jeff King <peff@peff.net>, Tom Grennan <tmgrennan@gmail.com>,
Karthik Nayak <karthik.188@gmail.com>
Subject: Re: [PATCH] tag: Implicitly supply --list given another list-like option
Date: Sat, 11 Mar 2017 19:19:00 -0800 [thread overview]
Message-ID: <xmqq4lyzw5az.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170311120855.16756-1-avarab@gmail.com> ("Ævar Arnfjörð Bjarmason"'s message of "Sat, 11 Mar 2017 12:08:55 +0000")
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> Change these invocations which currently error out without the -l, to
> behave as if though -l was provided:
>
> git tag -l [--contains|--points-at|--[no-]merged] <commit>
Shouldn't this be
git tag -l [[--[no-]contains|--points-at|--[no-]merged] <commit>] [<pattern>]
i.e. if you are giving <commit> you need how that commit is used in
filtering, but you do not have to give any such filter when listing,
and <pattern>, when given, is used to further limit the output, but
it also is optional.
> Subject: Re: [PATCH] tag: Implicitly supply --list given another list-like option
s/Implicit/implicit/ (ask "git shortlog --no-merges" over recent history)
> diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt
> index 525737a5d8..c80d9e11ba 100644
> --- a/Documentation/git-tag.txt
> +++ b/Documentation/git-tag.txt
> @@ -94,6 +94,9 @@ OPTIONS
> lists all tags. The pattern is a shell wildcard (i.e., matched
> using fnmatch(3)). Multiple patterns may be given; if any of
> them matches, the tag is shown.
> ++
> +We supply this option implicitly if any other list-like option is
> +provided. E.g. `--contains`, `--points-at` etc.
Who are "we"?
When any option that only makes sense in the list mode
(e.g. `--contains`) is given, the command defaults to
the `--list` mode.
By the way, do we catch it as a command line error when options like
`--points-at` are given when we are creating a new tag?
> diff --git a/builtin/tag.c b/builtin/tag.c
> index ad29be6923..6ab65bcf6b 100644
> --- a/builtin/tag.c
> +++ b/builtin/tag.c
> @@ -454,6 +454,12 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
> }
> create_tag_object = (opt.sign || annotate || msg.given || msgfile);
>
> + /* We implicitly supply --list with --contains, --points-at,
> + --merged and --no-merged, just like git-branch */
/*
* We write multi-line comments like this,
* without anything other than slash-asterisk or
* asterisk-slash on the first and last lines.
*/
> + if (filter.with_commit || filter.points_at.nr || filter.merge_commit)
> + cmdmode = 'l';
Don't we want to make sure we do the defaulting only upon !cmdmode?
Doesn't this start ignoring
tag -a -m foo --points-at HEAD bar
as an error otherwise?
> + /* Just plain "git tag" is like "git tag --list" */
> if (argc == 0 && !cmdmode)
> cmdmode = 'l';
> @@ -486,12 +492,6 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
> }
> if (filter.lines != -1)
> die(_("-n option is only allowed with -l."));
> - if (filter.with_commit)
> - die(_("--contains option is only allowed with -l."));
> - if (filter.points_at.nr)
> - die(_("--points-at option is only allowed with -l."));
> - if (filter.merge_commit)
> - die(_("--merged and --no-merged option are only allowed with -l"));
And I do not think removal of these check is a good idea at all.
Perhaps you were too focused on '-l' that you forgot that people may
be giving an explicit option like -a or -s, in which case these
error checks are still very sensible things to have, no?
next prev parent reply other threads:[~2017-03-12 3:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 10:43 BUG: "git branch --contains <commit> <name>" does nothing, silently fails Ævar Arnfjörð Bjarmason
2017-03-10 12:42 ` Jeff King
2017-03-10 13:23 ` Ævar Arnfjörð Bjarmason
2017-03-11 12:08 ` [PATCH] tag: Implicitly supply --list given another list-like option Ævar Arnfjörð Bjarmason
2017-03-11 12:14 ` Ævar Arnfjörð Bjarmason
2017-03-12 2:51 ` Junio C Hamano
2017-03-12 3:00 ` Junio C Hamano
2017-03-12 9:15 ` Ævar Arnfjörð Bjarmason
2017-03-12 3:19 ` Junio C Hamano [this message]
2017-03-12 9:15 ` Ævar Arnfjörð Bjarmason
2017-03-12 11:19 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq4lyzw5az.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=goulding@vivisimo.com \
--cc=karthik.188@gmail.com \
--cc=peff@peff.net \
--cc=tmgrennan@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.