summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e636106)
raw | patch | inline | side by side (parent: e636106)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 26 Jun 2008 20:16:33 +0000 (13:16 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 26 Jun 2008 20:26:25 +0000 (13:26 -0700) |
"git diff --check" should return non-zero when there was any whitespace
error but the code only paid attention to the error status of the last
new line in the patch.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
error but the code only paid attention to the error status of the last
new line in the patch.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c | patch | blob | history | |
t/t4017-diff-retval.sh | patch | blob | history |
index 526249008662d4041e5623914c1a420f3443c4d4..f281c5b82a623623f5840c19261155ede81e1301 100644 (file)
--- a/diff.c
+++ b/diff.c
char *err;
if (line[0] == '+') {
+ unsigned bad;
data->lineno++;
- data->status = check_and_emit_line(line + 1, len - 1,
+ bad = check_and_emit_line(line + 1, len - 1,
data->ws_rule, NULL, NULL, NULL, NULL);
- if (!data->status)
+ if (!bad)
return;
- err = whitespace_error_string(data->status);
+ data->status |= bad;
+ err = whitespace_error_string(bad);
fprintf(data->file, "%s:%d: %s.\n", data->filename, data->lineno, err);
free(err);
emit_line(data->file, set, reset, line, 1);
diff --git a/t/t4017-diff-retval.sh b/t/t4017-diff-retval.sh
index dc0b7126cc996594b415058d83014a2c7d732895..0d0fb87f5732e3ecbca8a195843070539353701e 100755 (executable)
--- a/t/t4017-diff-retval.sh
+++ b/t/t4017-diff-retval.sh
'
+
+test_expect_success 'check should test not just the last line' '
+ echo "" >>a &&
+ git --no-pager diff --check
+ test $? = 2
+
+'
+
test_done