]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jc/apply-blank-at-eof-fix'
authorJunio C Hamano <gitster@pobox.com>
Fri, 14 Oct 2011 02:03:20 +0000 (19:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Oct 2011 02:03:20 +0000 (19:03 -0700)
* jc/apply-blank-at-eof-fix:
  apply --whitespace=error: correctly report new blank lines at end

1  2 
builtin/apply.c

diff --cc builtin/apply.c
index 872e40ab1e0401a480ee8e852d09899f4d4553ed,508b1edc19555d2eab3c99b2a7fd667807e21972..694f55dc5ac4c439eeaceadd3e1c70df5bb42aa1
@@@ -2444,9 -1902,10 +2444,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;
  
        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);