git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] name-rev: Allow to omit refs/tags/ part in --refs option when --tags used
@ 2013-06-17  7:53 Namhyung Kim
  2013-06-17 15:27 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Namhyung Kim @ 2013-06-17  7:53 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

In its current form, when an user wants to filter specific ref using
--refs option, she needs to give something like --refs=refs/tags/v1.*.

This is not intuitive as users might think it's enough to give just
actual tag name part like --refs=v1.*.  It applies to refs other than
just tags too.  Change it for users to be able to use --refs=sth or
--refs=remotes/sth.

Also remove the leading 'tags/' part in the output when --tags option
was given since the option restricts to work with tags only.  This is
what we have if --name-only option was given also.

Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
---
 builtin/name-rev.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 6238247..446743b 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -97,7 +97,8 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void
 	if (data->tags_only && prefixcmp(path, "refs/tags/"))
 		return 0;
 
-	if (data->ref_filter && fnmatch(data->ref_filter, path, 0))
+	if (data->ref_filter && !prefixcmp(data->ref_filter, "refs/")
+	    && fnmatch(data->ref_filter, path, 0))
 		return 0;
 
 	while (o && o->type == OBJ_TAG) {
@@ -113,12 +114,15 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void
 		if (!prefixcmp(path, "refs/heads/"))
 			path = path + 11;
 		else if (data->tags_only
-		    && data->name_only
 		    && !prefixcmp(path, "refs/tags/"))
 			path = path + 10;
 		else if (!prefixcmp(path, "refs/"))
 			path = path + 5;
 
+		if (data->ref_filter && prefixcmp(data->ref_filter, "refs/")
+		    && fnmatch(data->ref_filter, path, 0))
+			return 0;
+
 		name_rev(commit, xstrdup(path), 0, 0, deref);
 	}
 	return 0;
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-06-18 12:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-17  7:53 [PATCH] name-rev: Allow to omit refs/tags/ part in --refs option when --tags used Namhyung Kim
2013-06-17 15:27 ` Junio C Hamano
2013-06-17 15:53   ` Junio C Hamano
2013-06-18 12:24     ` Namhyung Kim
2013-06-18 11:55   ` Namhyung Kim

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).