Re: [PATCH 2/6] dir.c::match_basename(): pay attention to the length of string parameters
- From
Jeff King <peff@peff.net>
- Date
- Mar 28, 2013, 22:40 UTC
- Message-ID
- <20130328224027.GA9911@sigill.intra.peff.net>
- In-Reply-To
- <20130328214728.GB10936@sigill.intra.peff.net>
On Thu, Mar 28, 2013 at 05:47:28PM -0400, Jeff King wrote:
Show 14 quoted lines
> From: Junio C Hamano <gitster@pobox.com> > > The function takes two counted strings (<basename, basenamelen> and > <pattern, patternlen>) as parameters, together with prefix (the > length of the prefix in pattern that is to be matched literally > without globbing against the basename) and EXC_* flags that tells it > how to match the pattern against the basename. > > However, it did not pay attention to the length of these counted > strings. Update them to do the following: > > * When the entire pattern is to be matched literally, the pattern > matches the basename only when the lengths of them are the same, > and they match up to that length.
Hrm. Though the tip of this series passes all tests, this one actually breaks bisectability. What happens is that the existing code passes:
path=foo/ pathlen=4
pattern=foo/ patternlen=3
match_basename is happy to compare "foo/" to "foo/" and realize they're equal. With this change, we compare "foo" to "foo/" and do not match. It isn't until the later patch where you start passing pathlen=3 that it works again.
I wonder if it is worth reordering the series to put the path_matches fix first.
-Peff