Skip to content

Commit

Permalink
Merge branch 'jc/maint-apply-no-double-patch' into maint
Browse files Browse the repository at this point in the history
* jc/maint-apply-no-double-patch:
  apply: do not patch lines that were already patched
  • Loading branch information
Junio C Hamano committed Apr 1, 2011
2 parents 46a1f07 + 9d15860 commit b46c9fa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion builtin/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ struct line {
unsigned hash : 24;
unsigned flag : 8;
#define LINE_COMMON 1
#define LINE_PATCHED 2
};

/*
Expand Down Expand Up @@ -2085,7 +2086,8 @@ static int match_fragment(struct image *img,

/* 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) {
Expand Down Expand Up @@ -2428,6 +2430,9 @@ static void update_image(struct image *img,
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;
}

Expand Down

0 comments on commit b46c9fa

Please sign in to comment.