Skip to content

Commit a45fb69

Browse files
apelissegitster
authored andcommitted
status: always report ignored tracked directories
When enumerating paths that are ignored, paths the index knows about are not included in the result. The "index knows about" check is done by consulting the name hash, not the actual contents of the index: - When core.ignorecase is false, directory names are not in the name hash, and ignored ones are shown as ignored (directories can never be tracked anyway). - When core.ignorecase is true, however, the name hash keeps track of the names of directories, in order to detect additions of the paths under different cases. This causes ignored directories to be mistakenly excluded when enumerating ignored paths. Stop excluding directories that are in the name hash when looking for ignored files in dir_add_name(); the names that are actually in the index are excluded much earlier in the callchain in treat_file(), so this fix will not make them mistakenly identified as ignored. Signed-off-by: Antoine Pelisse <[email protected]> Reviewed-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eb8c5b8 commit a45fb69

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

dir.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ static struct dir_entry *dir_entry_new(const char *pathname, int len)
672672

673673
static struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len)
674674
{
675-
if (cache_name_exists(pathname, len, ignore_case))
675+
if (!(dir->flags & DIR_SHOW_IGNORED) &&
676+
cache_name_exists(pathname, len, ignore_case))
676677
return NULL;
677678

678679
ALLOC_GROW(dir->entries, dir->nr+1, dir->alloc);
@@ -877,11 +878,7 @@ static int treat_file(struct dir_struct *dir, struct strbuf *path, int exclude,
877878
if (exclude)
878879
exclude_file = !(dir->flags & DIR_SHOW_IGNORED);
879880
else if (dir->flags & DIR_SHOW_IGNORED) {
880-
/*
881-
* Optimization:
882-
* Don't spend time on indexed files, they won't be
883-
* added to the list anyway
884-
*/
881+
/* Always exclude indexed files */
885882
struct cache_entry *ce = index_name_exists(&the_index,
886883
path->buf, path->len, ignore_case);
887884

0 commit comments

Comments
 (0)