summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2009-09-03 22:30:27 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2009-09-04 11:50:26 -0700
commit5b5061efd88e1d113a4484369dfab654b43364de (patch)
tree3acca65370698604617c2d771c6512d16820d84e
parentdiff.c: the builtin_diff() deals with only two-file comparison (diff)
downloadtgif-5b5061efd88e1d113a4484369dfab654b43364de.tar.xz
diff --whitespace=warn/error: obey blank-at-eof
The "diff --check" code used to conflate trailing-space whitespace error class with this, but now we have a proper separate error class, we should check it under blank-at-eof, not trailing-space. The whitespace error is not about _having_ blank lines at end, but about adding _new_ blank lines. To keep the message consistent with what is given by "git apply", call whitespace_error_string() to generate it, instead of using a hardcoded custom message. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--diff.c10
-rwxr-xr-xt/t4015-diff-whitespace.sh4
-rwxr-xr-xt/t4019-diff-wserror.sh2
3 files changed, 10 insertions, 6 deletions
diff --git a/diff.c b/diff.c
index 1eddd590ec..a693d184c9 100644
--- a/diff.c
+++ b/diff.c
@@ -1650,10 +1650,14 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
ecb.priv = &data;
xdi_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
- if ((data.ws_rule & WS_TRAILING_SPACE) &&
+ if ((data.ws_rule & WS_BLANK_AT_EOF) &&
data.trailing_blanks_start) {
- fprintf(o->file, "%s:%d: ends with blank lines.\n",
- data.filename, data.trailing_blanks_start);
+ static char *err;
+
+ if (!err)
+ err = whitespace_error_string(WS_BLANK_AT_EOF);
+ fprintf(o->file, "%s:%d: %s\n",
+ data.filename, data.trailing_blanks_start, err);
data.status = 1; /* report errors */
}
}
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index b1cbd36d17..a5d4461574 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -335,10 +335,10 @@ test_expect_success 'line numbers in --check output are correct' '
'
-test_expect_success 'checkdiff detects trailing blank lines' '
+test_expect_success 'checkdiff detects new trailing blank lines (1)' '
echo "foo();" >x &&
echo "" >>x &&
- git diff --check | grep "ends with blank"
+ git diff --check | grep "new blank line"
'
test_expect_success 'checkdiff allows new blank lines' '
diff --git a/t/t4019-diff-wserror.sh b/t/t4019-diff-wserror.sh
index 84a1fe3115..1517fff9c6 100755
--- a/t/t4019-diff-wserror.sh
+++ b/t/t4019-diff-wserror.sh
@@ -165,7 +165,7 @@ test_expect_success 'trailing empty lines (1)' '
rm -f .gitattributes &&
test_must_fail git diff --check >output &&
- grep "ends with blank lines." output &&
+ grep "new blank line at" output &&
grep "trailing whitespace" output
'