]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch: choose a sensible default with --jobs=0 again
authorMatthias Aßhauer <mha1993@live.de>
Mon, 20 Feb 2023 21:33:25 +0000 (21:33 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Feb 2023 20:09:40 +0000 (12:09 -0800)
prior to 51243f9 (run-command API: don't fall back on online_cpus(),
2022-10-12) `git fetch --multiple --jobs=0` would choose some default amount
of jobs, similar to `git -c fetch.parallel=0 fetch --multiple`. While our
documentation only ever promised that `fetch.parallel` would fall back to a
"sensible default", it makes sense to do the same for `--jobs`. So fall back
to online_cpus() and not BUG() out.

This fixes https://github.com/git-for-windows/git/issues/4302

Reported-by: Drew Noakes <drnoakes@microsoft.com>
Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
t/t5514-fetch-multiple.sh

index a21ce89312da93e9689215b8bc28b7428852dd87..a09606b472622c133a683513ffdbe184952f2b01 100644 (file)
@@ -2196,6 +2196,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
        if (dry_run)
                write_fetch_head = 0;
 
+       if (!max_jobs)
+               max_jobs = online_cpus();
+
        if (!git_config_get_string_tmp("fetch.bundleuri", &bundle_uri) &&
            fetch_bundle_uri(the_repository, bundle_uri, NULL))
                warning(_("failed to fetch bundles from '%s'"), bundle_uri);
index 511ba3bd454808943c73298c7c8f44a0b5bb9c7a..54f422ced3241870a40da6714c34564abab7c119 100755 (executable)
@@ -197,4 +197,9 @@ test_expect_success 'parallel' '
        test_i18ngrep "could not fetch .two.*128" err
 '
 
+test_expect_success 'git fetch --multiple --jobs=0 picks a default' '
+       (cd test &&
+        git fetch --multiple --jobs=0)
+'
+
 test_done