From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.144 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796291770; b=bbFEPBxjHKzhh390mm5OQsjalLWCMt5+r3obq8/363OAPSsJDpuMMHYbA5JFHcjKdbuy icYFBkWW2jcwr8Y29upOQOFkac71kkn+Y49MRL++yXI8sRntJ4VO5mdNgm7ILE6TASk0M 2AsAFDAO2weDvIR2O7sf1K8p/vFSEdDjLbJkhHuzOjGKQW80I5Hl8nmJ5JnvChbgYfBMF CaICj4ytLUCgykDkEn6e79tKQVWKApJVDywCE9CfSXGSYvGI1TsnIKDVyrTqGuEY0/GAW BeQOKn+h+UIW0+ZJqc1+/4Ueks1YXO9iYJnNpJc14bTTl0oUGPkUn5b2JdZoPJaFdkw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796291770; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=0j1FeSr/C1viwpoBESzow26y6c4yVLwdkc+NyUa/jYw=; b=B5PraNMFXJ/apMW4B1JUAgMhS2SRElMkuEzLzxLhT7nlsXEHkjFrgUTUxzOek4lNYKwE sg1gZNt1y6/zrACUeWJBeFYuOXa6aH3Fv+bztaR1LVB8HlJJ2/5PEHoNr3bERxuLfp8Yf D6EjdM//IvybPH+10IG81QZ95f1updafKu0tISqiDYeIBKr4cY3igynY6hFkjRBhuAv+r HG6CEf/IstfH16cmnKrX/xw6WGCAdTl27+quuso7tqUSbUSCx1usiXeRRpZVVCDV4s0Th aZ6SNl2K5q7XW5uH8cIY2OP1IUrYx8FjUGjCAFCg5XblOTwOVim7M+dEoc/afgqdOvA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=tV1ixcxR; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=wEXBoVXf; arc=none smtp.remote-ip=202.12.124.144 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40547606A322 for ; Thu, 3 Dec 2026 09:56:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 40547606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=tV1ixcxR; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=wEXBoVXf Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 812E21D001ED for ; Thu, 3 Dec 2026 04:56:09 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Thu, 03 Dec 2026 04:56:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1796291769; x=1796378169; bh=0j1FeSr/C1 viwpoBESzow26y6c4yVLwdkc+NyUa/jYw=; b=tV1ixcxRy/PuW87nBwfmCyO4RW nSz22ORHRzzDOzY4mq7tt3khRcWfaYoohPiHJxG5ywiZ0Ewn0yYBnEsBbnObAPOc 3G8Lffi+VDcSdMAMwV+lzWbrGFE1+j6IOOIYykHtWrZh7zi+cR9Ld8mSJSq3G+Yh 3GJamiv9tQPWUfGf7w0BIzaOHFDc5XYjVYC2elI5sCRayKnlxVL0HbJf/naChrq8 SzFAsgyC7yXWlvtgfUlF5idyYJmDl3MeF+LXbLJsuc0e4vTgMtimYrgWJaOwgdVK PT3F92UZmCiZe5unanBHMtVyUIxwIQt4E0ifgZdXVtNYOLCyA3DqXj4nHVSA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1796291769; x=1796378169; bh=0j1FeSr/C1viwpoBESzow26y6c4yVLwdkc+ NyUa/jYw=; b=wEXBoVXfkn+/NNH9tdwCkuvKdfH/rGqXqM2K4Hv5ccCs/r+qryy FKbHWBM8frpQsn+OknjFymZK8TlZphq5Okq2KmaLybXTLPkNjNnpeiOlTipQv6Ab SGiFJOEVMQcavoTE1dymoNl8oAns95PDfuC3x4DghpIT+ABXcim/pF4QSjAXoirW N7EttR3zx2HKwqeW8hPkuMaWBfV1UH+j/E0OzEztfxz9I9yXyE9i15fC4EeIoBpx 3fpL82ZoaKiq5FV2eD3XR0/IKelTgqH4k/tEiKbFiQ8HT7s1XgBkO451uU3bFcQj 0DM95f0EPM8F65lHNEpcuI+KhwjU8op/KEg== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pks.im a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796291769; d=pks.im; mf=PHBzQHBrcy5pbT4=; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:YIf9B4ECrPtaaYKbzdNlMJlDGcDqmlACjjhwWc9AcBJfSkl vOjURvaiAvueQBgFDZ2KmAlpi9TmCOT3d9/Ui2uP4zHZLJokzOywM0ImbTWKTEG2 0ex2SMAKINmZ22ziFoyqae1x91lG3p6niKGN8HiyvSL/o4CW+jg451rimvPuOEGJ OoWU3EzhAQIqrhb1FU/JYQJ4VGzYm/9RWyk4dpNAao2IO28bPa3zrp8P+Mfte7pB bvUwjl7MN2/AP0ZssmT7PcykuWmGn5INfXMjc1HXfXk8HftZ7Vra2Da7o0W3naiR 4AXrE3YcTq/790BOLyNMZyBaLvNzcOsO6KoA7FA==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:q04MiUlkf408Ve8uG77rs2sHF26xTSwE75MvEjND2pc=:+BS+8hf5Eu1ffx7AsaauXQ9HYFGp8kt2LXpmjpyJEwA=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTF+Mos79TaFygWOseWe2F4iAcHagOV9MTGnX/VaovuoGXP73NsU9Dw0sdo1Ts7QG5 60gG7vfuiyccfiRgvNYLIrcQ4MnAYtTGTn0BvIOhlkEBqsIlFh5cyrID/CsjwhbP4NM/C2 sOs7UMNWLdkydwrrPDuEtwNe22yVNTmfVNCTfK1B7+Rur5Svg6FU1Rr8nC3Nn6HS11UndH VvKN17d71b83W7HXjszVYqdl+Ohxaa7Txn4+eqVmF4bVugxUzYeT6Q2cmwWoFqGzb9S9Mm UsywdNutKxft21CkcTrUpXuixuN+1Pal7QP+2WVzOpWXzyDNDEp6M1chYLGyzaDzoQrNWs lK482nLbomMMjoAf4UkWFmZeAiE+Tt4JG0RFGPfI6fNCbxe0tByUNHslnBnyOp8Nb+jxWP 0dgP4LOnUE45JaU3masAm0dc0er0peQkT1qgpbYZJ/5DGLWUmcKzNn9Xw1bJOnT48E7eYJ 0pkX/ECr+mlUGeBnyArFOABBNjcnnUnxFnmCwCXsgkmBK5avyHydekyaAsogf02a2QPLJH FgUHDhs/5ada3LqjE0Rq6j/Eu7/3vmamqYAYHBA36ywzcDm2y7dlG0xfajPyVv7cN2PoqH Fx3hAE8VaXjyqrWmSzIPqRpRd2iwzpQl0Kqt+UXzRqtns969kPqkng6phuOA X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 3 Dec 2026 04:56:08 -0500 (EST) Received: by mail (OpenSMTPD) with ESMTPSA id 800cf0b8 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 3 Dec 2026 09:56:06 +0000 (UTC) Date: Thu, 3 Dec 2026 10:56:03 +0100 From: Patrick Steinhardt To: Abhishek Agarwal Cc: git@vger.kernel.org, Junio C Hamano , Jacob Keller , Adrian Ratiu Subject: Re: [PATCH 1/2] clone: reject a negative --jobs before cloning Message-ID: References: <20261202171328.805150-1-agab0323@gmail.com> <20261202171328.805150-2-agab0323@gmail.com> X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202171328.805150-2-agab0323@gmail.com> On Wed, Dec 02, 2026 at 10:43:27PM +0530, Abhishek Agarwal wrote: > diff --git a/builtin/clone.c b/builtin/clone.c > index ac40250d25..f9ecbede1b 100644 > --- a/builtin/clone.c > +++ b/builtin/clone.c > @@ -94,6 +94,19 @@ static int recurse_submodules_cb(const struct option *opt, > 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 const char *get_repo_path_1(struct strbuf *path, int *is_bundle) > { > static const char *suffix[] = { "/.git", "", ".git/.git", ".git" }; > @@ -949,8 +962,9 @@ int cmd_clone(int argc, > .defval = (intptr_t)".", > }, > OPT_ALIAS(0, "recursive", "recurse-submodules"), > - OPT_INTEGER('j', "jobs", &max_jobs, > - N_("number of submodules cloned in parallel")), > + OPT_CALLBACK('j', "jobs", &max_jobs, N_("n"), > + N_("number of submodules cloned in parallel"), > + parse_jobs_cb), 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. > diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh > index 2b5551044a..7a440709aa 100755 > --- a/t/t7406-submodule-update.sh > +++ b/t/t7406-submodule-update.sh > @@ -1116,6 +1116,16 @@ test_expect_success 'git clone --recurse-submodules --jobs 0 uses the number of > test_grep "up to $(test-tool online-cpus) tasks" trace-jobs.out > ' > > +test_expect_success 'git clone --recurse-submodules rejects a negative --jobs' ' > + test_when_finished "rm -rf super6" && > + for jobs in -1 -2 > + do > + test_must_fail git clone --recurse-submodules --jobs $jobs . super6 2>err && > + test_grep "${SQ}--jobs${SQ} cannot be negative" err && > + test_path_is_missing super6 || return 1 > + done > +' Okay, and here you cover both of the different failure scenarios that you mention in the commit message. Makes sense. Patrick