From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
To: git@vger.kernel.org
Cc: "Luis R. Rodriguez" <mcgrof@suse.com>,
Jiri Slaby <jslaby@suse.cz>, Andreas Schwab <schwab@suse.de>,
Jan Kara <jack@suse.cz>
Subject: [PATCH] tag: add -i and --introduced modifier for --contains
Date: Wed, 16 Apr 2014 13:58:58 -0700 [thread overview]
Message-ID: <1397681938-18594-1-git-send-email-mcgrof@do-not-panic.com> (raw)
From: "Luis R. Rodriguez" <mcgrof@suse.com>
Upstream Linux kernel commit c5905afb was introduced on v3.4 but
git describe --contains yields v3.5 while if we use git to look
for the first parent with git describe --first-parent yields
v3.3. The reason for this seems to be that the merge commit that
introduced c5905afb was based on v3.3. At least for --contains
its unclear to me why we get v3.5, the result is not intuitive,
as for --first-parent the issue is that the first parent actually
*is* v3.3. The easiest way to address this it to rely on on the
git tag --contains implmenetation and add a modifier that specifies
you want the tag that first introduced the specified commit.
mcgrof@ergon ~/linux (git::master)$ git tag -i --contains c5905afb
v3.4
mcgrof@ergon ~/linux (git::master)$ git tag --introduced --contains c5905afb
v3.4
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Andreas Schwab <schwab@suse.de>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
builtin/tag.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/builtin/tag.c b/builtin/tag.c
index 6c7c6bd..65a939b 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -21,7 +21,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_("git tag -l [-n[<num>]] [--contains <commit>] [ -i | --introduced --contains <commit> ] [--points-at <object>] "
"\n\t\t[<pattern>...]"),
N_("git tag -v <tagname>..."),
NULL
@@ -195,13 +195,18 @@ static int sort_by_version(const void *a_, const void *b_)
}
static int list_tags(const char **patterns, int lines,
- struct commit_list *with_commit, int sort)
+ struct commit_list *with_commit, int sort,
+ int introduced)
{
struct tag_filter filter;
filter.patterns = patterns;
filter.lines = lines;
- filter.sort = sort;
+ if (introduced) {
+ sort = VERCMP_SORT;
+ filter.sort = sort;
+ } else
+ filter.sort = sort;
filter.with_commit = with_commit;
memset(&filter.tags, 0, sizeof(filter.tags));
filter.tags.strdup_strings = 1;
@@ -216,8 +221,11 @@ static int list_tags(const char **patterns, int lines,
for (i = filter.tags.nr - 1; i >= 0; i--)
printf("%s\n", filter.tags.items[i].string);
else
- for (i = 0; i < filter.tags.nr; i++)
+ for (i = 0; i < filter.tags.nr; i++) {
printf("%s\n", filter.tags.items[i].string);
+ if (introduced)
+ break;
+ }
string_list_clear(&filter.tags, 0);
}
return 0;
@@ -493,6 +501,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
char *cleanup_arg = NULL;
int annotate = 0, force = 0, lines = -1;
int cmdmode = 0, sort = 0;
+ int introduced = 0;
const char *msgfile = NULL, *keyid = NULL;
struct msg_arg msg = { 0, STRBUF_INIT };
struct commit_list *with_commit = NULL;
@@ -511,6 +520,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
N_("tag message"), parse_msg_arg),
OPT_FILENAME('F', "file", &msgfile, N_("read message from file")),
OPT_BOOL('s', "sign", &opt.sign, N_("annotated and GPG-signed tag")),
+ OPT_BOOL('i', "introduced", &introduced, N_("print the first tag that introduced the commit")),
OPT_STRING(0, "cleanup", &cleanup_arg, N_("mode"),
N_("how to strip spaces and #comments from message")),
OPT_STRING('u', "local-user", &keyid, N_("key-id"),
@@ -576,7 +586,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
}
if (lines != -1 && sort)
die(_("--sort and -n are incompatible"));
- ret = list_tags(argv, lines == -1 ? 0 : lines, with_commit, sort);
+ ret = list_tags(argv, lines == -1 ? 0 : lines, with_commit,
+ sort, introduced);
if (column_active(colopts))
stop_column_filter();
return ret;
--
1.9.0
next reply other threads:[~2014-04-16 20:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-16 20:58 Luis R. Rodriguez [this message]
2014-04-16 22:02 ` [PATCH] tag: add -i and --introduced modifier for --contains Junio C Hamano
2014-04-16 22:35 ` Luis R. Rodriguez
2014-04-17 17:04 ` Junio C Hamano
2014-04-17 22:16 ` Jeff King
2014-04-18 16:26 ` Junio C Hamano
2014-04-22 4:04 ` W. Trevor King
2014-04-18 23:17 ` Luis R. Rodriguez
2014-04-18 23:36 ` Junio C Hamano
2014-04-22 0:38 ` Luis R. Rodriguez
2014-04-22 10:27 ` Jan Kara
2014-04-22 17:58 ` Junio C Hamano
2014-04-17 7:17 ` Andreas Schwab
2014-04-17 17:05 ` Junio C Hamano
2014-04-17 17:30 ` Andreas Schwab
2014-04-17 18:49 ` Junio C Hamano
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=1397681938-18594-1-git-send-email-mcgrof@do-not-panic.com \
--to=mcgrof@do-not-panic.com \
--cc=git@vger.kernel.org \
--cc=jack@suse.cz \
--cc=jslaby@suse.cz \
--cc=mcgrof@suse.com \
--cc=schwab@suse.de \
/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).