summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7e4ad90)
raw | patch | inline | side by side (parent: 7e4ad90)
author | Junio C Hamano <gitster@pobox.com> | |
Tue, 12 Aug 2008 05:15:28 +0000 (22:15 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 12 Aug 2008 05:15:28 +0000 (22:15 -0700) |
Recently "git diff --check" learned to detect new trailing blank lines
just like "git apply --whitespace" does. However this check should not
trigger unconditionally. This patch makes it honor the whitespace
settings from core.whitespace and gitattributes.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
just like "git apply --whitespace" does. However this check should not
trigger unconditionally. This patch makes it honor the whitespace
settings from core.whitespace and gitattributes.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c | patch | blob | history | |
t/t4019-diff-wserror.sh | patch | blob | history |
index 8746c60b9cb634bf78911c34cad1ba5a1f93d5ec..6954f992c2f268e2733af1e312a48ac3bc27799b 100644 (file)
--- a/diff.c
+++ b/diff.c
ecb.priv = &data;
xdi_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
- if (data.trailing_blanks_start) {
+ if ((data.ws_rule & WS_TRAILING_SPACE) &&
+ data.trailing_blanks_start) {
fprintf(o->file, "%s:%d: ends with blank lines.\n",
data.filename, data.trailing_blanks_start);
data.status = 1; /* report errors */
index 0d9cbb62615c0d94da784f63907989988b0e8151..7eae1f4500591799d656f1dde20cf15f296cf6e4 100755 (executable)
--- a/t/t4019-diff-wserror.sh
+++ b/t/t4019-diff-wserror.sh
echo " HT and SP indent" >>F &&
echo "With trailing SP " >>F &&
echo "Carriage ReturnQ" | tr Q "\015" >>F &&
- echo "No problem" >>F
+ echo "No problem" >>F &&
+ echo >>F
'
'
+test_expect_success 'trailing empty lines (1)' '
+
+ rm -f .gitattributes &&
+ test_must_fail git diff --check >output &&
+ grep "ends with blank lines." output &&
+ grep "trailing whitespace" output
+
+'
+
+test_expect_success 'trailing empty lines (2)' '
+
+ echo "F -whitespace" >.gitattributes &&
+ git diff --check >output &&
+ ! test -s output
+
+'
+
test_done