@matheusbsbs / matheus-bagliano / commits / fa736f72b0
Fork 0

allow for undeltified objects not to be reused

Currently non deltified object data is always reused when possible. This means that any change to core.compression has no effect on those objects as they don't get recompressed when repacking them. Let's add a --no-reuse-object flag to git-repack in order to force recompression of all objects when desired. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Nicolas Pitre committed May 9, 2007 at 12:31 UTC fa736f72b0840950e32dfd8bc470e91831107b10
2 files changed +21 -8
Documentation/git-pack-objects.txt
+7
@@ -127,6 +127,13 @@ base-name::
127 This flag tells the command not to reuse existing deltas
128 but compute them from scratch.
129
130 +--no-reuse-object::
131 + This flag tells the command not to reuse existing object data at all,
132 + including non deltified object, forcing recompression of everything.
133 + This implies --no-reuse-delta. Useful only in the obscur case where
134 + wholesale enforcement of a different compression level on the
135 + packed data is desired.
136 +
137 --delta-base-offset::
138 A packed archive can express base object of a delta as
139 either 20-byte object name or as an offset in the
builtin-pack-objects.c
+14 -8
@@ -17,9 +17,9 @@
17 static const char pack_usage[] = "\
18 git-pack-objects [{ -q | --progress | --all-progress }] \n\
19 [--local] [--incremental] [--window=N] [--depth=N] \n\
20 - [--no-reuse-delta] [--delta-base-offset] [--non-empty] \n\
21 - [--revs [--unpacked | --all]*] [--reflog] [--stdout | base-name] \n\
22 - [<ref-list | <object-list]";
20 + [--no-reuse-delta] [--no-reuse-object] [--delta-base-offset] \n\
21 + [--non-empty] [--revs [--unpacked | --all]*] [--reflog] \n\
22 + [--stdout | base-name] [<ref-list | <object-list]";
23
24 struct object_entry {
25 unsigned char sha1[20];
@@ -55,7 +55,7 @@ static struct object_entry *objects;
55 static uint32_t nr_objects, nr_alloc, nr_result;
56
57 static int non_empty;
58 -static int no_reuse_delta;
58 +static int no_reuse_delta, no_reuse_object;
59 static int local;
60 static int incremental;
61 static int allow_ofs_delta;
@@ -412,7 +412,9 @@ static unsigned long write_object(struct sha1file *f,
412 crc32_begin(f);
413
414 obj_type = entry->type;
415 - if (! entry->in_pack)
415 + if (no_reuse_object)
416 + to_reuse = 0; /* explicit */
417 + else if (!entry->in_pack)
418 to_reuse = 0; /* can't reuse what we don't have */
419 else if (obj_type == OBJ_REF_DELTA || obj_type == OBJ_OFS_DELTA)
420 to_reuse = 1; /* check_object() decided it for us */
@@ -425,7 +427,7 @@ static unsigned long write_object(struct sha1file *f,
427 * and we do not need to deltify it.
428 */
429
428 - if (!entry->in_pack && !entry->delta) {
430 + if (!no_reuse_object && !entry->in_pack && !entry->delta) {
431 unsigned char *map;
432 unsigned long mapsize;
433 map = map_sha1_file(entry->sha1, &mapsize);
@@ -1125,8 +1127,8 @@ static void check_object(struct object_entry *entry)
1127 buf = use_pack(p, &w_curs, entry->in_pack_offset, &avail);
1128
1129 /*
1128 - * We want in_pack_type even if we do not reuse delta.
1129 - * There is no point not reusing non-delta representations.
1130 + * We want in_pack_type even if we do not reuse delta
1131 + * since non-delta representations could still be reused.
1132 */
1133 used = unpack_object_header_gently(buf, avail,
1134 &entry->in_pack_type,
@@ -1655,6 +1657,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
1657 no_reuse_delta = 1;
1658 continue;
1659 }
1660 + if (!strcmp("--no-reuse-object", arg)) {
1661 + no_reuse_object = no_reuse_delta = 1;
1662 + continue;
1663 + }
1664 if (!strcmp("--delta-base-offset", arg)) {
1665 allow_ofs_delta = 1;
1666 continue;