Skip to content

Commit 150b493

Browse files
committed
git status --ignored: tests and docs
Helped-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1282988 commit 150b493

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed

Documentation/git-status.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ See linkgit:git-config[1] for configuration variable
4949
used to change the default for when the option is not
5050
specified.
5151

52+
--ignored::
53+
Show ignored files as well.
54+
5255
-z::
5356
Terminate entries with NUL, instead of LF. This implies
5457
the `--porcelain` output format if no other format is given.
@@ -80,6 +83,8 @@ shows the status of stage #3 (i.e. theirs).
8083
For entries that do not have conflicts, `X` shows the status of the index,
8184
and `Y` shows the status of the work tree. For untracked paths, `XY` are
8285
`??`.
86+
For ignored paths, `XY` are `!!`; they are shown only when the `--ignored`
87+
option is in effect.
8388

8489
X Y Meaning
8590
-------------------------------------------------
@@ -102,6 +107,7 @@ and `Y` shows the status of the work tree. For untracked paths, `XY` are
102107
U U unmerged, both modified
103108
-------------------------------------------------
104109
? ? untracked
110+
! ! ignored
105111
-------------------------------------------------
106112

107113

t/t7508-status.sh

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,127 @@ test_expect_success 'status -s (2)' '
8686
8787
'
8888

89+
test_expect_success 'status with gitignore' '
90+
{
91+
echo ".gitignore" &&
92+
echo "expect" &&
93+
echo "output" &&
94+
echo "untracked"
95+
} >.gitignore &&
96+
97+
cat >expect <<-\EOF &&
98+
M dir1/modified
99+
A dir2/added
100+
?? dir2/modified
101+
EOF
102+
git status -s >output &&
103+
test_cmp expect output &&
104+
105+
cat >expect <<-\EOF &&
106+
M dir1/modified
107+
A dir2/added
108+
?? dir2/modified
109+
!! .gitignore
110+
!! dir1/untracked
111+
!! dir2/untracked
112+
!! expect
113+
!! output
114+
!! untracked
115+
EOF
116+
git status -s --ignored >output &&
117+
test_cmp expect output &&
118+
119+
cat >expect <<-\EOF &&
120+
# On branch master
121+
# Changes to be committed:
122+
# (use "git reset HEAD <file>..." to unstage)
123+
#
124+
# new file: dir2/added
125+
#
126+
# Changed but not updated:
127+
# (use "git add <file>..." to update what will be committed)
128+
# (use "git checkout -- <file>..." to discard changes in working directory)
129+
#
130+
# modified: dir1/modified
131+
#
132+
# Untracked files:
133+
# (use "git add <file>..." to include in what will be committed)
134+
#
135+
# dir2/modified
136+
# Ignored files:
137+
# (use "git add -f <file>..." to include in what will be committed)
138+
#
139+
# .gitignore
140+
# dir1/untracked
141+
# dir2/untracked
142+
# expect
143+
# output
144+
# untracked
145+
EOF
146+
git status --ignored >output &&
147+
test_cmp expect output
148+
'
149+
150+
test_expect_success 'status with gitignore (nothing untracked)' '
151+
{
152+
echo ".gitignore" &&
153+
echo "expect" &&
154+
echo "dir2/modified" &&
155+
echo "output" &&
156+
echo "untracked"
157+
} >.gitignore &&
158+
159+
cat >expect <<-\EOF &&
160+
M dir1/modified
161+
A dir2/added
162+
EOF
163+
git status -s >output &&
164+
test_cmp expect output &&
165+
166+
cat >expect <<-\EOF &&
167+
M dir1/modified
168+
A dir2/added
169+
!! .gitignore
170+
!! dir1/untracked
171+
!! dir2/modified
172+
!! dir2/untracked
173+
!! expect
174+
!! output
175+
!! untracked
176+
EOF
177+
git status -s --ignored >output &&
178+
test_cmp expect output &&
179+
180+
cat >expect <<-\EOF &&
181+
# On branch master
182+
# Changes to be committed:
183+
# (use "git reset HEAD <file>..." to unstage)
184+
#
185+
# new file: dir2/added
186+
#
187+
# Changed but not updated:
188+
# (use "git add <file>..." to update what will be committed)
189+
# (use "git checkout -- <file>..." to discard changes in working directory)
190+
#
191+
# modified: dir1/modified
192+
#
193+
# Ignored files:
194+
# (use "git add -f <file>..." to include in what will be committed)
195+
#
196+
# .gitignore
197+
# dir1/untracked
198+
# dir2/modified
199+
# dir2/untracked
200+
# expect
201+
# output
202+
# untracked
203+
EOF
204+
git status --ignored >output &&
205+
test_cmp expect output
206+
'
207+
208+
rm -f .gitignore
209+
89210
cat >expect <<EOF
90211
# On branch master
91212
# Changes to be committed:

0 commit comments

Comments
 (0)