dir.c: git-status --ignored: don't list empty ignored directories
'git-status --ignored' lists ignored tracked directories without any ignored files if a tracked file happens to match an exclude pattern. Always exclude tracked files. 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:07 UTC
0104c9e7816e30701e4fdd9143889faacfa0eefa
2 files changed
+28
-7
dir.c
+4
-7
@@ -1153,16 +1153,13 @@ static int treat_file(struct dir_struct *dir, struct strbuf *path, int exclude,
1153
struct path_exclude_check check;
1154
int exclude_file = 0;
1155
1156
+ /* Always exclude indexed files */
1157
+ if (index_name_exists(&the_index, path->buf, path->len, ignore_case))
1158
+ return 1;
1159
+
1160
if (exclude)
1161
exclude_file = !(dir->flags & DIR_SHOW_IGNORED);
1162
else if (dir->flags & DIR_SHOW_IGNORED) {
1159
- /* Always exclude indexed files */
1160
- struct cache_entry *ce = index_name_exists(&the_index,
1161
- path->buf, path->len, ignore_case);
1162
-
1163
- if (ce)
1164
- return 1;
1165
-
1163
path_exclude_check_init(&check, dir);
1164
1165
if (!is_path_excluded(&check, path->buf, path->len, dtype))
t/t7061-wtstatus-ignore.sh
+24
@@ -118,6 +118,29 @@ test_expect_success 'status ignored tracked directory with --ignore -u' '
118
test_cmp expected actual
119
'
120
121
+cat >expected <<\EOF
122
+?? .gitignore
123
+?? actual
124
+?? expected
125
+EOF
126
+
127
+test_expect_success 'status ignored tracked directory and ignored file with --ignore' '
128
+ echo "committed" >>.gitignore &&
129
+ git status --porcelain --ignored >actual &&
130
+ test_cmp expected actual
131
+'
132
+
133
+cat >expected <<\EOF
134
+?? .gitignore
135
+?? actual
136
+?? expected
137
+EOF
138
+
139
+test_expect_success 'status ignored tracked directory and ignored file with --ignore -u' '
140
+ git status --porcelain --ignored -u >actual &&
141
+ test_cmp expected actual
142
+'
143
+
144
cat >expected <<\EOF
145
?? .gitignore
146
?? actual
@@ -126,6 +149,7 @@ cat >expected <<\EOF
149
EOF
150
151
test_expect_success 'status ignored tracked directory and uncommitted file with --ignore' '
152
+ echo "tracked" >.gitignore &&
153
: >tracked/uncommitted &&
154
git status --porcelain --ignored >actual &&
155
test_cmp expected actual