Re: [PATCH 3/4] attr.c::path_matches(): special case paths that end with a slash
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Mar 27, 2013, 01:30 UTC
- Message-ID
- <CACsJy8A8QNaKUoMUYri6uUs56suerUZ5n48Q3VDD-=OcruBqww@mail.gmail.com>
- In-Reply-To
- <20130326213319.GA3058@sigill.intra.peff.net>
On Wed, Mar 27, 2013 at 4:33 AM, Jeff King <peff@peff.net> wrote:
Show 15 quoted lines
> Hmm. match_pathname does have this: > > /* > * baselen does not count the trailing slash. base[] may or > * may not end with a trailing slash though. > */ > if (pathlen < baselen + 1 || > (baselen && pathname[baselen] != '/') || > strncmp_icase(pathname, base, baselen)) > return 0; > > which seems to imply that the trailing slash is important here, and that > we should not drop it when passing the path to match_pathname. I'm > still trying to figure out exactly what it is that the extra slash check > is for, and whether it might not have the same problem.
The "may not end with a trailing slash" can only happen when baselen == 0. And that rule is documented in code, at this line in last_exclude_matching_from_list:
assert(x->baselen == 0 || x->base[x->baselen - 1] == '/');
-- Duy