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 <B.Steinbrink@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Björn Steinbrink 2008-08-28 04:14:02 +02:00 коммит произвёл Junio C Hamano
Родитель c67b1fa349
Коммит 114ef90854
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -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;