git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git status --ignored

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 2, 2011, 16:08 UTC
Message-ID
<7vk4d4dxn1.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20110602055449.GA28292@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> I can reproduce here. The faulty logic means the bug only shows when you
> actually have no real untracked files. You should keep your git
> directory cleaner. ;)
Ok.
-- >8 --
Subject: [PATCH] git status --ignored: tests and docs
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/git-status.txt |    6 ++++
 t/t7508-status.sh            |   64 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index 1cab91b..b663e51 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -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.
@@ -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
     -------------------------------------------------
@@ -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
     -------------------------------------------------
 
 
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 556d0fa..b47aad8 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -86,6 +86,70 @@ 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
+'
+
+test_expect_success 'status with gitignore' '
+	{
+		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
+'
+
+rm -f .gitignore
+
 cat >expect <<EOF
 # On branch master
 # Changes to be committed:
-- 
1.7.6.rc0.98.gc12085
Previous: Jeff KingNext: Jeff King
Message 5 of 7 in “git status --ignored”
  1. Andrew SpiersJun 2, 2011
  2. Junio C HamanoJun 2, 2011
  3. Jeff KingJun 2, 2011
  4. Jeff KingJun 2, 2011
  5. Junio C HamanoJun 2, 2011
  6. Jeff KingJun 2, 2011
  7. Junio C HamanoJun 2, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.