* Re: [PATCH] Add --contains flag to git tag [not found] <1232501631-21531-3-git-send-email-goulding@vivisimo.com> @ 2009-01-21 1:37 ` Jake Goulding 2009-01-21 3:20 ` Miklos Vajna 0 siblings, 1 reply; 5+ messages in thread From: Jake Goulding @ 2009-01-21 1:37 UTC (permalink / raw) To: git Ack - I sent that a bit before I meant to (and before I added patch sequence numbers). This is a patch that adds a --contains flag to git tag, providing similar functionality as git branch --contains. Please let me know what else I have inevitably messed up, and I shall endeavor to fix and resubmit. -Jake ----- Original Message ----- From: "Jake Goulding" <goulding@vivisimo.com> To: git@vger.kernel.org Cc: "Jake Goulding" <goulding@vivisimo.com> Sent: Tuesday, January 20, 2009 8:33:49 PM GMT -05:00 US/Canada Eastern Subject: [PATCH] Add --contains flag to git tag This functions similar to how --contains works for git branch - it will show all tags that contain the specified commit. Indeed, it uses the same lookup mechanisms as git branch. Signed-off-by: Jake Goulding <goulding@vivisimo.com> --- builtin-tag.c | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-) diff --git a/builtin-tag.c b/builtin-tag.c index a398499..453ed26 100644 --- a/builtin-tag.c +++ b/builtin-tag.c @@ -26,6 +26,7 @@ static char signingkey[1000]; struct tag_filter { const char *pattern; int lines; + struct commit_list *with_commit; }; #define PGP_SIGNATURE "-----BEGIN PGP SIGNATURE-----" @@ -35,6 +36,15 @@ static int show_reference(const char *refname, const unsigned char *sha1, { struct tag_filter *filter = cb_data; + if (filter->with_commit) { + struct commit *commit; + + commit = lookup_commit_reference_gently(sha1, 1); + if (!commit) + return error("branch '%s' does not point at a commit", refname); + if (!has_commit(commit, filter->with_commit)) + return 0; + } if (!fnmatch(filter->pattern, refname, 0)) { int i; unsigned long size; @@ -79,7 +89,8 @@ static int show_reference(const char *refname, const unsigned char *sha1, return 0; } -static int list_tags(const char *pattern, int lines) +static int list_tags(const char *pattern, int lines, + struct commit_list *with_commit) { struct tag_filter filter; @@ -88,6 +99,7 @@ static int list_tags(const char *pattern, int lines) filter.pattern = pattern; filter.lines = lines; + filter.with_commit = with_commit; for_each_tag_ref(show_reference, (void *) &filter); @@ -360,6 +372,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix) list = 0, delete = 0, verify = 0; const char *msgfile = NULL, *keyid = NULL; struct msg_arg msg = { 0, STRBUF_INIT }; + struct commit_list *with_commit = NULL; struct option options[] = { OPT_BOOLEAN('l', NULL, &list, "list tag names"), { OPTION_INTEGER, 'n', NULL, &lines, NULL, @@ -378,6 +391,14 @@ int cmd_tag(int argc, const char **argv, const char *prefix) OPT_STRING('u', NULL, &keyid, "key-id", "use another key to sign the tag"), OPT_BOOLEAN('f', NULL, &force, "replace the tag if exists"), + + OPT_GROUP("Tag listing options"), + { + OPTION_CALLBACK, 0, "contains", &with_commit, "commit", + "print only tags that contain the commit", + PARSE_OPT_LASTARG_DEFAULT, + parse_opt_with_commit, (intptr_t)"HEAD", + }, OPT_END() }; @@ -402,9 +423,12 @@ int cmd_tag(int argc, const char **argv, const char *prefix) if (list + delete + verify > 1) usage_with_options(git_tag_usage, options); if (list) - return list_tags(argv[0], lines == -1 ? 0 : lines); + return list_tags(argv[0], lines == -1 ? 0 : lines, + with_commit); if (lines != -1) die("-n option is only allowed with -l."); + if (with_commit) + die("--contains option is only allowed with -l."); if (delete) return for_each_tag_name(argv, delete_tag); if (verify) -- 1.6.0.6 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Add --contains flag to git tag 2009-01-21 1:37 ` [PATCH] Add --contains flag to git tag Jake Goulding @ 2009-01-21 3:20 ` Miklos Vajna 2009-01-21 3:54 ` Jake Goulding 2009-01-22 17:17 ` Junio C Hamano 0 siblings, 2 replies; 5+ messages in thread From: Miklos Vajna @ 2009-01-21 3:20 UTC (permalink / raw) To: Jake Goulding; +Cc: git [-- Attachment #1: Type: text/plain, Size: 314 bytes --] On Tue, Jan 20, 2009 at 08:37:09PM -0500, Jake Goulding <goulding@vivisimo.com> wrote: > Please let me know what else I have inevitably messed up, and I shall > endeavor to fix and resubmit. Please document your improvements in Documentation/git-tag.txt and don't forget to add a testcase to t7004-tag.sh. [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add --contains flag to git tag 2009-01-21 3:20 ` Miklos Vajna @ 2009-01-21 3:54 ` Jake Goulding 2009-01-21 8:21 ` Johannes Schindelin 2009-01-22 17:17 ` Junio C Hamano 1 sibling, 1 reply; 5+ messages in thread From: Jake Goulding @ 2009-01-21 3:54 UTC (permalink / raw) To: Miklos Vajna; +Cc: git That is actually in a subsequent commit (in my unmarked patch sequence). I actually have 1 commit for the code change, one for documentation, and one for the test case. Should I squash all these together? Also, my test case is in a separate file (t7704-tag-contains.sh) as that is how I read t/README. Was this incorrect? Thanks! -Jake ----- Original Message ----- From: "Miklos Vajna" <vmiklos@frugalware.org> To: "Jake Goulding" <goulding@vivisimo.com> Cc: git@vger.kernel.org Sent: Tuesday, January 20, 2009 10:20:58 PM GMT -05:00 US/Canada Eastern Subject: Re: [PATCH] Add --contains flag to git tag On Tue, Jan 20, 2009 at 08:37:09PM -0500, Jake Goulding <goulding@vivisimo.com> wrote: > Please let me know what else I have inevitably messed up, and I shall > endeavor to fix and resubmit. Please document your improvements in Documentation/git-tag.txt and don't forget to add a testcase to t7004-tag.sh. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add --contains flag to git tag 2009-01-21 3:54 ` Jake Goulding @ 2009-01-21 8:21 ` Johannes Schindelin 0 siblings, 0 replies; 5+ messages in thread From: Johannes Schindelin @ 2009-01-21 8:21 UTC (permalink / raw) To: Jake Goulding; +Cc: Miklos Vajna, git Hi, On Tue, 20 Jan 2009, Jake Goulding wrote: > I actually have 1 commit for the code change, one for documentation, and > one for the test case. Should I squash all these together? In general, if the patches are not very large and logically belong together, it is a matter of taste if you squash together documentation and code changes. Tests, however, belong with the code. > Also, my test case is in a separate file (t7704-tag-contains.sh) as that > is how I read t/README. Was this incorrect? Again, the size matters. If it is a single test case, it is not worth a whole new file, especially when something like t7004-tag.sh already exists, whose name just asks for your test case to go in there. Ciao, Dscho ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add --contains flag to git tag 2009-01-21 3:20 ` Miklos Vajna 2009-01-21 3:54 ` Jake Goulding @ 2009-01-22 17:17 ` Junio C Hamano 1 sibling, 0 replies; 5+ messages in thread From: Junio C Hamano @ 2009-01-22 17:17 UTC (permalink / raw) To: Miklos Vajna; +Cc: Jake Goulding, git Miklos Vajna <vmiklos@frugalware.org> writes: > On Tue, Jan 20, 2009 at 08:37:09PM -0500, Jake Goulding <goulding@vivisimo.com> wrote: >> Please let me know what else I have inevitably messed up, and I shall >> endeavor to fix and resubmit. > > Please document your improvements in Documentation/git-tag.txt and don't > forget to add a testcase to t7004-tag.sh. Thanks for saving me time ;-) ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-01-22 17:19 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <1232501631-21531-3-git-send-email-goulding@vivisimo.com> 2009-01-21 1:37 ` [PATCH] Add --contains flag to git tag Jake Goulding 2009-01-21 3:20 ` Miklos Vajna 2009-01-21 3:54 ` Jake Goulding 2009-01-21 8:21 ` Johannes Schindelin 2009-01-22 17:17 ` Junio C Hamano
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).