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

[PATCH 4/4] Add tests for "git diff --check" with core.whitespace options

From
Wincent Colaiuta <win@wincent.com>
Date
Dec 12, 2007, 16:23 UTC
Message-ID
<1197476582-18956-5-git-send-email-win@wincent.com>
In-Reply-To
<1197476582-18956-4-git-send-email-win@wincent.com>

Make sure that "git diff --check" does the right thing when the core.whitespace options are set.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
---
 t/t4015-diff-whitespace.sh |   48 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index ff77a16..8d980af 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -256,4 +256,52 @@ test_expect_failure 'check mixed spaces and tabs in indent' '
 
 '
 
+test_expect_success 'check trailing whitespace (trailing-space: off)' '
+
+	git config core.whitespace "-trailing-space" &&
+	echo "foo ();   " > x &&
+	git diff --check
+
+'
+
+test_expect_failure 'check trailing whitespace (trailing-space: on)' '
+
+	git config core.whitespace "trailing-space" &&
+	echo "foo ();   " > x &&
+	git diff --check
+
+'
+
+test_expect_success 'check space before tab in indent (space-before-tab: off)' '
+
+	git config core.whitespace "-space-before-tab" &&
+	echo " 	foo ();" > x &&
+	git diff --check
+
+'
+
+test_expect_failure 'check space before tab in indent (space-before-tab: on)' '
+
+	git config core.whitespace "space-before-tab" &&
+	echo " 	foo ();   " > x &&
+	git diff --check
+
+'
+
+test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' '
+
+	git config core.whitespace "-indent-with-non-tab"
+	echo "                foo ();" > x &&
+	git diff --check
+
+'
+
+test_expect_failure 'check spaces as indentation (indent-with-non-tab: on)' '
+
+	git config core.whitespace "indent-with-non-tab" &&
+	echo "                foo ();" > x &&
+	git diff --check
+
+'
+
 test_done
-- 
1.5.3.7.1159.g2f071-dirty
Previous: Wincent ColaiutaNext: Junio C Hamano
Message 5 of 7 in “Refactoring for apply and diff”
  1. 0/4 Refactoring for apply and diffWincent Colaiuta, Dec 12, 2007
  2. 1/4 Fix "diff --check" whitespace detectionWincent Colaiuta, Dec 12, 2007
  3. 2/4 Extract and improve whitespace check from "git apply"Wincent Colaiuta, Dec 12, 2007
  4. 3/3 Make "diff --check" use shared whitespace functionsWincent Colaiuta, Dec 12, 2007
  5. 4/4 Add tests for "git diff --check" with core.whitespace optionsWincent Colaiuta, Dec 12, 2007
  6. Junio C HamanoDec 12, 2007
  7. Wincent ColaiutaDec 12, 2007

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.