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

[PATCH 2/4] tests: check --[short]stat output after chmod

From
Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Date
May 1, 2012, 17:10 UTC
Message-ID
<1335892215-21331-3-git-send-email-zbyszek@in.waw.pl>
In-Reply-To
<1335892215-21331-1-git-send-email-zbyszek@in.waw.pl>

Add a test to check 'diff --stat' output with a text file after chmod, and the same for a binary file. This demonstrates that text and binary files are treated differently, which can be misleading.

While at it, duplicate the tests to check --shortstat output too.
Reported-by: Martin Mareš <mj@ucw.cz>
Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
---
 t/t4006-diff-mode.sh |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
diff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh
index c8f5180..a81c095 100755
--- a/t/t4006-diff-mode.sh
+++ b/t/t4006-diff-mode.sh
@@ -25,4 +25,41 @@ test_expect_success 'chmod' '
 	test_cmp expected check
 '
 
+test_expect_success 'prepare binary file' '
+	git commit -m rezrov &&
+	dd if=/dev/zero of=binbin bs=1024 count=1 &&
+	git add binbin &&
+	git commit -m binbin
+'
+
+test_expect_success '--stat output after text chmod' '
+	test_chmod -x rezrov &&
+	echo " 0 files changed" >expect &&
+	git diff HEAD --stat >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success '--shortstat output after text chmod' '
+	git diff HEAD --shortstat >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success '--stat output after binary chmod' '
+	test_chmod +x binbin &&
+	cat >expect <<-EOF &&
+	 binbin |  Bin 1024 -> 1024 bytes
+	 1 file changed, 0 insertions(+), 0 deletions(-)
+	EOF
+	git diff HEAD --stat >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success '--shortstat output after binary chmod' '
+	cat >expect <<-EOF &&
+	 1 file changed, 0 insertions(+), 0 deletions(-)
+	EOF
+	git diff HEAD --shortstat >actual &&
+	test_cmp expect actual
+'
+
 test_done
-- 
1.7.10.539.g288dd
Previous: Zbigniew Jędrzejewski-SzmekNext: Johannes Sixt
Message 5 of 11 in “report chmod'ed binary files the same as text files”
  1. 0/4 report chmod'ed binary files the same as text filesZbigniew Jędrzejewski-Szmek, May 1, 2012
  2. 1/4 test: modernize style of t4006Zbigniew Jędrzejewski-Szmek, May 1, 2012
  3. Junio C HamanoMay 1, 2012
  4. Zbigniew Jędrzejewski-SzmekMay 1, 2012
  5. 2/4 tests: check --[short]stat output after chmodZbigniew Jędrzejewski-Szmek, May 1, 2012
  6. Johannes SixtMay 2, 2012
  7. 3/4 diff --stat: report chmoded binary files like text filesZbigniew Jędrzejewski-Szmek, May 1, 2012
  8. Junio C HamanoMay 1, 2012
  9. Zbigniew Jędrzejewski-SzmekMay 1, 2012
  10. 4/4 diff --stat: do not run diff on indentical filesZbigniew Jędrzejewski-Szmek, May 1, 2012
  11. Martin MaresMay 3, 2012

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.