author | Junio C Hamano <gitster@pobox.com> | |
Fri, 1 Apr 2011 23:20:11 +0000 (16:20 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 1 Apr 2011 23:20:11 +0000 (16:20 -0700) |
* jc/maint-apply-no-double-patch:
apply: do not patch lines that were already patched
apply: do not patch lines that were already patched
builtin/apply.c | patch | blob | history |
diff --git a/builtin/apply.c b/builtin/apply.c
index 14951daedffa9e8a8a913eee5e8423220e86e291..04f56f850a430cc0f132b6ad38018760eb68a77b 100644 (file)
--- a/builtin/apply.c
+++ b/builtin/apply.c
unsigned hash : 24;
unsigned flag : 8;
#define LINE_COMMON 1
+#define LINE_PATCHED 2
};
/*
/* Quick hash check */
for (i = 0; i < preimage_limit; i++)
- if (preimage->line[i].hash != img->line[try_lno + i].hash)
+ if ((img->line[try_lno + i].flag & LINE_PATCHED) ||
+ (preimage->line[i].hash != img->line[try_lno + i].hash))
return 0;
if (preimage_limit == preimage->nr) {
memcpy(img->line + applied_pos,
postimage->line,
postimage->nr * sizeof(*img->line));
+ for (i = 0; i < postimage->nr; i++)
+ img->line[applied_pos + i].flag |= LINE_PATCHED;
+
img->nr = nr;
}