git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Namhyung Kim <namhyung.kim@lge.com>
Date
Jun 17, 2013, 07:53 UTC
Message-ID
<1371455636-1378-1-git-send-email-namhyung.kim@lge.com>

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
Next: Junio C Hamano
Message 1 of 5 in “name-rev: Allow to omit refs/tags/ part in --refs option when --tags used”
  1. name-rev: Allow to omit refs/tags/ part in --refs option when --tags usedNamhyung Kim, Jun 17, 2013
  2. Junio C HamanoJun 17, 2013
  3. Junio C HamanoJun 17, 2013
  4. Namhyung KimJun 18, 2013
  5. Namhyung KimJun 18, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.