fetch: choose a sensible default with --jobs=0 again

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>

Matthias Aßhauer committed Feb 20, 2023 at 21:33 UTC c39952b925ccf59e49f3c174861a862dc1721492
2 files changed +8
builtin/fetch.c
+3
@@ -2196,6 +2196,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2196 if (dry_run)
2197 write_fetch_head = 0;
2198
2199 + if (!max_jobs)
2200 + max_jobs = online_cpus();
2201 +
2202 if (!git_config_get_string_tmp("fetch.bundleuri", &bundle_uri) &&
2203 fetch_bundle_uri(the_repository, bundle_uri, NULL))
2204 warning(_("failed to fetch bundles from '%s'"), bundle_uri);
t/t5514-fetch-multiple.sh
+5
@@ -197,4 +197,9 @@ test_expect_success 'parallel' '
197 test_i18ngrep "could not fetch .two.*128" err
198 '
199
200 +test_expect_success 'git fetch --multiple --jobs=0 picks a default' '
201 + (cd test &&
202 + git fetch --multiple --jobs=0)
203 +'
204 +
205 test_done