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 <gitster@pobox.com>
Kjetil Barvik committed
Jun 14, 2009 at 15:08 UTC
77716755cbdf970fa0814a5f77c884b1f17693de
2 files changed
+5
-1
symlinks.c
+4
@@ -91,6 +91,10 @@ static int lstat_cache(struct cache_def *cache, const char *name, int len,
91
longest_path_match(name, len, cache->path, cache->len,
92
&previous_slash);
93
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
+
98
if (match_flags && match_len == cache->len)
99
return match_flags;
100
/*
t/t6035-merge-dir-to-symlink.sh
+1
-1
@@ -26,7 +26,7 @@ test_expect_failure 'keep a/b-2/c/d across checkout' '
26
test -f a/b-2/c/d
27
'
28
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' '
30
git checkout HEAD^0 &&
31
git reset --hard master &&
32
git checkout start^0 &&