summaryrefslogtreecommitdiff
path: root/index-pack.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2006-09-21 00:06:49 -0400
committerJunio C Hamano <junkio@cox.net>2006-09-27 00:11:59 -0700
commiteb32d236df0c16b936b04f0c5402addb61cdb311 (patch)
tree005ee01d7e4813930c25854277d704d2f11bccb3 /index-pack.c
parent4a0641b7cf833644b286b56bb57d66b5538e4418 (diff)
downloadgit-eb32d236df0c16b936b04f0c5402addb61cdb311.tar.gz
introduce delta objects with offset to base
This adds a new object, namely OBJ_OFS_DELTA, renames OBJ_DELTA to OBJ_REF_DELTA to better make the distinction between those two delta objects, and adds support for the handling of those new delta objects in sha1_file.c only. The OBJ_OFS_DELTA contains a relative offset from the delta object's position in a pack instead of the 20-byte SHA1 reference to identify the base object. Since the base is likely to be not so far away, the relative offset is more likely to have a smaller encoding on average than an absolute offset. And for those delta objects the base must always be stored first because there is no way to know the distance of later objects when streaming a pack. Hence this relative offset is always meant to be negative. The offset encoding is slightly denser than the one used for object size -- credits to <linux@horizon.com> (whoever this is) for bringing it to my attention. This allows for pack size reduction between 3.2% (Linux-2.6) to over 5% (linux-historic). Runtime pack access should be faster too since delta replay does skip a search in the pack index for each delta in a chain. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'index-pack.c')
-rw-r--r--index-pack.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/index-pack.c b/index-pack.c
index 80bc6cb45b..aef7f0a32e 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -158,7 +158,7 @@ static void *unpack_raw_entry(unsigned long offset,
}
switch (type) {
- case OBJ_DELTA:
+ case OBJ_REF_DELTA:
if (pos + 20 >= pack_limit)
bad_object(offset, "object extends past end of pack");
hashcpy(delta_base, pack_base + pos);
@@ -301,7 +301,7 @@ static void parse_pack_objects(void)
data = unpack_raw_entry(offset, &obj->type, &data_size,
base_sha1, &offset);
obj->real_type = obj->type;
- if (obj->type == OBJ_DELTA) {
+ if (obj->type == OBJ_REF_DELTA) {
struct delta_entry *delta = &deltas[nr_deltas++];
delta->obj = obj;
hashcpy(delta->base_sha1, base_sha1);
@@ -328,7 +328,7 @@ static void parse_pack_objects(void)
struct object_entry *obj = &objects[i];
int j, first, last;
- if (obj->type == OBJ_DELTA)
+ if (obj->type == OBJ_REF_DELTA)
continue;
if (find_deltas_based_on_sha1(obj->sha1, &first, &last))
continue;
@@ -341,7 +341,7 @@ static void parse_pack_objects(void)
/* Check for unresolved deltas */
for (i = 0; i < nr_deltas; i++) {
- if (deltas[i].obj->real_type == OBJ_DELTA)
+ if (deltas[i].obj->real_type == OBJ_REF_DELTA)
die("packfile '%s' has unresolved deltas", pack_name);
}
}