Skip to content

Commit 560bb7a

Browse files
kbleesgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 85e7e81 commit 560bb7a

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

dir.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,15 @@ static enum directory_treatment treat_directory(struct dir_struct *dir,
11041104

11051105
/* This is the "show_other_directories" case */
11061106

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+
11071116
/*
11081117
* We are looking for ignored files and our directory is not ignored,
11091118
* check if it contains only ignored files

t/t7061-wtstatus-ignore.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,31 @@ test_expect_success 'status ignored tracked directory and uncommitted file with
143143
test_cmp expected actual
144144
'
145145

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+
146173
test_done

0 commit comments

Comments
 (0)