repack: accept --threads=<n> and pass it down to pack-objects

We already do so for --window=<n> and --depth=<n>; this will help when the user wants to force --threads=1 for reproducible testing without getting affected by racing multiple threads. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Apr 27, 2017 at 08:09 UTC 40bcf3188a6f02acba94587593124ccca5a37e2b
2 files changed +9 -1
Documentation/git-repack.txt
+4 -1
@@ -9,7 +9,7 @@ git-repack - Pack unpacked objects in a repository
9 SYNOPSIS
10 --------
11 [verse]
12 -'git repack' [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [-b] [--window=<n>] [--depth=<n>]
12 +'git repack' [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [-b] [--window=<n>] [--depth=<n>] [--threads=<n>]
13
14 DESCRIPTION
15 -----------
@@ -92,6 +92,9 @@ other objects in that pack they already have locally.
92 to be applied that many times to get to the necessary object.
93 The default value for --window is 10 and --depth is 50.
94
95 +--threads=<n>::
96 + This option is passed through to `git pack-objects`.
97 +
98 --window-memory=<n>::
99 This option provides an additional limit on top of `--window`;
100 the window size will dynamically scale down so as to not take
builtin/repack.c
+5
@@ -155,6 +155,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
155 int keep_unreachable = 0;
156 const char *window = NULL, *window_memory = NULL;
157 const char *depth = NULL;
158 + const char *threads = NULL;
159 const char *max_pack_size = NULL;
160 int no_reuse_delta = 0, no_reuse_object = 0;
161 int no_update_server_info = 0;
@@ -190,6 +191,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
191 N_("same as the above, but limit memory size instead of entries count")),
192 OPT_STRING(0, "depth", &depth, N_("n"),
193 N_("limits the maximum delta depth")),
194 + OPT_STRING(0, "threads", &threads, N_("n"),
195 + N_("limits the maximum number of threads")),
196 OPT_STRING(0, "max-pack-size", &max_pack_size, N_("bytes"),
197 N_("maximum size of each packfile")),
198 OPT_BOOL(0, "pack-kept-objects", &pack_kept_objects,
@@ -234,6 +237,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
237 argv_array_pushf(&cmd.args, "--window-memory=%s", window_memory);
238 if (depth)
239 argv_array_pushf(&cmd.args, "--depth=%s", depth);
240 + if (threads)
241 + argv_array_pushf(&cmd.args, "--threads=%s", threads);
242 if (max_pack_size)
243 argv_array_pushf(&cmd.args, "--max-pack-size=%s", max_pack_size);
244 if (no_reuse_delta)