From: Junio C Hamano Date: Fri, 21 Oct 2011 17:49:26 +0000 (-0700) Subject: Merge branch 'jc/apply-blank-at-eof-fix' into maint X-Git-Tag: v1.7.7.1~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e63f87a6f7a4e55f50e67b112f26d9a1e4e7f3ab;p=git.git Merge branch 'jc/apply-blank-at-eof-fix' into maint * jc/apply-blank-at-eof-fix: apply --whitespace=error: correctly report new blank lines at end --- e63f87a6f7a4e55f50e67b112f26d9a1e4e7f3ab diff --cc builtin/apply.c index aaa39fe17,508b1edc1..311a94e18 --- a/builtin/apply.c +++ b/builtin/apply.c @@@ -2447,9 -1902,10 +2447,11 @@@ static int apply_one_fragment(struct im int match_beginning, match_end; const char *patch = frag->patch; int size = frag->size; - char *old, *new, *oldlines, *newlines; + char *old, *oldlines; + struct strbuf newlines; int new_blank_lines_at_end = 0; + int found_new_blank_lines_at_end = 0; + int hunk_linenr = frag->linenr; unsigned long leading, trailing; int pos, applied_pos; struct image preimage; @@@ -2629,10 -2088,11 +2635,11 @@@ if (applied_pos >= 0) { if (new_blank_lines_at_end && - preimage.nr + applied_pos == img->nr && + preimage.nr + applied_pos >= img->nr && (ws_rule & WS_BLANK_AT_EOF) && ws_error_action != nowarn_ws_error) { - record_ws_error(WS_BLANK_AT_EOF, "+", 1, frag->linenr); + record_ws_error(WS_BLANK_AT_EOF, "+", 1, + found_new_blank_lines_at_end); if (ws_error_action == correct_ws_error) { while (new_blank_lines_at_end--) remove_last_line(&postimage);