Skip to content

Commit

Permalink
fetch: choose a sensible default with --jobs=0 again
Browse files Browse the repository at this point in the history
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 git-for-windows#4302

Reported-by: Drew Noakes <drnoakes@microsoft.com>
Signed-off-by: Matthias Aßhauer <mha1993@live.de>
  • Loading branch information
rimrul committed Feb 20, 2023
1 parent d9d677b commit daa6afa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions t/t5514-fetch-multiple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit daa6afa

Please sign in to comment.