From: Linus Torvalds Date: Thu, 9 Jul 2009 20:37:02 +0000 (-0700) Subject: Make index preloading check the whole path to the file X-Git-Tag: v1.6.4-rc1~16^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f62ce3de9dd4803f50f65e17f5fc03c7bdb49c40;p=git.git Make index preloading check the whole path to the file This uses the new thread-safe 'threaded_has_symlink_leading_path()' function to efficiently verify that the whole path leading up to the filename is a proper path, and does not contain symlinks. This makes 'ce_uptodate()' a much stronger guarantee: it no longer just guarantees that the 'lstat()' of the path would match, it also means that we know that people haven't played games with moving directories around and covered it up with symlinks. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- diff --git a/preload-index.c b/preload-index.c index 88edc5f8a..14d528118 100644 --- a/preload-index.c +++ b/preload-index.c @@ -34,7 +34,9 @@ static void *preload_thread(void *_data) struct thread_data *p = _data; struct index_state *index = p->index; struct cache_entry **cep = index->cache + p->offset; + struct cache_def cache; + memset(&cache, 0, sizeof(cache)); nr = p->nr; if (nr + p->offset > index->cache_nr) nr = index->cache_nr - p->offset; @@ -49,6 +51,8 @@ static void *preload_thread(void *_data) continue; if (!ce_path_match(ce, p->pathspec)) continue; + if (threaded_has_symlink_leading_path(&cache, ce->name, ce_namelen(ce))) + continue; if (lstat(ce->name, &st)) continue; if (ie_match_stat(index, ce, &st, CE_MATCH_RACY_IS_DIRTY))