summaryrefslogtreecommitdiff
path: root/patch-delta.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2006-02-09 22:50:04 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-02-10 05:06:38 (GMT)
commitd60fc1c8649f80c006b9f493c542461e81608d4b (patch)
treed481762cf3c8954e9bc635c61127b77342ae79d0 /patch-delta.c
parent67d42212ff104aaafa97b943cb369b8444f61581 (diff)
downloadgit-d60fc1c8649f80c006b9f493c542461e81608d4b.zip
git-d60fc1c8649f80c006b9f493c542461e81608d4b.tar.gz
git-d60fc1c8649f80c006b9f493c542461e81608d4b.tar.bz2
remove delta-against-self bit
After experimenting with code to add the ability to encode a delta against part of the deltified file, it turns out that resulting packs are _bigger_ than when this ability is not used. The raw delta output might be smaller, but it doesn't compress as well using gzip with a negative net saving on average. Said bit would in fact be more useful to allow for encoding the copying of chunks larger than 64KB providing more savings with large files. This will correspond to packs version 3. While the current code still produces packs version 2, it is made future proof so pack versions 2 and 3 are accepted. Any pack version 2 are compatible with version 3 since the redefined bit was never used before. When enough time has passed, code to use that bit to produce version 3 packs could be added. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'patch-delta.c')
-rw-r--r--patch-delta.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/patch-delta.c b/patch-delta.c
index 98c27be..c0e1311 100644
--- a/patch-delta.c
+++ b/patch-delta.c
@@ -44,16 +44,15 @@ void *patch_delta(void *src_buf, unsigned long src_size,
cmd = *data++;
if (cmd & 0x80) {
unsigned long cp_off = 0, cp_size = 0;
- const unsigned char *buf;
if (cmd & 0x01) cp_off = *data++;
if (cmd & 0x02) cp_off |= (*data++ << 8);
if (cmd & 0x04) cp_off |= (*data++ << 16);
if (cmd & 0x08) cp_off |= (*data++ << 24);
if (cmd & 0x10) cp_size = *data++;
if (cmd & 0x20) cp_size |= (*data++ << 8);
+ if (cmd & 0x40) cp_size |= (*data++ << 16);
if (cp_size == 0) cp_size = 0x10000;
- buf = (cmd & 0x40) ? dst_buf : src_buf;
- memcpy(out, buf + cp_off, cp_size);
+ memcpy(out, src_buf + cp_off, cp_size);
out += cp_size;
} else {
memcpy(out, data, cmd);