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

[PATCH] for-each-ref: Allow a trailing slash in the patterns

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Aug 28, 2008, 02:14 UTC
Message-ID
<20080828021402.GA18049@atjola.homenet>

More often than not, I end up using something like refs/remotes/ as the pattern for for-each-ref, but that doesn't work, because it expects to see the slash in the ref name right after the matched pattern. So teach it to accept the slash as the final character in the pattern as well.

Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
---
 builtin-for-each-ref.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 4d25ec5..21e92bb 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -652,7 +652,8 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f
 			if ((plen <= namelen) &&
 			    !strncmp(refname, p, plen) &&
 			    (refname[plen] == '\0' ||
-			     refname[plen] == '/'))
+			     refname[plen] == '/' ||
+			     p[plen-1] == '/'))
 				break;
 			if (!fnmatch(p, refname, FNM_PATHNAME))
 				break;
-- 
1.6.0.1.90.g27a6e.dirty
Message 1 of 1 in “for-each-ref: Allow a trailing slash in the patterns”
  1. for-each-ref: Allow a trailing slash in the patternsBjörn Steinbrink, Aug 28, 2008

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.