Skip to content

Commit df5bcdf

Browse files
Samuel Lijingitster
authored andcommitted
dir: recurse into untracked dirs for ignored files
We consider directories containing only untracked and ignored files to be themselves untracked, which in the usual case means we don't have to search these directories. This is problematic when we want to collect ignored files with DIR_SHOW_IGNORED_TOO, though, so we teach read_directory_recursive() to recurse into untracked directories to find the ignored files they contain when DIR_SHOW_IGNORED_TOO is set. This has the side effect of also collecting all untracked files in untracked directories as well. Signed-off-by: Samuel Lijin <sxlijin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 0a81d4a commit df5bcdf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

dir.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,10 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
17471747
dir_state = state;
17481748

17491749
/* recurse into subdir if instructed by treat_path */
1750-
if (state == path_recurse) {
1750+
if ((state == path_recurse) ||
1751+
((state == path_untracked) &&
1752+
(dir->flags & DIR_SHOW_IGNORED_TOO) &&
1753+
(get_dtype(cdir.de, path.buf, path.len) == DT_DIR))) {
17511754
struct untracked_cache_dir *ud;
17521755
ud = lookup_untracked(dir->untracked, untracked,
17531756
path.buf + baselen,

0 commit comments

Comments
 (0)