{"thread":{"id":"8056","subject":"[PATCH] allow for undeltified objects not to be reused","startedAt":"2007-05-09T16:31:28Z","lastAt":"2007-05-09T16:31:28Z","messageCount":1,"participants":["Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"41620","messageId":"alpine.LFD.0.99.0705091219240.24220@xanadu.home","threadId":"8056","inReplyTo":null,"subject":"[PATCH] allow for undeltified objects not to be reused","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-05-09T16:31:28Z","receivedAt":"2007-05-09T16:31:28Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"Currently non deltified object data is always reused when possible.  \nThis means that any change to core.compression has no effect on those\nobjects as they don't get recompressed when repacking them.\n\nLet's add a --no-reuse-object flag to git-repack in order to force \nrecompression of all objects when desired.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\ndiff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt\nindex bd3ee45..ce89214 100644\n--- a/Documentation/git-pack-objects.txt\n+++ b/Documentation/git-pack-objects.txt\n@@ -127,6 +127,13 @@ base-name::\n \tThis flag tells the command not to reuse existing deltas\n \tbut compute them from scratch.\n \n+--no-reuse-object::\n+\tThis flag tells the command not to reuse existing object data at all,\n+\tincluding non deltified object, forcing recompression of everything.\n+\tThis implies --no-reuse-delta. Useful only in the obscur case where\n+\twholesale enforcement of a different compression level on the\n+\tpacked data is desired.\n+\n --delta-base-offset::\n \tA packed archive can express base object of a delta as\n \teither 20-byte object name or as an offset in the\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 966f843..d94c79a 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -17,9 +17,9 @@\n static const char pack_usage[] = \"\\\n git-pack-objects [{ -q | --progress | --all-progress }] \\n\\\n \t[--local] [--incremental] [--window=N] [--depth=N] \\n\\\n-\t[--no-reuse-delta] [--delta-base-offset] [--non-empty] \\n\\\n-\t[--revs [--unpacked | --all]*] [--reflog] [--stdout | base-name] \\n\\\n-\t[<ref-list | <object-list]\";\n+\t[--no-reuse-delta] [--no-reuse-object] [--delta-base-offset] \\n\\\n+\t[--non-empty] [--revs [--unpacked | --all]*] [--reflog] \\n\\\n+\t[--stdout | base-name] [<ref-list | <object-list]\";\n \n struct object_entry {\n \tunsigned char sha1[20];\n@@ -55,7 +55,7 @@ static struct object_entry *objects;\n static uint32_t nr_objects, nr_alloc, nr_result;\n \n static int non_empty;\n-static int no_reuse_delta;\n+static int no_reuse_delta, no_reuse_object;\n static int local;\n static int incremental;\n static int allow_ofs_delta;\n@@ -412,7 +412,9 @@ static unsigned long write_object(struct sha1file *f,\n \t\tcrc32_begin(f);\n \n \tobj_type = entry->type;\n-\tif (! entry->in_pack)\n+\tif (no_reuse_object)\n+\t\tto_reuse = 0;\t/* explicit */\n+\telse if (!entry->in_pack)\n \t\tto_reuse = 0;\t/* can't reuse what we don't have */\n \telse if (obj_type == OBJ_REF_DELTA || obj_type == OBJ_OFS_DELTA)\n \t\tto_reuse = 1;\t/* check_object() decided it for us */\n@@ -425,7 +427,7 @@ static unsigned long write_object(struct sha1file *f,\n \t\t\t\t * and we do not need to deltify it.\n \t\t\t\t */\n \n-\tif (!entry->in_pack && !entry->delta) {\n+\tif (!no_reuse_object && !entry->in_pack && !entry->delta) {\n \t\tunsigned char *map;\n \t\tunsigned long mapsize;\n \t\tmap = map_sha1_file(entry->sha1, &mapsize);\n@@ -1125,8 +1127,8 @@ static void check_object(struct object_entry *entry)\n \t\tbuf = use_pack(p, &w_curs, entry->in_pack_offset, &avail);\n \n \t\t/*\n-\t\t * We want in_pack_type even if we do not reuse delta.\n-\t\t * There is no point not reusing non-delta representations.\n+\t\t * We want in_pack_type even if we do not reuse delta\n+\t\t * since non-delta representations could still be reused.\n \t\t */\n \t\tused = unpack_object_header_gently(buf, avail,\n \t\t\t\t\t\t   &entry->in_pack_type,\n@@ -1655,6 +1657,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \t\t\tno_reuse_delta = 1;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(\"--no-reuse-object\", arg)) {\n+\t\t\tno_reuse_object = no_reuse_delta = 1;\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(\"--delta-base-offset\", arg)) {\n \t\t\tallow_ofs_delta = 1;\n \t\t\tcontinue;\n"}]}