summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-07-17 15:06:23 -0700
committerJunio C Hamano <junkio@cox.net>2006-07-25 14:15:48 -0700
commitceec1361ebbc4613813ba42976503f5e304cfacf (patch)
tree63c317e6e9c6598fcd03fdc07e07cbed7f882d9a
parentbb6b8e4f877e8b59b3756960e29d1955072dab56 (diff)
downloadgit-ceec1361ebbc4613813ba42976503f5e304cfacf.tar.gz
pack-objects: reuse deflated data from new-style loose objects.
When packing an object without deltifying, if the data is stored in a loose object that is encoded with a new style header, copy it without inflating and deflating. Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--pack-objects.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/pack-objects.c b/pack-objects.c
index 861c7f08ff..e52e9774e5 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -269,6 +269,22 @@ static unsigned long write_object(struct sha1file *f,
* and we do not need to deltify it.
*/
+ if (!entry->in_pack && !entry->delta) {
+ unsigned char *map;
+ unsigned long mapsize;
+ map = map_sha1_file(entry->sha1, &mapsize);
+ if (map && !legacy_loose_object(map)) {
+ /* We can copy straight into the pack file */
+ sha1write(f, map, mapsize);
+ munmap(map, mapsize);
+ written++;
+ reused++;
+ return mapsize;
+ }
+ if (map)
+ munmap(map, mapsize);
+ }
+
if (! to_reuse) {
buf = read_sha1_file(entry->sha1, type, &size);
if (!buf)