Skip to content

Commit

Permalink
git status --ignored: tests and docs
Browse files Browse the repository at this point in the history
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Jun 2, 2011
1 parent 1282988 commit 150b493
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Documentation/git-status.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ See linkgit:git-config[1] for configuration variable
used to change the default for when the option is not
specified.

--ignored::
Show ignored files as well.

-z::
Terminate entries with NUL, instead of LF. This implies
the `--porcelain` output format if no other format is given.
Expand Down Expand Up @@ -80,6 +83,8 @@ shows the status of stage #3 (i.e. theirs).
For entries that do not have conflicts, `X` shows the status of the index,
and `Y` shows the status of the work tree. For untracked paths, `XY` are
`??`.
For ignored paths, `XY` are `!!`; they are shown only when the `--ignored`
option is in effect.

X Y Meaning
-------------------------------------------------
Expand All @@ -102,6 +107,7 @@ and `Y` shows the status of the work tree. For untracked paths, `XY` are
U U unmerged, both modified
-------------------------------------------------
? ? untracked
! ! ignored
-------------------------------------------------


Expand Down
121 changes: 121 additions & 0 deletions t/t7508-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,127 @@ test_expect_success 'status -s (2)' '
'

test_expect_success 'status with gitignore' '
{
echo ".gitignore" &&
echo "expect" &&
echo "output" &&
echo "untracked"
} >.gitignore &&
cat >expect <<-\EOF &&
M dir1/modified
A dir2/added
?? dir2/modified
EOF
git status -s >output &&
test_cmp expect output &&
cat >expect <<-\EOF &&
M dir1/modified
A dir2/added
?? dir2/modified
!! .gitignore
!! dir1/untracked
!! dir2/untracked
!! expect
!! output
!! untracked
EOF
git status -s --ignored >output &&
test_cmp expect output &&
cat >expect <<-\EOF &&
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: dir2/added
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: dir1/modified
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# dir2/modified
# Ignored files:
# (use "git add -f <file>..." to include in what will be committed)
#
# .gitignore
# dir1/untracked
# dir2/untracked
# expect
# output
# untracked
EOF
git status --ignored >output &&
test_cmp expect output
'

test_expect_success 'status with gitignore (nothing untracked)' '
{
echo ".gitignore" &&
echo "expect" &&
echo "dir2/modified" &&
echo "output" &&
echo "untracked"
} >.gitignore &&
cat >expect <<-\EOF &&
M dir1/modified
A dir2/added
EOF
git status -s >output &&
test_cmp expect output &&
cat >expect <<-\EOF &&
M dir1/modified
A dir2/added
!! .gitignore
!! dir1/untracked
!! dir2/modified
!! dir2/untracked
!! expect
!! output
!! untracked
EOF
git status -s --ignored >output &&
test_cmp expect output &&
cat >expect <<-\EOF &&
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: dir2/added
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: dir1/modified
#
# Ignored files:
# (use "git add -f <file>..." to include in what will be committed)
#
# .gitignore
# dir1/untracked
# dir2/modified
# dir2/untracked
# expect
# output
# untracked
EOF
git status --ignored >output &&
test_cmp expect output
'

rm -f .gitignore

cat >expect <<EOF
# On branch master
# Changes to be committed:
Expand Down

0 comments on commit 150b493

Please sign in to comment.