Skip to content

Commit 289ff55

Browse files
kbleesgitster
authored andcommitted
dir.c: git-status --ignored: don't list files in ignored directories
'git-status --ignored' lists both the ignored directory and the ignored files if the files are in a tracked sub directory. When recursing into sub directories in read_directory_recursive, pass on the check_only parameter so that we don't accidentally add the files. Signed-off-by: Karsten Blees <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 560bb7a commit 289ff55

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

dir.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,6 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
13171317
return path_ignored;
13181318
case DT_DIR:
13191319
strbuf_addch(path, '/');
1320-
13211320
switch (treat_directory(dir, path->buf, path->len, exclude, simplify)) {
13221321
case show_directory:
13231322
break;
@@ -1387,8 +1386,7 @@ static int read_directory_recursive(struct dir_struct *dir,
13871386
switch (treat_path(dir, de, &path, baselen, simplify)) {
13881387
case path_recurse:
13891388
contents += read_directory_recursive(dir, path.buf,
1390-
path.len, 0,
1391-
simplify);
1389+
path.len, check_only, simplify);
13921390
continue;
13931391
case path_ignored:
13941392
continue;

t/t7061-wtstatus-ignore.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,31 @@ test_expect_success 'status ignored tracked directory with uncommitted file in u
170170
test_cmp expected actual
171171
'
172172

173+
cat >expected <<\EOF
174+
?? .gitignore
175+
?? actual
176+
?? expected
177+
!! tracked/
178+
EOF
179+
180+
test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore' '
181+
: >tracked/ignored/committed &&
182+
git add -f tracked/ignored/committed &&
183+
git commit -m. &&
184+
git status --porcelain --ignored >actual &&
185+
test_cmp expected actual
186+
'
187+
188+
cat >expected <<\EOF
189+
?? .gitignore
190+
?? actual
191+
?? expected
192+
!! tracked/ignored/uncommitted
193+
EOF
194+
195+
test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore -u' '
196+
git status --porcelain --ignored -u >actual &&
197+
test_cmp expected actual
198+
'
199+
173200
test_done

0 commit comments

Comments
 (0)