git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Keeping <john@keeping.me.uk>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org, christian.couder@gmail.com,
	Matthieu.Moy@grenoble-inp.fr, gitster@pobox.com
Subject: Re: [PATCH v17 14/14] tag.c: implement '--merged' and '--no-merged' options
Date: Thu, 17 Sep 2015 22:36:19 +0100	[thread overview]
Message-ID: <20150917213619.GI17201@serenity.lan> (raw)
In-Reply-To: <1441902169-9891-3-git-send-email-Karthik.188@gmail.com>

On Thu, Sep 10, 2015 at 09:52:49PM +0530, Karthik Nayak wrote:
> Use 'ref-filter' APIs to implement the '--merged' and '--no-merged'
> options into 'tag.c'. The '--merged' option lets the user to only list
> tags merged into the named commit. The '--no-merged' option lets the
> user to only list tags not merged into the named commit.  If no object
> is provided it assumes HEAD as the object.
> 
> Add documentation and tests for the same.
> 
> Mentored-by: Christian Couder <christian.couder@gmail.com>
> Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
> ---
>  Documentation/git-tag.txt |  7 ++++++-
>  builtin/tag.c             |  6 +++++-
>  t/t7004-tag.sh            | 27 +++++++++++++++++++++++++++
>  3 files changed, 38 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt
> index 0c7f4e6..3803bf7 100644
> --- a/Documentation/git-tag.txt
> +++ b/Documentation/git-tag.txt
> @@ -14,7 +14,7 @@ SYNOPSIS
>  'git tag' -d <tagname>...
>  'git tag' [-n[<num>]] -l [--contains <commit>] [--points-at <object>]
>  	[--column[=<options>] | --no-column] [--create-reflog] [--sort=<key>]
> -	[--format=<format>] [<pattern>...]
> +	[--format=<format>] [--[no-]merged [<commit>]] [<pattern>...]
>  'git tag' -v <tagname>...
>  
>  DESCRIPTION
> @@ -165,6 +165,11 @@ This option is only applicable when listing tags without annotation lines.
>  	that of linkgit:git-for-each-ref[1].  When unspecified,
>  	defaults to `%(refname:short)`.
>  
> +--[no-]merged [<commit>]::

We prefer to write --[no-]* as:

	--option::
	--no-option::

although this may be the first instance that we see this combination
with an argument.

I also found the "[<commit>]" syntax confusing and had to go and figure
out what PARSE_OPT_LASTARG_DEFAULT does; I wonder if it's worth
appending something like the following to the help for this option:

	The `commit` may be omitted if this is the final argument.

> +	Only list tags whose tips are reachable, or not reachable
> +	if '--no-merged' is used, from the specified commit ('HEAD'
> +	if not specified).
> +
>  CONFIGURATION
>  -------------
>  By default, 'git tag' in sign-with-default mode (-s) will use your
> diff --git a/builtin/tag.c b/builtin/tag.c
> index 075d90b..081fe84 100644
> --- a/builtin/tag.c
> +++ b/builtin/tag.c
> @@ -23,7 +23,7 @@ static const char * const git_tag_usage[] = {
>  	N_("git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] <tagname> [<head>]"),
>  	N_("git tag -d <tagname>..."),
>  	N_("git tag -l [-n[<num>]] [--contains <commit>] [--points-at <object>]"
> -		"\n\t\t[--format=<format>] [<pattern>...]"),
> +		"\n\t\t[--format=<format>] [--[no-]merged [<commit>]] [<pattern>...]"),
>  	N_("git tag -v <tagname>..."),
>  	NULL
>  };
> @@ -359,6 +359,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
>  		OPT_COLUMN(0, "column", &colopts, N_("show tag list in columns")),
>  		OPT_CONTAINS(&filter.with_commit, N_("print only tags that contain the commit")),
>  		OPT_WITH(&filter.with_commit, N_("print only tags that contain the commit")),
> +		OPT_MERGED(&filter, N_("print only tags that are merged")),
> +		OPT_NO_MERGED(&filter, N_("print only tags that are not merged")),
>  		OPT_CALLBACK(0 , "sort", sorting_tail, N_("key"),
>  			     N_("field name to sort on"), &parse_opt_ref_sorting),
>  		{
> @@ -417,6 +419,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
>  		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"));
>  	if (cmdmode == 'd')
>  		return for_each_tag_name(argv, delete_tag);
>  	if (cmdmode == 'v')
> diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
> index 8987fb1..3dd2f51 100755
> --- a/t/t7004-tag.sh
> +++ b/t/t7004-tag.sh
> @@ -1531,4 +1531,31 @@ test_expect_success '--format should list tags as per format given' '
>  	test_cmp expect actual
>  '
>  
> +test_expect_success 'setup --merged test tags' '
> +	git tag mergetest-1 HEAD~2 &&
> +	git tag mergetest-2 HEAD~1 &&
> +	git tag mergetest-3 HEAD
> +'
> +
> +test_expect_success '--merged cannot be used in non-list mode' '
> +	test_must_fail git tag --merged=mergetest-2 foo
> +'
> +
> +test_expect_success '--merged shows merged tags' '
> +	cat >expect <<-\EOF &&
> +	mergetest-1
> +	mergetest-2
> +	EOF
> +	git tag -l --merged=mergetest-2 mergetest-* >actual &&
> +	test_cmp expect actual
> +'
> +
> +test_expect_success '--no-merged show unmerged tags' '
> +	cat >expect <<-\EOF &&
> +	mergetest-3
> +	EOF
> +	git tag -l --no-merged=mergetest-2 mergetest-* >actual &&
> +	test_cmp expect actual
> +'
> +
>  test_done
> -- 
> 2.5.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2015-09-17 21:41 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-10 15:48 [PATCH v17 00/14] port tag.c to use ref-filter APIs Karthik Nayak
2015-09-10 15:48 ` [PATCH v17 01/14] ref-filter: move `struct atom_value` to ref-filter.c Karthik Nayak
2015-09-10 15:48 ` [PATCH v17 02/14] ref-filter: introduce ref_formatting_state and ref_formatting_stack Karthik Nayak
2015-09-10 15:48 ` [PATCH v17 03/14] utf8: add function to align a string into given strbuf Karthik Nayak
2015-09-10 15:48 ` [PATCH v17 04/14] ref-filter: introduce handler function for each atom Karthik Nayak
2015-09-10 15:48 ` [PATCH v17 05/14] ref-filter: introduce match_atom_name() Karthik Nayak
2015-09-10 16:49   ` Matthieu Moy
2015-09-10 17:23     ` Junio C Hamano
2015-09-10 18:58       ` Matthieu Moy
2015-09-10 16:56   ` Junio C Hamano
2015-09-10 16:59     ` Matthieu Moy
2015-09-10 18:25       ` Junio C Hamano
2015-09-10 17:00     ` Karthik Nayak
2015-09-10 17:28       ` Junio C Hamano
2015-09-10 17:35         ` Karthik Nayak
2015-09-10 17:45           ` Junio C Hamano
2015-09-10 17:49             ` Karthik Nayak
2015-09-11 14:59   ` Karthik Nayak
2015-09-11 15:01   ` [PATCH v17 06/14] ref-filter: implement an `align` atom Karthik Nayak
2015-09-10 15:48 ` Karthik Nayak
2015-09-10 16:53   ` Matthieu Moy
2015-09-10 16:59   ` Junio C Hamano
2015-09-11 15:03   ` Karthik Nayak
2015-09-10 15:48 ` [PATCH v17 07/14] ref-filter: add option to filter out tags, branches and remotes Karthik Nayak
2015-09-10 15:48 ` [PATCH v17 08/14] ref-filter: add support for %(contents:lines=X) Karthik Nayak
2015-09-10 17:14   ` Junio C Hamano
2015-09-10 17:37     ` Karthik Nayak
2015-09-11 15:04   ` Karthik Nayak
2015-09-10 15:48 ` [PATCH v17 09/14] ref-filter: add support to sort by version Karthik Nayak
2015-09-10 15:48 ` [PATCH v17 10/14] ref-filter: add option to match literal pattern Karthik Nayak
2015-09-10 15:48 ` [PATCH v17 11/14] tag.c: use 'ref-filter' data structures Karthik Nayak
2015-09-10 16:22 ` [PATCH v17 12/14] tag.c: use 'ref-filter' APIs Karthik Nayak
2015-09-11 15:06   ` Karthik Nayak
2015-09-10 16:22 ` [PATCH v17 13/14] tag.c: implement '--format' option Karthik Nayak
2015-09-10 17:59   ` Junio C Hamano
2015-09-10 18:04     ` Karthik Nayak
2015-09-11 15:06   ` Karthik Nayak
2015-09-10 16:22 ` [PATCH v17 14/14] tag.c: implement '--merged' and '--no-merged' options Karthik Nayak
2015-09-17 21:36   ` John Keeping [this message]
2015-09-17 22:09     ` Junio C Hamano
2015-09-18  7:10       ` Matthieu Moy
2015-09-18  8:42         ` John Keeping
2015-09-18  9:13           ` Matthieu Moy
2015-09-18 15:10           ` Karthik Nayak
2015-09-18 15:19             ` Matthieu Moy
2015-09-18 15:22               ` Karthik Nayak
2015-09-18 15:30                 ` Matthieu Moy
2015-09-18 15:38                   ` Karthik Nayak
2015-09-18 15:44                     ` Matthieu Moy
2015-09-10 16:57 ` [PATCH v17 00/14] port tag.c to use ref-filter APIs Matthieu Moy
2015-09-11 15:08   ` Karthik Nayak
2015-09-11 17:30     ` Eric Sunshine
2015-09-11 18:05       ` Junio C Hamano
2015-09-11 18:12         ` Karthik Nayak
2015-09-12  9:14     ` Matthieu Moy
2015-09-13  4:54       ` Karthik Nayak

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=20150917213619.GI17201@serenity.lan \
    --to=john@keeping.me.uk \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=karthik.188@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).