In the review of aa/submodule-update-jobs [1], Junio pointed out that
"git clone --recurse-submodules --jobs=-1" is ignored without a word,
because clone uses -1 to mean "not given" and does not pass it on,
while "--jobs=-2" is passed on and only rejected by "submodule update"
after the clone is done. He wondered if "fetch" has a similar issue.
It does: "git fetch" and "git pull" treat any negative "--jobs" as if
the option was not given.
These two patches make both commands reject a negative value while
the command line is parsed, with the same message "submodule update"
now gives. The series is built on top of aa/submodule-update-jobs,
because the first patch adds its test next to the tests from that
topic.
Two things I was not sure about:
- Both patches add the same small callback. I kept a copy in each
command so that the two stay independent, but I can move it to
parse-options-cb.c if that is preferred.
- "git hook run -j-1" uses -1 to mean "all CPUs" (495b7d54dc). I did
not do that here, because the configuration variables clone and
fetch fall back to (submodule.fetchJobs and fetch.parallel) reject
negative values and use 0 for "all CPUs", and so does "submodule
update --jobs" after the topic above.
[1] https://lore.kernel.org/git/xmqq…@gitster.g/
Abhishek Agarwal (2):
clone: reject a negative --jobs before cloning
fetch: reject a negative --jobs
builtin/clone.c | 18 ++++++++++++++++--
builtin/fetch.c | 18 ++++++++++++++++--
t/t5514-fetch-multiple.sh | 8 ++++++++
t/t7406-submodule-update.sh | 10 ++++++++++
4 files changed, 50 insertions(+), 4 deletions(-)
base-commit: 5d6ad3960bf5d6e577b706d8c642429b504b065d
--
2.56.0