In pack v4 the object size and type is encoded differently from pack v3.
The object size uses the same efficient variable length number encoding
already used elsewhere.
The object type has 4 bits allocated to it compared to 3 bits in pack v3.
This should be quite sufficient for the foreseeable future, especially
since pack v4 has only one type of delta object instead of two.
Signed-off-by: Nicolas Pitre <n...@fluxnic.net>
packv4-create.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/packv4-create.c b/packv4-create.c
index 61b70c8..6098062 100644
@@ -635,6 +635,33 @@ static unsigned long packv4_write_tables(struct sha1file
*f, unsigned nr_objects
+static int write_object_header(struct sha1file *f, enum object_type type,
unsigned long size)
+ unsigned char buf;
+ uint64_t val;
+ int len;
+ * We really have only one kind of delta object.
+ if (type == OBJ_OFS_DELTA)
+ type = OBJ_REF_DELTA;
+ * We allocate 4 bits in the LSB for the object type which should
+ * be good for quite a while, given that we effectively encodes
+ * only 5 object types: commit, tree, blob, delta, tag.
+ val = size;
+ if (MSB(val, 4))
+ die("fixme: the code doesn't currently cope with big sizes");
+ val <<= 4;
+ val |= type;
+ len = encode_varint(val, buf);
+ sha1write(f, buf, len);
+ return len;
static struct packed_git *open_pack(const char *path)
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html