X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=diff-delta.c;h=5bc22047f8715b0b1e628ab5ba93afa68e2ccc9e;hb=42d0ee8302c361a0e3bde7bc59858eda94bc13a4;hp=aaee7be4d20dade99d351f6bdd70632cf249230e;hpb=2593a410e095f89f0eef40edb90b39029574462b;p=git.git diff --git a/diff-delta.c b/diff-delta.c index aaee7be4..5bc22047 100644 --- a/diff-delta.c +++ b/diff-delta.c @@ -131,12 +131,13 @@ static struct index ** delta_index(const unsigned char *buf, /* the maximum size for any opcode */ #define MAX_OP_SIZE COPYOP_SIZE(0xffffffff, 0xffffffff) -void *diff_delta(void *from_buf, unsigned long from_size, - void *to_buf, unsigned long to_size, +void *diff_delta(const void *from_buf, unsigned long from_size, + const void *to_buf, unsigned long to_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; }