From: Abhishek Agarwal <agab0323@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Jacob Keller <jacob.keller@gmail.com>,
Adrian Ratiu <adrian.ratiu@collabora.com>
Subject: Re: [PATCH 1/2] clone: reject a negative --jobs before cloning
Date: Sun, 6 Dec 2026 02:22:18 +0530 [thread overview]
Message-ID: <20261205205218.46612-1-agab0323@gmail.com> (raw)
In-Reply-To: <axE8s0A8snwyvyX9@pks.im>
On Thu, Dec 03, 2026 at 10:56:03AM +0100, Patrick Steinhardt wrote:
> Does this really warrant `OPT_CALLBACK()`? Can't we use `OPT_UNSIGNED()`
> instead?
>
> Well, the answer is "not trivially" because of the sentinel value, which
> is "-1". But we could convert `max_jobs` to an unsigned value and use a
> sentinel value of `UINT_MAX`. I don't think anyone would ever configure
> a maximum job count of multiple billions of jobs, so that might be an
> alternative that requires less plumbing overall.
>
> The status quo isn't all that bad either, though, so I'll leave it up to
> you to decide whether you want to take this suggestion.
Thanks for the review.
I tried it. The catch is that the value still ends up in an int:
fetch hands it to fetch_multiple() and fetch_submodules(), and clone
passes it on to "submodule update", whose --jobs is still
OPT_INTEGER(). So a value above INT_MAX gets past OPT_UNSIGNED() and
goes wrong later:
- "git fetch --jobs=3000000000" turns negative in max_children and is
silently replaced by fetch.parallel again. If I compare max_jobs
with UINT_MAX instead, it dies with "data too large to fit into
virtual memory space".
- "git clone --recurse-submodules --jobs=3000000000" clones the
superproject first and is only rejected by "submodule update"
afterwards.
A range check after parse_options() in both commands fixes that, and
the result is still a bit smaller than the callback. But it adds a
message for the range check, and since OPT_UNSIGNED() sets
PARSE_OPT_NONEG, "--no-jobs" (which OPT_INTEGER() parses as 0) would
stop working unless I spell the option out by hand.
The callback accepts the same values as before, except negative ones,
and gives the same message as "submodule update --jobs", so I would
prefer to keep it. If you or Junio prefer the unsigned version, I am
happy to send a v2.
The same goes for 2/2.
Thanks,
Abhishek
next prev parent reply other threads:[~2026-12-05 20:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 17:13 [PATCH 0/2] clone, fetch: reject a negative --jobs Abhishek Agarwal
2026-12-02 17:13 ` [PATCH 1/2] clone: reject a negative --jobs before cloning Abhishek Agarwal
2026-12-03 9:56 ` Patrick Steinhardt
2026-12-05 20:52 ` Abhishek Agarwal [this message]
2026-12-02 17:13 ` [PATCH 2/2] fetch: reject a negative --jobs Abhishek Agarwal
2026-12-03 9:56 ` Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261205205218.46612-1-agab0323@gmail.com \
--to=agab0323@gmail.com \
--cc=adrian.ratiu@collabora.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jacob.keller@gmail.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.