OSDN Git Service

dir.c::match_pathname(): adjust patternlen when shifting pattern
authorJeff King <peff@peff.net>
Thu, 28 Mar 2013 21:47:47 +0000 (17:47 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Mar 2013 04:48:18 +0000 (21:48 -0700)
If we receive a pattern that starts with "/", we shift it
forward to avoid looking at the "/" part. Since the prefix
and patternlen parameters are counts of what is in the
pattern, we must decrement them as we increment the pointer.

We remembered to handle prefix, but not patternlen. This
didn't cause any bugs, though, because the patternlen
parameter is not actually used. Since it will be used in
future patches, let's correct this oversight.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c

diff --git a/dir.c b/dir.c
index 0db79f9..1757a3f 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -597,6 +597,7 @@ int match_pathname(const char *pathname, int pathlen,
         */
        if (*pattern == '/') {
                pattern++;
+               patternlen--;
                prefix--;
        }