Skip to content

Commit 114ef90

Browse files
dotdashgitster
authored andcommitted
for-each-ref: Allow a trailing slash in the patterns
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c67b1fa commit 114ef90

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin-for-each-ref.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,8 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f
652652
if ((plen <= namelen) &&
653653
!strncmp(refname, p, plen) &&
654654
(refname[plen] == '\0' ||
655-
refname[plen] == '/'))
655+
refname[plen] == '/' ||
656+
p[plen-1] == '/'))
656657
break;
657658
if (!fnmatch(p, refname, FNM_PATHNAME))
658659
break;

0 commit comments

Comments
 (0)