read-cache: check for leading symlinks when refreshing index
[gitweb.git] / read-cache.c
index 4b4effd64b842173d6a06656935436515c755242..5c234cbd70d088b94fd6c19eb6a96d7b852b963d 100644 (file)
@@ -1044,6 +1044,14 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
                return ce;
        }
 
+       if (has_symlink_leading_path(ce->name, ce_namelen(ce))) {
+               if (ignore_missing)
+                       return ce;
+               if (err)
+                       *err = ENOENT;
+               return NULL;
+       }
+
        if (lstat(ce->name, &st) < 0) {
                if (ignore_missing && errno == ENOENT)
                        return ce;