From 114ef90854c395145594974c222a004060b2acd1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Steinbrink?= Date: Thu, 28 Aug 2008 04:14:02 +0200 Subject: [PATCH] for-each-ref: Allow a trailing slash in the patterns MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- builtin-for-each-ref.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c index 4d25ec51d..21e92bbcb 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; -- 2.11.0