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>
Junio C Hamano committed
Jul 17, 2006 at 15:06 UTC
ceec1361ebbc4613813ba42976503f5e304cfacf
1 file changed
+16
pack-objects.c
+16
@@ -269,6 +269,22 @@ static unsigned long write_object(struct sha1file *f,
269
* and we do not need to deltify it.
270
*/
271
272
+ if (!entry->in_pack && !entry->delta) {
273
+ unsigned char *map;
274
+ unsigned long mapsize;
275
+ map = map_sha1_file(entry->sha1, &mapsize);
276
+ if (map && !legacy_loose_object(map)) {
277
+ /* We can copy straight into the pack file */
278
+ sha1write(f, map, mapsize);
279
+ munmap(map, mapsize);
280
+ written++;
281
+ reused++;
282
+ return mapsize;
283
+ }
284
+ if (map)
285
+ munmap(map, mapsize);
286
+ }
287
+
288
if (! to_reuse) {
289
buf = read_sha1_file(entry->sha1, type, &size);
290
if (!buf)