{"thread":{"id":"14170","subject":"[PATCH] diff --check: do not discard error status upon seeing a good line","startedAt":"2008-06-26T20:22:24Z","lastAt":"2008-06-26T20:22:24Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"81319","messageId":"7vwskcosjj.fsf@gitster.siamese.dyndns.org","threadId":"14170","inReplyTo":null,"subject":"[PATCH] diff --check: do not discard error status upon seeing a good line","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-06-26T20:22:24Z","receivedAt":"2008-06-26T20:22:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"git diff --check\" should return non-zero when there was any whitespace\nerrors but the code only paid attention to the error status of the last\nnew line in the patch.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * c1795bb (Unify whitespace checking, 2007-12-13) broke this part of the\n   code.\n\n diff.c                 |    8 +++++---\n t/t4017-diff-retval.sh |    8 ++++++++\n 2 files changed, 13 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 5262490..f281c5b 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1150,12 +1150,14 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)\n \tchar *err;\n \n \tif (line[0] == '+') {\n+\t\tunsigned bad;\n \t\tdata->lineno++;\n-\t\tdata->status = check_and_emit_line(line + 1, len - 1,\n+\t\tbad = check_and_emit_line(line + 1, len - 1,\n \t\t    data->ws_rule, NULL, NULL, NULL, NULL);\n-\t\tif (!data->status)\n+\t\tif (!bad)\n \t\t\treturn;\n-\t\terr = whitespace_error_string(data->status);\n+\t\tdata->status |= bad;\n+\t\terr = whitespace_error_string(bad);\n \t\tfprintf(data->file, \"%s:%d: %s.\\n\", data->filename, data->lineno, err);\n \t\tfree(err);\n \t\temit_line(data->file, set, reset, line, 1);\ndiff --git a/t/t4017-diff-retval.sh b/t/t4017-diff-retval.sh\nindex dc0b712..0d0fb87 100755\n--- a/t/t4017-diff-retval.sh\n+++ b/t/t4017-diff-retval.sh\n@@ -105,4 +105,12 @@ test_expect_success '--check with --no-pager returns 2 for dirty difference' '\n \n '\n \n+\n+test_expect_success 'check should test not just the last line' '\n+\techo \"\" >>a &&\n+\tgit --no-pager diff --check\n+\ttest $? = 2\n+\n+'\n+\n test_done\n-- \n1.5.6.1.78.gde8d9\n"}]}