X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=diff-delta.c;h=1188b31cd0f1e2f3a1fc2096a10243a03b439021;hb=5a1fb2ca92caaa7ae9044ab81dc102f59d17b97a;hp=aaee7be4d20dade99d351f6bdd70632cf249230e;hpb=71bb10336fa79ff667f4753668aaa72b6ebfc689;p=git.git diff --git a/diff-delta.c b/diff-delta.c index aaee7be4..1188b31c 100644 --- a/diff-delta.c +++ b/diff-delta.c @@ -136,7 +136,8 @@ void *diff_delta(void *from_buf, unsigned long from_size, unsigned long *delta_size, unsigned long max_size) { - unsigned int i, outpos, outsize, inscnt, hash_shift; + unsigned int i, outpos, outsize, hash_shift; + int inscnt; const unsigned char *ref_data, *ref_top, *data, *top; unsigned char *out; struct index *entry, **hash; @@ -222,6 +223,20 @@ void *diff_delta(void *from_buf, unsigned long from_size, unsigned char *op; if (inscnt) { + while (moff && ref_data[moff-1] == data[-1]) { + if (msize == 0x10000) + break; + /* we can match one byte back */ + msize++; + moff--; + data--; + outpos--; + if (--inscnt) + continue; + outpos--; /* remove count slot */ + inscnt--; /* make it -1 */ + break; + } out[outpos - inscnt - 1] = inscnt; inscnt = 0; }