summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b8d9c1a)
raw | patch | inline | side by side (parent: b8d9c1a)
author | Junio C Hamano <gitster@pobox.com> | |
Fri, 4 Sep 2009 05:30:27 +0000 (22:30 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 4 Sep 2009 18:50:26 +0000 (11:50 -0700) |
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>
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>
diff.c | patch | blob | history | |
t/t4015-diff-whitespace.sh | patch | blob | history | |
t/t4019-diff-wserror.sh | patch | blob | history |
index 1eddd590ec745b57d4c0305a35d8d3744bd30ad6..a693d184c95d3aaf8f2ab592bd806bbc64441a39 100644 (file)
--- a/diff.c
+++ b/diff.c
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 */
}
}
index b1cbd36d1710a38b94838a2fdf08e0e5ded431f8..a5d446157455de909d47abfd32a363091ed41e42 100755 (executable)
'
-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' '
index 84a1fe31151c2af38554eaca8f03e2c1e2e7848f..1517fff9c64f711a6fd3dda6361a338d0e1fdfe0 100755 (executable)
--- a/t/t4019-diff-wserror.sh
+++ b/t/t4019-diff-wserror.sh
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
'