git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] fetch: reject a negative --jobs

From
Patrick Steinhardt <ps@pks.im>
Date
Dec 3, 2026, 09:56 UTC
Message-ID
<axE8uP_wHC4p70YC@pks.im>
In-Reply-To
<20261202171328.805150-3-agab0323@gmail.com>
On Wed, Dec 02, 2026 at 10:43:28PM +0530, Abhishek Agarwal wrote:
Show 36 quoted lines
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 533fdfe7d8..12140f6a87 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -207,6 +207,19 @@ static int parse_refmap_arg(const struct option *opt, const char *arg, int unset
>  	return 0;
>  }
>  
> +static int parse_jobs_cb(const struct option *opt, const char *arg, int unset)
> +{
> +	int *jobs = opt->value;
> +
> +	if (unset)
> +		*jobs = 0;
> +	else if (!git_parse_int(arg, jobs))
> +		return error(_("invalid value for '%s': '%s'"), "--jobs", arg);
> +	else if (*jobs < 0)
> +		return error(_("'%s' cannot be negative"), "--jobs");
> +	return 0;
> +}
> +
>  static void unlock_pack(unsigned int flags)
>  {
>  	if (gtransport)
> @@ -2555,8 +2568,9 @@ int cmd_fetch(int argc,
>  			    N_("fetch all tags and associated objects"), TAGS_SET),
>  		OPT_SET_INT('n', NULL, &tags,
>  			    N_("do not fetch all tags (--no-tags)"), TAGS_UNSET),
> -		OPT_INTEGER('j', "jobs", &max_jobs,
> -			    N_("number of submodules fetched in parallel")),
> +		OPT_CALLBACK('j', "jobs", &max_jobs, N_("n"),
> +			     N_("number of submodules fetched in parallel"),
> +			     parse_jobs_cb),
>  		OPT_BOOL(0, "prefetch", &prefetch,
>  			 N_("modify the refspec to place all refs within refs/prefetch/")),
>  		OPT_BOOL('p', "prune", &prune,

And this is essentially the equivalent change, just for git-fetch(1). The same suggestion as for git-clone(1) applies here of course.

Overall, these changes look good to me though, thanks!
Patrick
Previous: Abhishek Agarwal
Message 5 of 5 in “clone, fetch: reject a negative --jobs”
  1. 0/2 clone, fetch: reject a negative --jobsAbhishek Agarwal, Dec 2, 2026
  2. 1/2 clone: reject a negative --jobs before cloningAbhishek Agarwal, Dec 2, 2026
  3. Patrick SteinhardtDec 3, 2026
  4. 2/2 fetch: reject a negative --jobsAbhishek Agarwal, Dec 2, 2026
  5. Patrick SteinhardtDec 3, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.