Skip to content

Commit

Permalink
dir: recurse into untracked dirs for ignored files
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Samuel Lijin authored and gitster committed May 22, 2017
1 parent 0a81d4a commit df5bcdf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,10 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
dir_state = state;

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

0 comments on commit df5bcdf

Please sign in to comment.