Show the correct line number, when git diff --check detects a blank line at EOF.
PATCH 1/1 Show the correct line number, when git diff --check detects a blank line at EOF.
The whitespace check printed the value of the wrong variable, i.e. the line number of the hunk in the old file.
Signed-off-by Christoph Mallon <[email protected]>
---
The bug was introduced in d68fe26f3e03b230ac9bbbcf002a9acdc4bebde9. The patch is on top of this commit and can be applied to master (c752e7f3e8d96a9673ad248addc9418164bd3ce6), too.
diff.c | 2 +- t/t4019-diff-wserror.sh | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletions(-)
diff.c +1 -1
@@ -1730,7 +1730,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b, ecbdata.ws_rule = data.ws_rule;check_blank_at_eof (&mf1, &mf2, &ecbdata); - blank_at_eof = ecbdata.blank_at_eof_in_preimage; + blank_at_eof = ecbdata.blank_at_eof_in_postimage;if (blank_at_eof) {static char *err;
t/t4019-diff-wserror.sh +9 -0
@@ -178,6 +178,15 @@ test_expect_success 'trailing empty lines (2)' ' ' +test_expect_success 'checkdiff shows correct line number for trailing blank lines' ' + + printf "a\nb\n" > G && + git add G && + printf "x\nx\nx\na\nb\nc\n\n" > G && + [ "$(git diff --check -- G)" = "G:7: new blank line at EOF." ] + +' + test_expect_success 'do not color trailing cr in context' ' git config --unset core.whitespace rm -f .gitattributes &&
Signature · 1 line
1.7.3