{"thread":{"id":"12055","subject":"[PATCH 2/2] pack-objects: Use git_config_magic_int()","startedAt":"2008-02-12T08:23:59Z","lastAt":"2008-02-12T08:23:59Z","messageCount":1,"participants":["Andreas Ericsson"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"68497","messageId":"47B1579F.8030407@op5.se","threadId":"12055","inReplyTo":"1202804110-3715-1-git-send-email-ae@op5.se","subject":"[PATCH 2/2] pack-objects: Use git_config_magic_int()","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-02-12T08:23:59Z","receivedAt":"2008-02-12T08:23:59Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"This lets users specify \"auto\" as a valid parameter to --threads\nand pack.threads instead of having to remember what the magic\nnumber 0 actually meant. 0 still works. This is just a nicer way\nof saying it.\n\nSigned-off-by: Andreas Ericsson <ae@op5.se>\n---\n Documentation/config.txt           |    4 ++--\n Documentation/git-pack-objects.txt |    4 ++--\n builtin-pack-objects.c             |   16 ++++++++++------\n 3 files changed, 14 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex e9f26ed..398c6e0 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -756,8 +756,8 @@ pack.threads::\n \twarning. This is meant to reduce packing time on multiprocessor\n \tmachines. The required amount of memory for the delta search window\n \tis however multiplied by the number of threads.\n-\tSpecifying 0 will cause git to auto-detect the number of CPU's\n-\tand set the number of threads accordingly.\n+\tSpecifying 'auto' or 0 will cause git to auto-detect the number\n+\tof CPU's and set the number of threads accordingly.\n \n pack.indexVersion::\n \tSpecify the default pack index version.  Valid values are 1 for\ndiff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt\nindex 5c1bd3b..e4b6fe9 100644\n--- a/Documentation/git-pack-objects.txt\n+++ b/Documentation/git-pack-objects.txt\n@@ -177,8 +177,8 @@ base-name::\n \tThis is meant to reduce packing time on multiprocessor machines.\n \tThe required amount of memory for the delta search window is\n \thowever multiplied by the number of threads.\n-\tSpecifying 0 will cause git to auto-detect the number of CPU's\n-\tand set the number of threads accordingly.\n+\tSpecifying 'auto' or 0 will cause git to auto-detect the number\n+\tof CPU's and set the number of threads accordingly.\n \n --index-version=<version>[,<offset>]::\n \tThis is intended to be used by the test suite only. It allows\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex a7ffb53..be04829 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -1857,7 +1857,7 @@ static int git_pack_config(const char *k, const char *v)\n \t\treturn 0;\n \t}\n \tif (!strcmp(k, \"pack.threads\")) {\n-\t\tdelta_search_threads = git_config_int(k, v);\n+\t\tdelta_search_threads = git_config_magic_int(k, v, \"auto\", 0);\n \t\tif (delta_search_threads < 0)\n \t\t\tdie(\"invalid number of threads specified (%d)\",\n \t\t\t    delta_search_threads);\n@@ -2128,11 +2128,15 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \t\t\tcontinue;\n \t\t}\n \t\tif (!prefixcmp(arg, \"--threads=\")) {\n-\t\t\tchar *end;\n-\t\t\tdelta_search_threads = strtoul(arg+10, &end, 0);\n-\n-\t\t\tif (!arg[10] || *end || delta_search_threads < 0)\n-\t\t\t\tusage(pack_usage);\n+\t\t\tif (!strcasecmp(arg+10, \"auto\"))\n+\t\t\t\tdelta_search_threads = 0;\n+\t\t\telse {\n+\t\t\t\tchar *end;\n+\t\t\t\tdelta_search_threads = strtoul(arg+10, &end, 0);\n+\n+\t\t\t\tif (!arg[10] || *end || delta_search_threads < 0)\n+\t\t\t\t\tusage(pack_usage);\n+\t\t\t}\n #ifndef THREADED_DELTA_SEARCH\n \t\t\tif (delta_search_threads > 1)\n \t\t\t\twarning(\"no threads support, \"\n-- \n1.5.4.rc5.11.g0eab8\n"}]}