Skip to content

Commit af2b184

Browse files
committed
Merge branch 'jc/maint-apply-no-double-patch'
* jc/maint-apply-no-double-patch: apply: do not patch lines that were already patched
2 parents 848e219 + 9d15860 commit af2b184

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

builtin/apply.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ struct line {
204204
unsigned hash : 24;
205205
unsigned flag : 8;
206206
#define LINE_COMMON 1
207+
#define LINE_PATCHED 2
207208
};
208209

209210
/*
@@ -2085,7 +2086,8 @@ static int match_fragment(struct image *img,
20852086

20862087
/* Quick hash check */
20872088
for (i = 0; i < preimage_limit; i++)
2088-
if (preimage->line[i].hash != img->line[try_lno + i].hash)
2089+
if ((img->line[try_lno + i].flag & LINE_PATCHED) ||
2090+
(preimage->line[i].hash != img->line[try_lno + i].hash))
20892091
return 0;
20902092

20912093
if (preimage_limit == preimage->nr) {
@@ -2428,6 +2430,9 @@ static void update_image(struct image *img,
24282430
memcpy(img->line + applied_pos,
24292431
postimage->line,
24302432
postimage->nr * sizeof(*img->line));
2433+
for (i = 0; i < postimage->nr; i++)
2434+
img->line[applied_pos + i].flag |= LINE_PATCHED;
2435+
24312436
img->nr = nr;
24322437
}
24332438

0 commit comments

Comments
 (0)