{"thread":{"id":"15237","subject":"[PATCH] for-each-ref: Allow a trailing slash in the patterns","startedAt":"2008-08-28T02:14:02Z","lastAt":"2008-08-28T02:14:02Z","messageCount":1,"participants":["Björn Steinbrink"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"88847","messageId":"20080828021402.GA18049@atjola.homenet","threadId":"15237","inReplyTo":null,"subject":"[PATCH] for-each-ref: Allow a trailing slash in the patterns","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-08-28T02:14:02Z","receivedAt":"2008-08-28T02:14:02Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"More often than not, I end up using something like refs/remotes/ as the\npattern for for-each-ref, but that doesn't work, because it expects to see\nthe slash in the ref name right after the matched pattern. So teach it to\naccept the slash as the final character in the pattern as well.\n\nSigned-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>\n---\n builtin-for-each-ref.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c\nindex 4d25ec5..21e92bb 100644\n--- a/builtin-for-each-ref.c\n+++ b/builtin-for-each-ref.c\n@@ -652,7 +652,8 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f\n \t\t\tif ((plen <= namelen) &&\n \t\t\t    !strncmp(refname, p, plen) &&\n \t\t\t    (refname[plen] == '\\0' ||\n-\t\t\t     refname[plen] == '/'))\n+\t\t\t     refname[plen] == '/' ||\n+\t\t\t     p[plen-1] == '/'))\n \t\t\t\tbreak;\n \t\t\tif (!fnmatch(p, refname, FNM_PATHNAME))\n \t\t\t\tbreak;\n-- \n1.6.0.1.90.g27a6e.dirty\n"}]}