Article View: linux.kernel.git
Article #4253[PATCH 1/2] clone: reject a negative --jobs before cloning
From: Abhishek Agarwal
Date: Wed, 02 Dec 2026 17:13
Date: Wed, 02 Dec 2026 17:13
83 lines
13978 bytes
13978 bytes
"git clone --recurse-submodules --jobs=<n>" passes "--jobs=<n>" on to
"git submodule update", but only when <n> is not -1, because max_jobs
starts at -1 to mean that the option was not given. So "--jobs=-1" is
dropped without a word and the submodules are fetched with the default
number of jobs, while "--jobs=-2" is passed on and rejected by
"submodule update". That happens only after the superproject has been
cloned, so the user waits for the whole clone and is left with one
whose submodules are not checked out.
Parse the option with a callback that rejects a negative value, like
"git submodule update --jobs" and "submodule.fetchJobs" already do.
The error now comes before anything is cloned, and -1 can again only
mean that the option was not given. "--no-jobs" still means the same
as "--jobs=0". A value that is not a number is still rejected, now
with the "invalid value for" message that other options already use.
Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Abhishek Agarwal <agab0323@gmail.com>
---
builtin/clone.c | 18 ++++++++++++++++--
t/t7406-submodule-update.sh | 10 ++++++++++
2 files changed, 26 insertions(+), 2 deletions(-)
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),
OPT_STRING(0, "template", &option_template, N_("template-directory"),
N_("directory from which templates will be used")),
OPT_STRING_LIST(0, "reference", &option_required_reference, N_("repo"),
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
+'
+
test_expect_success 'submodule update --quiet passes quietness to merge/rebase' '
(cd super &&
test_commit -C rebasing message &&
--
2.56.0
Technical Details
Message-ID:
<20261202171328.805150-2-agab0323@gmail.com>Path:
mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76891-linux-kernel-git=dewy.ruReferences:
<20261202171328.805150-1-agab0323@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76891-linux-kernel-git=dewy.ru
From: agab0323@gmail.com (Abhishek Agarwal)
Newsgroups: linux.kernel.git
Subject: [PATCH 1/2] clone: reject a negative --jobs before cloning
Date: Wed, 2 Dec 2026 22:43:27 +0530
Organization: Usenet Network
Message-ID: <20261202171328.805150-2-agab0323@gmail.com>
References: <20261202171328.805150-1-agab0323@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2017896"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:1eq6FWz8qo5fxESyrBSTBKGmcUY= sha256:GA8SiXAY8TtAI4ay669FD4LIpXD1fDjSwFdQbFo1HUA=
sha1:Z9/M4M/otV/5DiJ3cdy6mhtM2TI= sha256:QNpahN5aHXF8Qfg+yDoxvaTKpfWdKIUttDmPR8OLaMs=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 6D3AD1176C9; Wed, 2 Dec 2026 20:15:42 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 9gxwwy_BnMcT;
Wed, 2 Dec 2026 20:15:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=git+bounces-76891-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id 18E6A1176C3; Wed, 2 Dec 2026 20:15:30 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sin.lore.kernel.org (Postfix) with ESMTP id 3118D23FFE; Wed, 2 Dec 2026 17:15:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796231726;
b=UOUuGIj/tMfr1b5qnlNCAlOk7g9M3JHMJm9Q4AsWXL9V8RnRbqGY/xG3tblEH6cnwcl/
b/c4zrH4lt0JTzOhagyXasmCzvO+kQQ0FEPa2EOqOLmz1skNIZ0lOfA04VUgTLF7qPLIN
NVB21Mvq/qqJVrlYw5W08X+FtyGBSCjaTgR0J/tUwMv3FOoO2I2iJ7RQ/UkpDfeNBqwX6
UMtYg+PQGkd8i5rqoc+pmQqMhPJyBkmUR76FIpM7UVaGpCjMUsx5WUct9N4vBsr8BIslU
YGN4WvuxV8SnjVSte8BdUpvNyGtgrDBwG7+2yu6KsCB8bhLc8D0jY6AIfH09FQ3Bl4w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796231726;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=F7NcIcdjQ99WUxZ7et+NjIDisfH6UVU66itbV3LCSG4=;
b=ecjBaFVSZNl1zLgcmRjFN0sXRChGluwzEmavrRHU1a3j982DVtpQ0Qr2aEZS08SCLtro
J/KRnGzg/itm28vIKnixLSNXpJHB2X0RdD5LitkaFc4+XuJUT1/G2cyWMxXaWoaLv9Wad
g3CzmaGbFyUEVsy7aIosqUnIozqcR9lh/pYYll7szx7mRlpQ077SgcacJc3XJ0JBg+PG7
HS0Lu+UxOtlVYCeUsU16T7BnrIPiBlYrkuAVjbj0MGQ4ERTd7NdcSric2CYAf/hKRkArC
5JZdLMFG2KYydGPFleCzuadymE4oXohhUE7XGhfpuRGUWFS+umrma5PzAnEequ21VFA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=sPJXxadj;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id AAAA0606A31A;
Wed, 2 Dec 2026 17:15:26 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=sPJXxadj
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.182
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796231725;
b=WugXRHN2Ki5Gure94gW1RXhIWMiqTXEeuyTtJzdLnRP/ri9+vIc5TtjNT0cIArWTvzdN
kRiRLLWW9ZXjTbDTybjqQeKsMSQiidOXzJLuOLhuBDkV9qkyxDZUHcFheD64yKaJX2K86
J3yoixA++247O++2IQP0pXql5Ru8KXJaYUoI9pO4MiALLvKg9KCAfVEaCiTL5bAwX9H71
Peg083tNrISE0NeoaGK8FSh0oeutDOroDDy42DxNpuL3Gt6bT/y7wH5PFl16WwoHAwjmI
NTkBABAX125U8OlY6s2U8F6CUiB7PEHayDABnypLSO/LQfcQbHFPwFSNRQaiHMeJ+ZQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796231725;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=F7NcIcdjQ99WUxZ7et+NjIDisfH6UVU66itbV3LCSG4=;
b=T185JwYAR8wtUPnR62fM7cHnu5+FT+ImT7La4qFR7Wb1uAQ2M4TX6gksNEiGEGJ5JA+q
b0nDNDgtLblxnueH+tQpX+S8U3MNCnLUtPWIvGLv/d60R19dTEQKa19Ij3MMDdDvZPoK8
XaYomO996kmnB0LF/9srn9Fkuszg17TUjPDDZLMffnlb7/P5o4zFXF/VzTFaOkz7xYi/t
NXfy5PYvs5sMvk5GWwI8JUjT0Sjle2jjM6ggqH8/OnKp11Bvz20fN8otNu/T9vP6+FKnn
5zxmjdxIjchCmpp4ASN+BabmfWWaj98BehMdhynnG/PXnXkKzpFxkfwWC98unVGjhDQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=sPJXxadj;
arc=none smtp.remote-ip=209.85.215.182
X-Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74498606A327
for <git@vger.kernel.org>; Wed, 2 Dec 2026 17:15:25 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 74498606A327
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-cde0daf3a2aso5876464a12.3
for <git@vger.kernel.org>; Wed, 02 Dec 2026 09:15:25 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796231724; x=1796836524; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=F7NcIcdjQ99WUxZ7et+NjIDisfH6UVU66itbV3LCSG4=;
b=sPJXxadjQDqj04vVPpT2Bhx7AWsSbaN5xPBntZY/ju+JE7qLJimNnyqaXkt1htsBwQ
JyhARZZweZs+eB0wTMNDnxgg77eQf/EwQUpKj9UXZV60yXFiGO7gzctAVR/mJ0fExhey
u2029hGmQ4QF6TVUHhvLgJL5aJuQfC91pJA3n0AB280VGV01krWsjypwH1XtsuUlhs80
ntgsP4DZnpCDKy4fg7k578S3A3atGBAPsu84ZFnXGjIDc0pYdI6c5f9JyM/ZVOKHOKZY
0B7avEHq+PfU7th1IOtdqAbLoAf+8Oa5ML9jm2E/CbiUKUwj+T1moMwQIe9hwrDn2yHF
cyRA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796231724; x=1796836524;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=F7NcIcdjQ99WUxZ7et+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N/3Raaeq+In3tlFai0ENPCRFwGyGtXw2Dmp074cyCz5DUwswu3X+
szPpAtTVqpsHevgcHd5oM+bCecPbhg==
X-Received: by 2002:a17:90b:3b8f:b0:3b3:b36e:8c3d with SMTP id 98e67ed59e1d1-3b41cb466f4mr38132202a91.62.1796231724432;
Wed, 02 Dec 2026 09:15:24 -0800 (PST)
X-Received: from aeron-host ([103.177.178.109])
by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5c7d7a6b5sm9970a91.14.2026.12.02.09.15.22
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 02 Dec 2026 09:15:24 -0800 (PST)
X-Cc: Junio C Hamano <gitster@pobox.com>,
Patrick Steinhardt <ps@pks.im>,
Jacob Keller <jacob.keller@gmail.com>,
Adrian Ratiu <adrian.ratiu@collabora.com>
X-Mailer: git-send-email 2.56.0
X-In-Reply-To: <20261202171328.805150-1-agab0323@gmail.com>
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list