Skip to content

Commit ae0a37c

Browse files
committed
Merge branch 'cm/diff-check-at-eol' into maint
* cm/diff-check-at-eol: diff --check: correct line numbers of new blank lines at EOF
2 parents d3334d9 + 8837d33 commit ae0a37c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2158,7 +2158,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
21582158

21592159
ecbdata.ws_rule = data.ws_rule;
21602160
check_blank_at_eof(&mf1, &mf2, &ecbdata);
2161-
blank_at_eof = ecbdata.blank_at_eof_in_preimage;
2161+
blank_at_eof = ecbdata.blank_at_eof_in_postimage;
21622162

21632163
if (blank_at_eof) {
21642164
static char *err;

t/t4019-diff-wserror.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ test_expect_success 'trailing empty lines (2)' '
178178
179179
'
180180

181+
test_expect_success 'checkdiff shows correct line number for trailing blank lines' '
182+
183+
printf "a\nb\n" > G &&
184+
git add G &&
185+
printf "x\nx\nx\na\nb\nc\n\n" > G &&
186+
[ "$(git diff --check -- G)" = "G:7: new blank line at EOF." ]
187+
188+
'
189+
181190
test_expect_success 'do not color trailing cr in context' '
182191
git config --unset core.whitespace
183192
rm -f .gitattributes &&

0 commit comments

Comments
 (0)