DORMANTno replies

[PATCH] name-rev: Allow to omit refs/tags/ part in --refs option when --tags used

From: Namhyung Kim <hidden>
Date: 2016-06-15 22:57:46
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help