pack-objects: Use git_config_magic_int()
PATCH 2/2 pack-objects: Use git_config_magic_int()
In reply to a message not in the archiveThis 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.
---
Documentation/config.txt | 4 ++-- Documentation/git-pack-objects.txt | 4 ++-- builtin-pack-objects.c | 16 ++++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-)
Documentation/config.txt +0 -0
@@ -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
Documentation/git-pack-objects.txt +0 -0
@@ -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
builtin-pack-objects.c +0 -0
@@ -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, "
Signature · 1 line
1.5.4.rc5.11.g0eab8