Skip to content

Commit 3fc44a1

Browse files
committed
Merge branch 'jk/maint-1.7.2-status-ignored' into maint
* jk/maint-1.7.2-status-ignored: git status --ignored: tests and docs status: fix bug with missing --ignore files Conflicts: Documentation/git-status.txt t/t7508-status.sh
2 parents 30962fb + 150b493 commit 3fc44a1

File tree

3 files changed

+128
-2
lines changed

3 files changed

+128
-2
lines changed

Documentation/git-status.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ configuration variable documented in linkgit:git-config[1].
7070
(and suppresses the output of submodule summaries when the config option
7171
`status.submodulesummary` is set).
7272

73+
--ignored::
74+
Show ignored files as well.
75+
7376
-z::
7477
Terminate entries with NUL, instead of LF. This implies
7578
the `--porcelain` output format if no other format is given.
@@ -120,7 +123,8 @@ codes can be interpreted as follows:
120123
* 'C' = copied
121124
* 'U' = updated but unmerged
122125

123-
Ignored files are not listed.
126+
Ignored files are not listed, unless `--ignored` option is in effect,
127+
in which case `XY` are `!!`.
124128

125129
X Y Meaning
126130
-------------------------------------------------
@@ -143,6 +147,7 @@ Ignored files are not listed.
143147
U U unmerged, both modified
144148
-------------------------------------------------
145149
? ? untracked
150+
! ! ignored
146151
-------------------------------------------------
147152

148153
If -b is used the short-format status is preceded by a line

t/t7508-status.sh

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,127 @@ test_expect_success 'status -s' '
131131
132132
'
133133

134+
test_expect_success 'status with gitignore' '
135+
{
136+
echo ".gitignore" &&
137+
echo "expect" &&
138+
echo "output" &&
139+
echo "untracked"
140+
} >.gitignore &&
141+
142+
cat >expect <<-\EOF &&
143+
M dir1/modified
144+
A dir2/added
145+
?? dir2/modified
146+
EOF
147+
git status -s >output &&
148+
test_cmp expect output &&
149+
150+
cat >expect <<-\EOF &&
151+
M dir1/modified
152+
A dir2/added
153+
?? dir2/modified
154+
!! .gitignore
155+
!! dir1/untracked
156+
!! dir2/untracked
157+
!! expect
158+
!! output
159+
!! untracked
160+
EOF
161+
git status -s --ignored >output &&
162+
test_cmp expect output &&
163+
164+
cat >expect <<-\EOF &&
165+
# On branch master
166+
# Changes to be committed:
167+
# (use "git reset HEAD <file>..." to unstage)
168+
#
169+
# new file: dir2/added
170+
#
171+
# Changes not staged for commit:
172+
# (use "git add <file>..." to update what will be committed)
173+
# (use "git checkout -- <file>..." to discard changes in working directory)
174+
#
175+
# modified: dir1/modified
176+
#
177+
# Untracked files:
178+
# (use "git add <file>..." to include in what will be committed)
179+
#
180+
# dir2/modified
181+
# Ignored files:
182+
# (use "git add -f <file>..." to include in what will be committed)
183+
#
184+
# .gitignore
185+
# dir1/untracked
186+
# dir2/untracked
187+
# expect
188+
# output
189+
# untracked
190+
EOF
191+
git status --ignored >output &&
192+
test_cmp expect output
193+
'
194+
195+
test_expect_success 'status with gitignore (nothing untracked)' '
196+
{
197+
echo ".gitignore" &&
198+
echo "expect" &&
199+
echo "dir2/modified" &&
200+
echo "output" &&
201+
echo "untracked"
202+
} >.gitignore &&
203+
204+
cat >expect <<-\EOF &&
205+
M dir1/modified
206+
A dir2/added
207+
EOF
208+
git status -s >output &&
209+
test_cmp expect output &&
210+
211+
cat >expect <<-\EOF &&
212+
M dir1/modified
213+
A dir2/added
214+
!! .gitignore
215+
!! dir1/untracked
216+
!! dir2/modified
217+
!! dir2/untracked
218+
!! expect
219+
!! output
220+
!! untracked
221+
EOF
222+
git status -s --ignored >output &&
223+
test_cmp expect output &&
224+
225+
cat >expect <<-\EOF &&
226+
# On branch master
227+
# Changes to be committed:
228+
# (use "git reset HEAD <file>..." to unstage)
229+
#
230+
# new file: dir2/added
231+
#
232+
# Changes not staged for commit:
233+
# (use "git add <file>..." to update what will be committed)
234+
# (use "git checkout -- <file>..." to discard changes in working directory)
235+
#
236+
# modified: dir1/modified
237+
#
238+
# Ignored files:
239+
# (use "git add -f <file>..." to include in what will be committed)
240+
#
241+
# .gitignore
242+
# dir1/untracked
243+
# dir2/modified
244+
# dir2/untracked
245+
# expect
246+
# output
247+
# untracked
248+
EOF
249+
git status --ignored >output &&
250+
test_cmp expect output
251+
'
252+
253+
rm -f .gitignore
254+
134255
cat >expect <<\EOF
135256
## master
136257
M dir1/modified

wt-status.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ static void wt_status_print_other(struct wt_status *s,
642642
int i;
643643
struct strbuf buf = STRBUF_INIT;
644644

645-
if (!s->untracked.nr)
645+
if (!l->nr)
646646
return;
647647

648648
wt_status_print_other_header(s, what, how);

0 commit comments

Comments
 (0)