Skip to content

Commit 7771675

Browse files
Kjetil Barvikgitster
authored andcommitted
lstat_cache: guard against full match of length of 'name' parameter
longest_path_match() in symlinks.c does exactly what it's name says, but in some cases that match can be too long, since the has_*_leading_path() functions assumes that the match will newer be as long as the name string given to the function. fix this by adding an extra if test which checks if the match length is equal to the 'len' parameter. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4f6339b commit 7771675

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

symlinks.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ static int lstat_cache(struct cache_def *cache, const char *name, int len,
9191
longest_path_match(name, len, cache->path, cache->len,
9292
&previous_slash);
9393
match_flags = cache->flags & track_flags & (FL_NOENT|FL_SYMLINK);
94+
95+
if (!(track_flags & FL_FULLPATH) && match_len == len)
96+
match_len = last_slash = previous_slash;
97+
9498
if (match_flags && match_len == cache->len)
9599
return match_flags;
96100
/*

t/t6035-merge-dir-to-symlink.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test_expect_failure 'keep a/b-2/c/d across checkout' '
2626
test -f a/b-2/c/d
2727
'
2828

29-
test_expect_failure 'checkout should not have deleted a/b-2/c/d' '
29+
test_expect_success 'checkout should not have deleted a/b-2/c/d' '
3030
git checkout HEAD^0 &&
3131
git reset --hard master &&
3232
git checkout start^0 &&

0 commit comments

Comments
 (0)