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>
Samuel Lijin committed
May 18, 2017 at 04:21 UTC
df5bcdf83aeb94718602ebc8c0f597166bb493f1
1 file changed
+4
-1
dir.c
+4
-1
@@ -1747,7 +1747,10 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
1747
dir_state = state;
1748
1749
/* 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))) {
1754
struct untracked_cache_dir *ud;
1755
ud = lookup_untracked(dir->untracked, untracked,
1756
path.buf + baselen,