summaryrefslogtreecommitdiff
path: root/builtin/apply.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-10-21 17:49:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-10-21 17:49:26 (GMT)
commite63f87a6f7a4e55f50e67b112f26d9a1e4e7f3ab (patch)
tree613c9ce697b049f70961c26761230f54ec47b249 /builtin/apply.c
parent6e89b37d34f9a58182192664f304c15f525be4d2 (diff)
parent855726395342441808eff5e4e9ad9a2b9254edbc (diff)
downloadgit-e63f87a6f7a4e55f50e67b112f26d9a1e4e7f3ab.zip
git-e63f87a6f7a4e55f50e67b112f26d9a1e4e7f3ab.tar.gz
git-e63f87a6f7a4e55f50e67b112f26d9a1e4e7f3ab.tar.bz2
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
Diffstat (limited to 'builtin/apply.c')
-rw-r--r--builtin/apply.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index aaa39fe..311a94e 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -2450,6 +2450,8 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
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;
@@ -2543,14 +2545,18 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
error("invalid start of line: '%c'", first);
return -1;
}
- if (added_blank_line)
+ if (added_blank_line) {
+ if (!new_blank_lines_at_end)
+ found_new_blank_lines_at_end = hunk_linenr;
new_blank_lines_at_end++;
+ }
else if (is_blank_context)
;
else
new_blank_lines_at_end = 0;
patch += len;
size -= len;
+ hunk_linenr++;
}
if (inaccurate_eof &&
old > oldlines && old[-1] == '\n' &&
@@ -2632,7 +2638,8 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
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);