[PATCH 2/2] pack-objects: Use git_config_magic_int()
From: Andreas Ericsson <hidden>
Date: 2016-06-15 22:44:13
Subsystem:
documentation, the rest · Maintainers:
Jonathan Corbet, Linus Torvalds
This lets users specify "auto" as a valid parameter to --threads and pack.threads instead of having to remember what the magic number 0 actually meant. 0 still works. This is just a nicer way of saying it. Signed-off-by: Andreas Ericsson <redacted> --- Documentation/config.txt | 4 ++-- Documentation/git-pack-objects.txt | 4 ++-- builtin-pack-objects.c | 16 ++++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index e9f26ed..398c6e0 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt@@ -756,8 +756,8 @@ pack.threads:: warning. This is meant to reduce packing time on multiprocessor machines. The required amount of memory for the delta search window is however multiplied by the number of threads. - Specifying 0 will cause git to auto-detect the number of CPU's - and set the number of threads accordingly. + Specifying 'auto' or 0 will cause git to auto-detect the number + of CPU's and set the number of threads accordingly. pack.indexVersion:: Specify the default pack index version. Valid values are 1 for
diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt
index 5c1bd3b..e4b6fe9 100644
--- a/Documentation/git-pack-objects.txt
+++ b/Documentation/git-pack-objects.txt@@ -177,8 +177,8 @@ base-name:: This is meant to reduce packing time on multiprocessor machines. The required amount of memory for the delta search window is however multiplied by the number of threads. - Specifying 0 will cause git to auto-detect the number of CPU's - and set the number of threads accordingly. + Specifying 'auto' or 0 will cause git to auto-detect the number + of CPU's and set the number of threads accordingly. --index-version=<version>[,<offset>]:: This is intended to be used by the test suite only. It allows
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index a7ffb53..be04829 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c@@ -1857,7 +1857,7 @@ static int git_pack_config(const char *k, const char *v) return 0; } if (!strcmp(k, "pack.threads")) { - delta_search_threads = git_config_int(k, v); + delta_search_threads = git_config_magic_int(k, v, "auto", 0); if (delta_search_threads < 0) die("invalid number of threads specified (%d)", delta_search_threads);
@@ -2128,11 +2128,15 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) continue; } if (!prefixcmp(arg, "--threads=")) { - char *end; - delta_search_threads = strtoul(arg+10, &end, 0); - - if (!arg[10] || *end || delta_search_threads < 0) - usage(pack_usage); + if (!strcasecmp(arg+10, "auto")) + delta_search_threads = 0; + else { + char *end; + delta_search_threads = strtoul(arg+10, &end, 0); + + if (!arg[10] || *end || delta_search_threads < 0) + usage(pack_usage); + } #ifndef THREADED_DELTA_SEARCH if (delta_search_threads > 1) warning("no threads support, "
--
1.5.4.rc5.11.g0eab8