1. Stefan Saasen
  2. git

Commits

Junio C Hamano  committed b46c9fa Merge

Merge branch 'jc/maint-apply-no-double-patch' into maint

* jc/maint-apply-no-double-patch:
apply: do not patch lines that were already patched

  • Participants
  • Parent commits 46a1f07, 9d15860
  • Branches master

Comments (0)

Files changed (1)

File builtin/apply.c

View file
  • Ignore whitespace
 	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;
 }