From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.182 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== 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== 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 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 ; Wed, 2 Dec 2026 17:15:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 74498606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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 Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-cde0daf3a2aso5876464a12.3 for ; Wed, 02 Dec 2026 09:15:25 -0800 (PST) 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+NjIDisfH6UVU66itbV3LCSG4=; b=QWsW3T4xf4s1+g1CwqGbkZs2w0EuagC7XwxcOe7tpvk/ZOiWnrftADveKFleZQTdIv yWiv9ELZH2VFaXxkn//w00AneQIQw30IcUYW28DPRg11Zc3PcUm5sP2ylXMs+El9ZmzT GY2JPmlSx5H2i4FmIJ19u2HnD5vQU4gzzHc7Hz4403qegJl7Lvli0cjKh1W/vJI3O7zG exzYEpNc/u+MpAZWrA2lGiMLlKvOH9pTWmTnnRPJMzIPGze0YeqiLkHhBJOS/n6uTDub nbWWKBZsgmEBSehwMd79y40bfmFrCkXlyGOtDYk/b48M6yYhUrX/0XuWLOhfJeVhNtIh 3azw== X-Gm-Message-State: APuU4Z9nZqD6RiBQ4prv0NFnDC6zgwAhZa3nsyts5s3YjoF/YmTCYcZb wn731n3T1FGIT31YnCuWtTmAv5jWKkefI0wPSR2QShENrU1HW0iiiVVHsVHTqmRsFXk= X-Gm-Gg: AZFdTZcIRCRFoXpuiXw7QYHg/+4CV9Z6CbN2gO7FJBvISgHDFSugdpAd4s4Ultz8/i8 TAohVPg4KsTeOMtRI5PmtPnGvv+9YfTywG8v8R6hbvevtDJ4G9YjM78OF7SKFD7qETMTrLtaqUa TCb2lDZg1WwuBV8TrD4aAlO6N/6Y6stL4x3jpcsA2G5Wsb0yeHORFDgCdXaAdI4Ay1XL23tfImY 2Ao2zUXJPaVeKKzGiWwTL95/WB1WHdlYa3AxT/f9QPwL42QDD+0lsxLvyN0sj7QlLNXdu6cQW61 0MePq54KoMYsTYGYkIDCxPH9VkcXCGFiH7xNLWoToDpqTltA5Kj4bZdQQfmcFsa1/zSx4pfDDQW wI3+qlhUPmvX3Z4BVUWFUK726kGT2sN4lgZ139NryaZ0lNwSJY+6pY5GfCnuAyraFAezl2Q5+Eu gYNqNycemtgprkUp/Jq0YXNh3cb6y+r0kmQQojaygwwRqOCdUfQxPctea1hY2OmuR8Z52g1ZA0S qHhCjCgzlwhhPpuGLHge5tgN/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) 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) From: Abhishek Agarwal To: git@vger.kernel.org Cc: Junio C Hamano , Patrick Steinhardt , Jacob Keller , Adrian Ratiu Subject: [PATCH 1/2] clone: reject a negative --jobs before cloning Date: Wed, 2 Dec 2026 22:43:27 +0530 Message-ID: <20261202171328.805150-2-agab0323@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261202171328.805150-1-agab0323@gmail.com> References: <20261202171328.805150-1-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-Transfer-Encoding: 8bit "git clone --recurse-submodules --jobs=" passes "--jobs=" on to "git submodule update", but only when 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 Signed-off-by: Abhishek Agarwal --- 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