{"thread":{"id":"17277","subject":"Re: [PATCH] Add --contains flag to git tag","startedAt":"2009-01-21T01:37:09Z","lastAt":"2009-01-22T17:17:46Z","messageCount":5,"participants":["Jake Goulding","Miklos Vajna","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"101334","messageId":"4448209.246381232501828959.JavaMail.root@scalix.vivisimo.com","threadId":"17277","inReplyTo":"1232501631-21531-3-git-send-email-goulding@vivisimo.com","subject":"Re: [PATCH] Add --contains flag to git tag","fromName":"Jake Goulding","fromEmail":"goulding@vivisimo.com","sentAt":"2009-01-21T01:37:09Z","receivedAt":"2009-01-21T01:37:09Z","isPatch":true,"sender":{"key":"goulding@vivisimo.com","avatar":"https://gravatar.com/avatar/d8938ff226c618b80857e27f7e0a2d4335215bfb9733c321b8dd30c660b7f1e9?d=mp&s=160"},"body":"Ack - I sent that a bit before I meant to (and before I added patch sequence numbers).\n\nThis is a patch that adds a --contains flag to git tag, providing similar functionality as git branch --contains.\n\nPlease let me know what else I have inevitably messed up, and I shall endeavor to fix and resubmit. \n\n-Jake\n\n----- Original Message -----\nFrom: \"Jake Goulding\" <goulding@vivisimo.com>\nTo: git@vger.kernel.org\nCc: \"Jake Goulding\" <goulding@vivisimo.com>\nSent: Tuesday, January 20, 2009 8:33:49 PM GMT -05:00 US/Canada Eastern\nSubject: [PATCH] Add --contains flag to git tag\n\nThis functions similar to how --contains works for git branch - it\nwill show all tags that contain the specified commit. Indeed, it uses\nthe same lookup mechanisms as git branch.\n\nSigned-off-by: Jake Goulding <goulding@vivisimo.com>\n---\n builtin-tag.c |   28 ++++++++++++++++++++++++++--\n 1 files changed, 26 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-tag.c b/builtin-tag.c\nindex a398499..453ed26 100644\n--- a/builtin-tag.c\n+++ b/builtin-tag.c\n@@ -26,6 +26,7 @@ static char signingkey[1000];\n struct tag_filter {\n \tconst char *pattern;\n \tint lines;\n+\tstruct commit_list *with_commit;\n };\n \n #define PGP_SIGNATURE \"-----BEGIN PGP SIGNATURE-----\"\n@@ -35,6 +36,15 @@ static int show_reference(const char *refname, const unsigned char *sha1,\n {\n \tstruct tag_filter *filter = cb_data;\n \n+\tif (filter->with_commit) {\n+\t\tstruct commit *commit;\n+\n+\t\tcommit = lookup_commit_reference_gently(sha1, 1);\n+\t\tif (!commit)\n+\t\t\treturn error(\"branch '%s' does not point at a commit\", refname);\n+\t\tif (!has_commit(commit, filter->with_commit))\n+\t\t\treturn 0;\n+\t}\n \tif (!fnmatch(filter->pattern, refname, 0)) {\n \t\tint i;\n \t\tunsigned long size;\n@@ -79,7 +89,8 @@ static int show_reference(const char *refname, const unsigned char *sha1,\n \treturn 0;\n }\n \n-static int list_tags(const char *pattern, int lines)\n+static int list_tags(const char *pattern, int lines,\n+\t\t\tstruct commit_list *with_commit)\n {\n \tstruct tag_filter filter;\n \n@@ -88,6 +99,7 @@ static int list_tags(const char *pattern, int lines)\n \n \tfilter.pattern = pattern;\n \tfilter.lines = lines;\n+\tfilter.with_commit = with_commit;\n \n \tfor_each_tag_ref(show_reference, (void *) &filter);\n \n@@ -360,6 +372,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\tlist = 0, delete = 0, verify = 0;\n \tconst char *msgfile = NULL, *keyid = NULL;\n \tstruct msg_arg msg = { 0, STRBUF_INIT };\n+\tstruct commit_list *with_commit = NULL;\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN('l', NULL, &list, \"list tag names\"),\n \t\t{ OPTION_INTEGER, 'n', NULL, &lines, NULL,\n@@ -378,6 +391,14 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\tOPT_STRING('u', NULL, &keyid, \"key-id\",\n \t\t\t\t\t\"use another key to sign the tag\"),\n \t\tOPT_BOOLEAN('f', NULL, &force, \"replace the tag if exists\"),\n+\n+\t\tOPT_GROUP(\"Tag listing options\"),\n+\t\t{\n+\t\t\tOPTION_CALLBACK, 0, \"contains\", &with_commit, \"commit\",\n+\t\t\t\"print only tags that contain the commit\",\n+\t\t\tPARSE_OPT_LASTARG_DEFAULT,\n+\t\t\tparse_opt_with_commit, (intptr_t)\"HEAD\",\n+\t\t},\n \t\tOPT_END()\n \t};\n \n@@ -402,9 +423,12 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \tif (list + delete + verify > 1)\n \t\tusage_with_options(git_tag_usage, options);\n \tif (list)\n-\t\treturn list_tags(argv[0], lines == -1 ? 0 : lines);\n+\t\treturn list_tags(argv[0], lines == -1 ? 0 : lines,\n+\t\t\t\t with_commit);\n \tif (lines != -1)\n \t\tdie(\"-n option is only allowed with -l.\");\n+\tif (with_commit)\n+\t\tdie(\"--contains option is only allowed with -l.\");\n \tif (delete)\n \t\treturn for_each_tag_name(argv, delete_tag);\n \tif (verify)\n-- \n1.6.0.6\n"},{"id":"101340","messageId":"20090121032058.GG21473@genesis.frugalware.org","threadId":"17277","inReplyTo":"4448209.246381232501828959.JavaMail.root@scalix.vivisimo.com","subject":"Re: [PATCH] Add --contains flag to git tag","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-01-21T03:20:58Z","receivedAt":"2009-01-21T03:20:58Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Tue, Jan 20, 2009 at 08:37:09PM -0500, Jake Goulding <goulding@vivisimo.com> wrote:\n> Please let me know what else I have inevitably messed up, and I shall\n> endeavor to fix and resubmit. \n\nPlease document your improvements in Documentation/git-tag.txt and don't\nforget to add a testcase to t7004-tag.sh.\n"},{"id":"101343","messageId":"25058429.247441232510076471.JavaMail.root@scalix.vivisimo.com","threadId":"17277","inReplyTo":"20090121032058.GG21473@genesis.frugalware.org","subject":"Re: [PATCH] Add --contains flag to git tag","fromName":"Jake Goulding","fromEmail":"goulding@vivisimo.com","sentAt":"2009-01-21T03:54:36Z","receivedAt":"2009-01-21T03:54:36Z","isPatch":true,"sender":{"key":"goulding@vivisimo.com","avatar":"https://gravatar.com/avatar/d8938ff226c618b80857e27f7e0a2d4335215bfb9733c321b8dd30c660b7f1e9?d=mp&s=160"},"body":"That is actually in a subsequent commit (in my unmarked patch sequence). \n\nI actually have 1 commit for the code change, one for documentation, and one for the test case. Should I squash all these together?\n\nAlso, my test case is in a separate file (t7704-tag-contains.sh) as that is how I read t/README. Was this incorrect?\n\nThanks!\n\n-Jake\n\n----- Original Message -----\nFrom: \"Miklos Vajna\" <vmiklos@frugalware.org>\nTo: \"Jake Goulding\" <goulding@vivisimo.com>\nCc: git@vger.kernel.org\nSent: Tuesday, January 20, 2009 10:20:58 PM GMT -05:00 US/Canada Eastern\nSubject: Re: [PATCH] Add --contains flag to git tag\n\nOn Tue, Jan 20, 2009 at 08:37:09PM -0500, Jake Goulding <goulding@vivisimo.com> wrote:\n> Please let me know what else I have inevitably messed up, and I shall\n> endeavor to fix and resubmit. \n\nPlease document your improvements in Documentation/git-tag.txt and don't\nforget to add a testcase to t7004-tag.sh.\n"},{"id":"101352","messageId":"alpine.DEB.1.00.0901210919030.7929@racer","threadId":"17277","inReplyTo":"25058429.247441232510076471.JavaMail.root@scalix.vivisimo.com","subject":"Re: [PATCH] Add --contains flag to git tag","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-01-21T08:21:30Z","receivedAt":"2009-01-21T08:21:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 20 Jan 2009, Jake Goulding wrote:\n\n> I actually have 1 commit for the code change, one for documentation, and \n> one for the test case. Should I squash all these together?\n\nIn general, if the patches are not very large and logically belong \ntogether, it is a matter of taste if you squash together documentation and \ncode changes.  Tests, however, belong with the code.\n\n> Also, my test case is in a separate file (t7704-tag-contains.sh) as that \n> is how I read t/README. Was this incorrect?\n\nAgain, the size matters.  If it is a single test case, it is not worth a \nwhole new file, especially when something like t7004-tag.sh already \nexists, whose name just asks for your test case to go in there.\n\nCiao,\nDscho\n"},{"id":"101550","messageId":"7viqo76z0l.fsf@gitster.siamese.dyndns.org","threadId":"17277","inReplyTo":"20090121032058.GG21473@genesis.frugalware.org","subject":"Re: [PATCH] Add --contains flag to git tag","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-22T17:17:46Z","receivedAt":"2009-01-22T17:17:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miklos Vajna <vmiklos@frugalware.org> writes:\n\n> On Tue, Jan 20, 2009 at 08:37:09PM -0500, Jake Goulding <goulding@vivisimo.com> wrote:\n>> Please let me know what else I have inevitably messed up, and I shall\n>> endeavor to fix and resubmit. \n>\n> Please document your improvements in Documentation/git-tag.txt and don't\n> forget to add a testcase to t7004-tag.sh.\n\nThanks for saving me time ;-)\n"}]}