summaryrefslogtreecommitdiff
path: root/pack-objects.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-26 15:40:08 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-26 15:40:08 (GMT)
commitc4fb06c0d04f433ab71d84674ebfe18cda162369 (patch)
treed8bc1479fd9589d808f89711faaaa9c773cb67a8 /pack-objects.c
parent8ee378a0f00a56cbffedee21fdbba30870d84436 (diff)
downloadgit-c4fb06c0d04f433ab71d84674ebfe18cda162369.zip
git-c4fb06c0d04f433ab71d84674ebfe18cda162369.tar.gz
git-c4fb06c0d04f433ab71d84674ebfe18cda162369.tar.bz2
Fix object packing/unpacking.
This actually successfully packed and unpacked a git archive down to 1.3MB (17MB unpacked). Right now unpacking is way too noisy, lots of debug messages left.
Diffstat (limited to 'pack-objects.c')
-rw-r--r--pack-objects.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/pack-objects.c b/pack-objects.c
index 3900df3..aa6cb6d 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -96,7 +96,7 @@ static unsigned long write_object(FILE *f, struct object_entry *entry)
unsigned long size;
char type[10];
void *buf = read_sha1_file(entry->sha1, type, &size);
- char header[21];
+ char header[25];
unsigned hdrlen, datalen;
if (!buf)
@@ -110,16 +110,16 @@ static unsigned long write_object(FILE *f, struct object_entry *entry)
* instead.
*/
header[0] = ".CTB"[entry->type];
- datalen = htonl(size);
- memcpy(header+1, &datalen, 4);
hdrlen = 5;
if (entry->delta) {
header[0] = 'D';
- memcpy(header+1, entry->delta, 20);
+ memcpy(header+5, entry->delta, 20);
buf = delta_against(buf, size, entry);
size = entry->delta_size;
- hdrlen = 21;
+ hdrlen = 25;
}
+ datalen = htonl(size);
+ memcpy(header+1, &datalen, 4);
fwrite(header, hdrlen, 1, f);
datalen = fwrite_compressed(buf, size, f);
free(buf);