Skip to content

Commit

Permalink
pack-objects: reuse deflated data from new-style loose objects.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Jul 25, 2006
1 parent bb6b8e4 commit ceec136
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ceec136

Please sign in to comment.