repack: add delta-islands support

Implement simple support for --delta-islands option and repack.useDeltaIslands config variable in git repack. This allows users to setup delta islands in their config and get the benefit of less disk usage while cloning and fetching is still quite fast and not much more CPU intensive. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Aug 16, 2018 at 08:13 UTC 16d75fa48d535ae3f19b221638989cac955f42fb
3 files changed +18
Documentation/config.txt
+4
@@ -3145,6 +3145,10 @@ repack.packKeptObjects::
3145 index is being written (either via `--write-bitmap-index` or
3146 `repack.writeBitmaps`).
3147
3148 +repack.useDeltaIslands::
3149 + If set to true, makes `git repack` act as if `--delta-islands`
3150 + was passed. Defaults to `false`.
3151 +
3152 repack.writeBitmaps::
3153 When true, git will write a bitmap index when packing all
3154 objects to disk (e.g., when `git repack -a` is run). This
Documentation/git-repack.txt
+5
@@ -155,6 +155,11 @@ depth is 4095.
155 being removed. In addition, any unreachable loose objects will
156 be packed (and their loose counterparts removed).
157
158 +-i::
159 +--delta-islands::
160 + Pass the `--delta-islands` option to `git-pack-objects`, see
161 + linkgit:git-pack-objects[1].
162 +
163 Configuration
164 -------------
165
builtin/repack.c
+9
@@ -12,6 +12,7 @@
12 static int delta_base_offset = 1;
13 static int pack_kept_objects = -1;
14 static int write_bitmaps;
15 +static int use_delta_islands;
16 static char *packdir, *packtmp;
17
18 static const char *const git_repack_usage[] = {
@@ -40,6 +41,10 @@ static int repack_config(const char *var, const char *value, void *cb)
41 write_bitmaps = git_config_bool(var, value);
42 return 0;
43 }
44 + if (!strcmp(var, "repack.usedeltaislands")) {
45 + use_delta_islands = git_config_bool(var, value);
46 + return 0;
47 + }
48 return git_default_config(var, value, cb);
49 }
50
@@ -194,6 +199,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
199 N_("pass --local to git-pack-objects")),
200 OPT_BOOL('b', "write-bitmap-index", &write_bitmaps,
201 N_("write bitmap index")),
202 + OPT_BOOL('i', "delta-islands", &use_delta_islands,
203 + N_("pass --delta-islands to git-pack-objects")),
204 OPT_STRING(0, "unpack-unreachable", &unpack_unreachable, N_("approxidate"),
205 N_("with -A, do not loosen objects older than this")),
206 OPT_BOOL('k', "keep-unreachable", &keep_unreachable,
@@ -267,6 +274,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
274 argv_array_pushf(&cmd.args, "--no-reuse-object");
275 if (write_bitmaps)
276 argv_array_push(&cmd.args, "--write-bitmap-index");
277 + if (use_delta_islands)
278 + argv_array_push(&cmd.args, "--delta-islands");
279
280 if (pack_everything & ALL_INTO_ONE) {
281 get_non_kept_pack_filenames(&existing_packs, &keep_pack_list);