{"thread":{"id":"12121","subject":"[PATCH] Fix line numbers emitted by \"git diff --check\"","startedAt":"2008-02-15T23:33:43Z","lastAt":"2008-02-16T07:04:40Z","messageCount":2,"participants":["Jay Soffian","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"68854","messageId":"1203118423-32642-1-git-send-email-jaysoffian@gmail.com","threadId":"12121","inReplyTo":null,"subject":"[PATCH] Fix line numbers emitted by \"git diff --check\"","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2008-02-15T23:33:43Z","receivedAt":"2008-02-15T23:33:43Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"Fixes a problem where git diff --check was emitting incorrect lines\nnumbers. Adds a test to verify the fix.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\n diff.c                     |    4 +++-\n t/t4015-diff-whitespace.sh |    9 +++++++++\n 2 files changed, 12 insertions(+), 1 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex cd8bc4d..a002573 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1023,8 +1023,10 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)\n \tif (line[0] == '+') {\n \t\tdata->status = 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 (!data->status) {\n+\t\t\tdata->lineno++;\n \t\t\treturn;\n+\t\t}\n \t\terr = whitespace_error_string(data->status);\n \t\tprintf(\"%s:%d: %s.\\n\", data->filename, data->lineno, err);\n \t\tfree(err);\ndiff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh\nindex d30169f..83c54b7 100755\n--- a/t/t4015-diff-whitespace.sh\n+++ b/t/t4015-diff-whitespace.sh\n@@ -326,4 +326,13 @@ test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab:\n \t! git diff --check\n \n '\n+\n+test_expect_success 'line numbers in --check output are correct' '\n+\n+\techo \"\" > x &&\n+\techo \"foo(); \" >> x &&\n+\tgit diff --check | grep \"x:2:\"\n+\n+'\n+\n test_done\n-- \n1.5.4.1.1281.g75df\n"},{"id":"68878","messageId":"7vk5l5crg7.fsf@gitster.siamese.dyndns.org","threadId":"12121","inReplyTo":"1203118423-32642-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH] Fix line numbers emitted by \"git diff --check\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-16T07:04:40Z","receivedAt":"2008-02-16T07:04:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> writes:\n\n> Fixes a problem where git diff --check was emitting incorrect lines\n> numbers. Adds a test to verify the fix.\n>\n> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>\n\nAhh, our mails crossed, and our fixes are equivalent, but yours\nhas an additional test, which is always good.\n\nWill steal the test part and squash it in (I've already patched\n'maint' with the one I sent out), if you do not mind.\n"}]}