Skip to content

Commit

Permalink
for-each-ref: Allow a trailing slash in the patterns
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Björn Steinbrink authored and Junio C Hamano committed Aug 29, 2008
1 parent c67b1fa commit 114ef90
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion builtin-for-each-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 114ef90

Please sign in to comment.