dir.c: git-status --ignored: don't drop ignored directories

'git-status --ignored' drops ignored directories if they contain untracked files in an untracked sub directory. Fix it by getting exact (recursive) excluded status in treat_directory. Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Karsten Blees committed Apr 15, 2013 at 21:05 UTC 560bb7a7a146fddad3394dc913f1469d477d26a9
2 files changed +36
dir.c
+9
@@ -1104,6 +1104,15 @@ static enum directory_treatment treat_directory(struct dir_struct *dir,
1104
1105 /* This is the "show_other_directories" case */
1106
1107 + /* might be a sub directory in an excluded directory */
1108 + if (!exclude) {
1109 + struct path_exclude_check check;
1110 + int dt = DT_DIR;
1111 + path_exclude_check_init(&check, dir);
1112 + exclude = is_path_excluded(&check, dirname, len, &dt);
1113 + path_exclude_check_clear(&check);
1114 + }
1115 +
1116 /*
1117 * We are looking for ignored files and our directory is not ignored,
1118 * check if it contains only ignored files
t/t7061-wtstatus-ignore.sh
+27
@@ -143,4 +143,31 @@ test_expect_success 'status ignored tracked directory and uncommitted file with
143 test_cmp expected actual
144 '
145
146 +cat >expected <<\EOF
147 +?? .gitignore
148 +?? actual
149 +?? expected
150 +!! tracked/
151 +EOF
152 +
153 +test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore' '
154 + rm -rf tracked/uncommitted &&
155 + mkdir tracked/ignored &&
156 + : >tracked/ignored/uncommitted &&
157 + git status --porcelain --ignored >actual &&
158 + test_cmp expected actual
159 +'
160 +
161 +cat >expected <<\EOF
162 +?? .gitignore
163 +?? actual
164 +?? expected
165 +!! tracked/ignored/uncommitted
166 +EOF
167 +
168 +test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore -u' '
169 + git status --porcelain --ignored -u >actual &&
170 + test_cmp expected actual
171 +'
172 +
173 test_done