summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 964498e)
raw | patch | inline | side by side (parent: 964498e)
author | Junio C Hamano <gitster@pobox.com> | |
Fri, 4 Mar 2011 22:43:45 +0000 (14:43 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 6 Mar 2011 22:02:45 +0000 (14:02 -0800) |
When the line number the patch intended to touch does not match
the line in the version being patched, GNU patch reports that
it applied the hunk at a different line number, with how big an
offset.
Teach "git apply" to do the same under --verbose option.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
the line in the version being patched, GNU patch reports that
it applied the hunk at a different line number, with how big an
offset.
Teach "git apply" to do the same under --verbose option.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/apply.c | patch | blob | history |
diff --git a/builtin/apply.c b/builtin/apply.c
index 14951daedffa9e8a8a913eee5e8423220e86e291..a231c0c7ca1c5ae75db84b38c0038777a63ba8d0 100644 (file)
--- a/builtin/apply.c
+++ b/builtin/apply.c
}
static int apply_one_fragment(struct image *img, struct fragment *frag,
- int inaccurate_eof, unsigned ws_rule)
+ int inaccurate_eof, unsigned ws_rule,
+ int nth_fragment)
{
int match_beginning, match_end;
const char *patch = frag->patch;
apply = 0;
}
+ if (apply_verbosely && applied_pos != pos) {
+ int offset = applied_pos - pos;
+ if (apply_in_reverse)
+ offset = 0 - offset;
+ fprintf(stderr,
+ "Hunk #%d succeeded at %d (offset %d lines).\n",
+ nth_fragment, applied_pos + 1, offset);
+ }
+
/*
* Warn if it was necessary to reduce the number
* of context lines.
const char *name = patch->old_name ? patch->old_name : patch->new_name;
unsigned ws_rule = patch->ws_rule;
unsigned inaccurate_eof = patch->inaccurate_eof;
+ int nth = 0;
if (patch->is_binary)
return apply_binary(img, patch);
while (frag) {
- if (apply_one_fragment(img, frag, inaccurate_eof, ws_rule)) {
+ nth++;
+ if (apply_one_fragment(img, frag, inaccurate_eof, ws_rule, nth)) {
error("patch failed: %s:%ld", name, frag->oldpos);
if (!apply_with_reject)
return -1;