]> git.ipfire.org Git - thirdparty/git.git/blobdiff - dir.c
name-hash: don't reuse cache_entry in dir_entry
[thirdparty/git.git] / dir.c
diff --git a/dir.c b/dir.c
index bd274a73f1faaee40bce34024ef17bfd44fbcad7..8545922ee2ddb5a218e173d938975c47bf76b335 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -826,9 +826,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
        current = stk ? stk->baselen : -1;
        strbuf_setlen(&dir->basebuf, current < 0 ? 0 : current);
        while (current < baselen) {
-               struct exclude_stack *stk = xcalloc(1, sizeof(*stk));
                const char *cp;
 
+               stk = xcalloc(1, sizeof(*stk));
                if (current < 0) {
                        cp = base;
                        current = 0;
@@ -964,29 +964,15 @@ enum exist_status {
  */
 static enum exist_status directory_exists_in_index_icase(const char *dirname, int len)
 {
-       const struct cache_entry *ce = cache_dir_exists(dirname, len);
-       unsigned char endchar;
+       struct cache_entry *ce;
 
-       if (!ce)
-               return index_nonexistent;
-       endchar = ce->name[len];
-
-       /*
-        * The cache_entry structure returned will contain this dirname
-        * and possibly additional path components.
-        */
-       if (endchar == '/')
+       if (cache_dir_exists(dirname, len))
                return index_directory;
 
-       /*
-        * If there are no additional path components, then this cache_entry
-        * represents a submodule.  Submodules, despite being directories,
-        * are stored in the cache without a closing slash.
-        */
-       if (!endchar && S_ISGITLINK(ce->ce_mode))
+       ce = cache_file_exists(dirname, len, ignore_case);
+       if (ce && S_ISGITLINK(ce->ce_mode))
                return index_gitdir;
 
-       /* This should never be hit, but it exists just in case. */
        return index_nonexistent;
 }