{"thread":{"id":"25411","subject":"[PATCH] Show the correct line number, when git diff --check detects a blank line at EOF.","startedAt":"2010-10-10T17:24:06Z","lastAt":"2010-10-10T17:24:06Z","messageCount":1,"participants":["Christoph Mallon"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"153150","messageId":"4CB1F6B6.2060000@gmx.de","threadId":"25411","inReplyTo":null,"subject":"[PATCH] Show the correct line number, when git diff --check detects a blank line at EOF.","fromName":"Christoph Mallon","fromEmail":"christoph.mallon@gmx.de","sentAt":"2010-10-10T17:24:06Z","receivedAt":"2010-10-10T17:24:06Z","isPatch":true,"sender":{"key":"christoph.mallon@gmx.de","avatar":"https://avatars.githubusercontent.com/u/20772248?v=4"},"body":"The whitespace check printed the value of the wrong variable, i.e. the line number of the hunk in the old file.\n\nSigned-off-by: Christoph Mallon <christoph.mallon@gmx.de>\n---\nThe bug was introduced in d68fe26f3e03b230ac9bbbcf002a9acdc4bebde9. The patch is on top of this commit and can be applied to master (c752e7f3e8d96a9673ad248addc9418164bd3ce6), too.\n\n diff.c                  |    2 +-\n t/t4019-diff-wserror.sh |    9 +++++++++\n 2 files changed, 10 insertions(+), 1 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 63a3bfc..3a3b404 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1730,7 +1730,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,\n \n \t\t\tecbdata.ws_rule = data.ws_rule;\n \t\t\tcheck_blank_at_eof(&mf1, &mf2, &ecbdata);\n-\t\t\tblank_at_eof = ecbdata.blank_at_eof_in_preimage;\n+\t\t\tblank_at_eof = ecbdata.blank_at_eof_in_postimage;\n \n \t\t\tif (blank_at_eof) {\n \t\t\t\tstatic char *err;\ndiff --git a/t/t4019-diff-wserror.sh b/t/t4019-diff-wserror.sh\nindex 3a3663f..61119e6 100755\n--- a/t/t4019-diff-wserror.sh\n+++ b/t/t4019-diff-wserror.sh\n@@ -178,6 +178,15 @@ test_expect_success 'trailing empty lines (2)' '\n \n '\n \n+test_expect_success 'checkdiff shows correct line number for trailing blank lines' '\n+\n+\tprintf \"a\\nb\\n\" > G &&\n+\tgit add G &&\n+\tprintf \"x\\nx\\nx\\na\\nb\\nc\\n\\n\" > G &&\n+\t[ \"$(git diff --check -- G)\" = \"G:7: new blank line at EOF.\" ]\n+\n+'\n+\n test_expect_success 'do not color trailing cr in context' '\n \tgit config --unset core.whitespace\n \trm -f .gitattributes &&\n-- \n1.7.3\n"}]}