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

Re: git status --ignored

From
Jeff King <peff@peff.net>
Date
Jun 2, 2011, 17:20 UTC
Message-ID
<20110602172021.GB2928@sigill.intra.peff.net>
In-Reply-To
<7vk4d4dxn1.fsf@alter.siamese.dyndns.org>
On Thu, Jun 02, 2011 at 09:08:18AM -0700, Junio C Hamano wrote:
Show 13 quoted lines
> +	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

Unfortunately this does not actually show the bug, as the short format takes a different code path that was not broken.

I have mixed feelings about putting the whole long format in a test vector, as all of the human-readable bits are supposed to be allowed to change. And I know that tests are only partially about demonstrating a particular bug, and more about codifying the behavior we want so future changes don't break it. But it is nice to exercise that code path, and it doesn't change all that much, so maybe it is worth doing. Squashable patch below. Throw it out if you don't agree.

> +test_expect_success 'status with gitignore' '

It took me a minute to figure out what was different between the two tests with the same title. Maybe calling them "status with gitignore (untracked files present)" and "status with gitignore (no untracked files)" would help future readers.

---
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index b47aad8..957c1e3 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -115,6 +115,36 @@ test_expect_success 'status with gitignore' '
 	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' '
@@ -146,6 +176,33 @@ test_expect_success 'status with gitignore' '
 	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
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 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.