Re: [PATCH] Speedup scanning for excluded files.
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 30, 2007, 00:00 UTC
- Message-ID
- <7vzly1sc7p.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <118833cc0710291559kbd874a8o8111b9495090ef27@mail.gmail.com>
"Morten Welinder" <mwelinder@gmail.com> writes:
Show 5 quoted lines
>> + } else if (x->flags & EXC_FLAG_ENDSWITH) {
>> + if (!strcmp(exclude + 1, pathname + pathlen -x->patternlen + 1))
>
> Is there some guarantee that the result of that subtraction is still within
> the string?Good eyes.
If pattern is "*.exe", patternlen is 5, and strcmp wants to compare 4 chars, so pathlen is better be at least that long, and we do allow that pattern to match a hidden file ".exe".
Like this?
if (x->patternlen - 1 <= pathlen &&
!strcmp(exclude + 1, pathname + pathlen - x->patternlen + 1))
return to_exclude;