summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 67e5a5e)
raw | patch | inline | side by side (parent: 67e5a5e)
author | Junio C Hamano <junkio@cox.net> | |
Wed, 29 Jun 2005 00:49:27 +0000 (17:49 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Wed, 29 Jun 2005 03:37:42 +0000 (20:37 -0700) |
Deltas are useless by themselves and when you use them you need to get
to their base objects. A base object should inherit recency from the
most recent deltified object that is based on it and that is what this
patch teaches git-pack-objects.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
to their base objects. A base object should inherit recency from the
most recent deltified object that is based on it and that is what this
patch teaches git-pack-objects.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
pack-objects.c | patch | blob | history |
diff --git a/pack-objects.c b/pack-objects.c
index 36f515b73821573e5a9be46ebb0b50cdb267b061..feee5600b9c362ad1436db64e3624f646f064fc3 100644 (file)
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -118,6 +118,23 @@ static unsigned long write_object(struct sha1file *f, struct object_entry *entry
return hdrlen + datalen;
}
+static unsigned long write_one(struct sha1file *f,
+ struct object_entry *e,
+ unsigned long offset)
+{
+ if (e->offset)
+ /* offset starts from header size and cannot be zero
+ * if it is written already.
+ */
+ return offset;
+ e->offset = offset;
+ offset += write_object(f, e);
+ /* if we are delitified, write out its base object. */
+ if (e->delta)
+ offset = write_one(f, e->delta, offset);
+ return offset;
+}
+
static void write_pack_file(void)
{
int i;
hdr.hdr_entries = htonl(nr_objects);
sha1write(f, &hdr, sizeof(hdr));
offset = sizeof(hdr);
- for (i = 0; i < nr_objects; i++) {
- struct object_entry *entry = objects + i;
- entry->offset = offset;
- offset += write_object(f, entry);
- }
+ for (i = 0; i < nr_objects; i++)
+ offset = write_one(f, objects + i, offset);
+
sha1close(f, pack_file_sha1, 1);
mb = offset >> 20;
offset &= 0xfffff;