Skip to content

Commit 982ac87

Browse files
peffgitster
authored andcommitted
dir.c::match_pathname(): adjust patternlen when shifting pattern
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0b6e56d commit 982ac87

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

dir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ int match_pathname(const char *pathname, int pathlen,
597597
*/
598598
if (*pattern == '/') {
599599
pattern++;
600+
patternlen--;
600601
prefix--;
601602
}
602603

0 commit comments

Comments
 (0)