From patchwork Wed May 17 11:48:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13244762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B884EC77B7F for ; Wed, 17 May 2023 11:48:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230007AbjEQLss (ORCPT ); Wed, 17 May 2023 07:48:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbjEQLsr (ORCPT ); Wed, 17 May 2023 07:48:47 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9806110F7 for ; Wed, 17 May 2023 04:48:46 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 0A1EC32002E2 for ; Wed, 17 May 2023 07:48:45 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 17 May 2023 07:48:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1684324125; x=1684410525; bh=qx VQkp3JR+uYHDSqYll7CZyeq5skhRQVrOjiNidwb54=; b=ReCoM2UR2xJOXVEdNK tzufnTauxhO7/bHBYOomnIKV3EujjUsSQQ22q7/8nVUorb48mmBXq2alvageqI+a BYVoLCI/q26cT6WBa9+90mYzcFk8PfAUJZiTXGZrKx/anrWm2rFe5No/xTqI01fH gHYUAM6cmJIXsrFWETKQaGD21BiT02tBzkpn1j64jsS3hll4mGUf5FNju9kQfJrs DePoMyR7ygz+BvCOrIISNPygjEv+WpWPbnocyMef7b3MKVbS1Ys/xyAnOdlmH3sy o590ILdKI89KbgOcRrBXd+r2Tsk4VUTFOPmB4mURX+YW8e1b1+ImdbtDLe7dGd3D 32EQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684324125; x=1684410525; bh=qxVQkp3JR+uYH DSqYll7CZyeq5skhRQVrOjiNidwb54=; b=ecOYEdUNIoKMUiFv4m4kAKDGS/FbB axhkPuvgS40fqn0wi8uuTTIFYuzSntY/6fzK8OUCxP9y/R5H3rS78glLBQUgLVuA coF/BWkVk4mIulvUa4huDZB/bty1JEvt6Zo/5fCodFLrQ2zv0OrzdrgtuEKyvPJK BLmI1zz6oMDmnrJek+P3kTkh62Ui0xKevU4mCO8W3jWMA/qvelK/LprcsuxQERbI E4CB1tUkNxN+7+o43kAHatQqyF4+02u3fZxr1nH0mVEDRE4sQUesLhtv0lQfPur3 oxTkfng3gncqclkWe7LDWL1z4QEzHvPib1ldWzJgCcRgce0bOZyvoeK3g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeiuddggeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 17 May 2023 07:48:44 -0400 (EDT) Received: by pks.im (OpenSMTPD) with ESMTPSA id 34b74922 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 17 May 2023 11:48:21 +0000 (UTC) Date: Wed, 17 May 2023 13:48:42 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 1/9] fetch: drop unused DISPLAY_FORMAT_UNKNOWN enum value Message-ID: <9417a62e9bbd30d9350b65e5396a31f9cb7c60b6.1684324059.git.ps@pks.im> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org With 50957937f9 (fetch: introduce `display_format` enum, 2023-05-10), a new enumeration was introduced to determine the display format that is to be used by git-fetch(1). The `DISPLAY_FORMAT_UNKNOWN` value isn't ever used though, and neither do we rely on the explicit `0` value for initialization anywhere. Remove the enum value. Signed-off-by: Patrick Steinhardt --- builtin/fetch.c | 1 - 1 file changed, 1 deletion(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 849a9be421..9147b700e5 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -58,7 +58,6 @@ enum { }; enum display_format { - DISPLAY_FORMAT_UNKNOWN = 0, DISPLAY_FORMAT_FULL, DISPLAY_FORMAT_COMPACT, DISPLAY_FORMAT_PORCELAIN, From patchwork Wed May 17 11:48:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13244764 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DAC3C77B7F for ; Wed, 17 May 2023 11:49:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230358AbjEQLtA (ORCPT ); Wed, 17 May 2023 07:49:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbjEQLsv (ORCPT ); Wed, 17 May 2023 07:48:51 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF2D03ABB for ; Wed, 17 May 2023 04:48:49 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 75BB432002B6 for ; Wed, 17 May 2023 07:48:49 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 17 May 2023 07:48:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1684324129; x=1684410529; bh=5V URXlK+z1n1Tqi2pZYvUj61anNYLHP6bt29jF1saOs=; b=myLtH00p2B1lDgoBD9 WMwj+IcRNeH6q4zIP+8vfk0wAx6/BkkndM/cKqjSnrt5deIOfAJnuoMQYid94dS8 Tfc0sadIpxd1Iz+LYOKD8iAlEjcMTGvDNvqDhI+9WDiVXn+oCTFa1kBwyVkq0kNf 7ceEiIXLVSB3exEQa1fTIo1de2bclSiz//Iqo4aVi5yqfbVwE30keWPdCnDh3VTU TcPvmRNYhD8AnJuGUabprmErOScgRlcPsmMxn5/q59v4h1H/kGSQK/HNvSrrRD3t eLa0DNFRD7SBLZ8+QqZPZfDiCTE/882r/bnss4Nqj/Zzd9kKhPxcIKg2DU76KUUc gNgQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684324129; x=1684410529; bh=5VURXlK+z1n1T qi2pZYvUj61anNYLHP6bt29jF1saOs=; b=vxGEVtLrsD5iX3hiDWvfBYghxb6lv LGJMxke7ezniUQsdxFKKgQz0Ws+lo9V447+IEJ8g6vlD/VVR2+CQEA6MxN/xuCsF jFNZf2rWmelCFDtFrvb0UkN2lW56FhWBWaRX5yUhfZU5Rg0qSvv6LZmM6NpLaVGW kbNN0AB99ZWGfS+5QgBb1J/JP3TNbbsoHdpZvlB4JLkPvNUCwaY7XuCs7HUhpe/P AxcINKWoSTYvI38CYPZsXsO7vxT9yPenDhrQvfcTeRMObZbSAmJWmU4/F+wxT1c2 Mb984U5DikgZ6tAejWWWgxgo5QOL37N0Bh05BSlXjjIe9jP61zNrSxKxw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeiuddggeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 17 May 2023 07:48:48 -0400 (EDT) Received: by pks.im (OpenSMTPD) with ESMTPSA id 5ab87d4e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 17 May 2023 11:48:25 +0000 (UTC) Date: Wed, 17 May 2023 13:48:46 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 2/9] fetch: drop unneeded NULL-check for `remote_ref` Message-ID: <7197540df60d34e8f727e29d300dd0c96e31d310.1684324059.git.ps@pks.im> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Drop the `NULL` check for `remote_ref` in `update_local_ref()`. The function only has a single caller, and that caller always passes in a non-`NULL` value. This fixes a false positive in Coverity. Signed-off-by: Patrick Steinhardt --- builtin/fetch.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 9147b700e5..f268322e6f 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -953,11 +953,10 @@ static int update_local_ref(struct ref *ref, * Base this on the remote's ref name, as it's * more likely to follow a standard layout. */ - const char *name = remote_ref ? remote_ref->name : ""; - if (starts_with(name, "refs/tags/")) { + if (starts_with(remote_ref->name, "refs/tags/")) { msg = "storing tag"; what = _("[new tag]"); - } else if (starts_with(name, "refs/heads/")) { + } else if (starts_with(remote_ref->name, "refs/heads/")) { msg = "storing head"; what = _("[new branch]"); } else { From patchwork Wed May 17 11:48:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13244765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35333C77B7F for ; Wed, 17 May 2023 11:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230507AbjEQLtJ (ORCPT ); Wed, 17 May 2023 07:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230489AbjEQLs7 (ORCPT ); Wed, 17 May 2023 07:48:59 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FBD6449E for ; Wed, 17 May 2023 04:48:54 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id EE2F432002B6 for ; Wed, 17 May 2023 07:48:53 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 17 May 2023 07:48:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1684324133; x=1684410533; bh=zw D5m9WzvJzlKEnEhRLvt4jA5eCuXnNRtcR8AnN+7bM=; b=N9VY653xEwn34YGUz7 gyzUld2X7tMkXXL01FtgyFXnLXvmpAeW871L7gjK62hZCoSA08rWYNPYE9DWh0es VVwJrHhi5Nnilhuo3BxdZh6q/QYlqppq3pZ7P/4J6Y3UYTkj9eFCfiOVqcaoOdFd 8s/aMpKr7XDbpP86jnezefIv+3349puyOvaVu0L4YLcyXxRedYw88t39QKayvOBc poY88qPpnIZMMNnK9IiZJ/RCSY0OzgaI2+j5TcjVjQ0FXhxVOl8CRHtYFGM3a/LL f+CPTWPVl+NTqZbiqOwb4e6UlkFAWPlbIh62NhsdrQGMjO4tFe9qQot5C++Kh0EQ hW9A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684324133; x=1684410533; bh=zwD5m9WzvJzlK EnEhRLvt4jA5eCuXnNRtcR8AnN+7bM=; b=RNg8TdyDBbfrhtcwLgDbUqeNt1hf7 RxiWLmtAXXT7SBWR4jq0EuwnWpL3aci9qLDZzOvRY7lKoPQeh4QL7DCNeJeqc51u b7/mdrOhIxvxH3+DuASCFOGDz86VOtyL1BA1kHcF5V0hqyz+/BwZxrUF2VW/HVW1 ZTUIGEiC6nuvYd1h9ZJu21oSfyyl3iLnGcGWN3U0vNd3/3Z1gGoyWDqyFQOM/KWI LWawYPhyXTVQfH4wnip55W9NrJO39hxupja2FlJ45r0hn9ZbSRgspqK5iEIY70+e e3QbNvmOtwXxtnArcLyRx/nJTRQZkFRUn5PPXnNvFsMEAaTuOflEPl6Ig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeiuddggeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgepvdenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 17 May 2023 07:48:52 -0400 (EDT) Received: by pks.im (OpenSMTPD) with ESMTPSA id d9b2f6c5 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 17 May 2023 11:48:29 +0000 (UTC) Date: Wed, 17 May 2023 13:48:51 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 3/9] fetch: pass through `fetch_config` directly Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The `fetch_config` structure currently only has a single member, which is the `display_format`. We're about extend it to contain all parsed config values and will thus need it available in most of the code. Prepare for this change by passing through the `fetch_config` directly instead of only passing its single member. Signed-off-by: Patrick Steinhardt --- builtin/fetch.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index f268322e6f..401543e05d 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1553,7 +1553,7 @@ static int backfill_tags(struct display_state *display_state, static int do_fetch(struct transport *transport, struct refspec *rs, - enum display_format display_format) + const struct fetch_config *config) { struct ref_transaction *transaction = NULL; struct ref *ref_map = NULL; @@ -1639,7 +1639,8 @@ static int do_fetch(struct transport *transport, if (retcode) goto cleanup; - display_state_init(&display_state, ref_map, transport->url, display_format); + display_state_init(&display_state, ref_map, transport->url, + config->display_format); if (atomic_fetch) { transaction = ref_transaction_begin(&err); @@ -1828,7 +1829,7 @@ static int add_remote_or_group(const char *name, struct string_list *list) } static void add_options_to_argv(struct strvec *argv, - enum display_format format) + const struct fetch_config *config) { if (dry_run) strvec_push(argv, "--dry-run"); @@ -1864,7 +1865,7 @@ static void add_options_to_argv(struct strvec *argv, strvec_push(argv, "--ipv6"); if (!write_fetch_head) strvec_push(argv, "--no-write-fetch-head"); - if (format == DISPLAY_FORMAT_PORCELAIN) + if (config->display_format == DISPLAY_FORMAT_PORCELAIN) strvec_pushf(argv, "--porcelain"); } @@ -1874,7 +1875,7 @@ struct parallel_fetch_state { const char **argv; struct string_list *remotes; int next, result; - enum display_format format; + const struct fetch_config *config; }; static int fetch_next_remote(struct child_process *cp, @@ -1894,7 +1895,7 @@ static int fetch_next_remote(struct child_process *cp, strvec_push(&cp->args, remote); cp->git_cmd = 1; - if (verbosity >= 0 && state->format != DISPLAY_FORMAT_PORCELAIN) + if (verbosity >= 0 && state->config->display_format != DISPLAY_FORMAT_PORCELAIN) printf(_("Fetching %s\n"), remote); return 1; @@ -1927,7 +1928,7 @@ static int fetch_finished(int result, struct strbuf *out, } static int fetch_multiple(struct string_list *list, int max_children, - enum display_format format) + const struct fetch_config *config) { int i, result = 0; struct strvec argv = STRVEC_INIT; @@ -1945,10 +1946,10 @@ static int fetch_multiple(struct string_list *list, int max_children, strvec_pushl(&argv, "-c", "fetch.bundleURI=", "fetch", "--append", "--no-auto-gc", "--no-write-commit-graph", NULL); - add_options_to_argv(&argv, format); + add_options_to_argv(&argv, config); if (max_children != 1 && list->nr != 1) { - struct parallel_fetch_state state = { argv.v, list, 0, 0, format }; + struct parallel_fetch_state state = { argv.v, list, 0, 0, config }; const struct run_process_parallel_opts opts = { .tr2_category = "fetch", .tr2_label = "parallel/fetch", @@ -1972,7 +1973,7 @@ static int fetch_multiple(struct string_list *list, int max_children, strvec_pushv(&cmd.args, argv.v); strvec_push(&cmd.args, name); - if (verbosity >= 0 && format != DISPLAY_FORMAT_PORCELAIN) + if (verbosity >= 0 && config->display_format != DISPLAY_FORMAT_PORCELAIN) printf(_("Fetching %s\n"), name); cmd.git_cmd = 1; if (run_command(&cmd)) { @@ -2028,7 +2029,7 @@ static inline void fetch_one_setup_partial(struct remote *remote) static int fetch_one(struct remote *remote, int argc, const char **argv, int prune_tags_ok, int use_stdin_refspecs, - enum display_format display_format) + const struct fetch_config *config) { struct refspec rs = REFSPEC_INIT_FETCH; int i; @@ -2095,7 +2096,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv, sigchain_push_common(unlock_pack_on_signal); atexit(unlock_pack_atexit); sigchain_push(SIGPIPE, SIG_IGN); - exit_code = do_fetch(gtransport, &rs, display_format); + exit_code = do_fetch(gtransport, &rs, config); sigchain_pop(SIGPIPE); refspec_clear(&rs); transport_disconnect(gtransport); @@ -2383,7 +2384,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) if (filter_options.choice || repo_has_promisor_remote(the_repository)) fetch_one_setup_partial(remote); result = fetch_one(remote, argc, argv, prune_tags_ok, stdin_refspecs, - config.display_format); + &config); } else { int max_children = max_jobs; @@ -2403,7 +2404,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) max_children = fetch_parallel_config; /* TODO should this also die if we have a previous partial-clone? */ - result = fetch_multiple(&list, max_children, config.display_format); + result = fetch_multiple(&list, max_children, &config); } /* @@ -2424,7 +2425,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) if (max_children < 0) max_children = fetch_parallel_config; - add_options_to_argv(&options, config.display_format); + add_options_to_argv(&options, &config); result = fetch_submodules(the_repository, &options, submodule_prefix, From patchwork Wed May 17 11:48:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13244766 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3295C77B7F for ; Wed, 17 May 2023 11:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230302AbjEQLtM (ORCPT ); Wed, 17 May 2023 07:49:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231260AbjEQLtB (ORCPT ); Wed, 17 May 2023 07:49:01 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E40110F7 for ; Wed, 17 May 2023 04:49:00 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 89A8D32003D3 for ; Wed, 17 May 2023 07:48:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 17 May 2023 07:48:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1684324139; x=1684410539; bh=fV MMzq9hRkc2kXRlI1eMhydet6eRIFeoDKrYv9w2Uxc=; b=T9v3MMxaKuPuFo2kbJ GjRhyberCEUxISVmOMMaRfS0/ZWx9AWgrEcd6YTEGeh9RQq3H2S40c9Cm4sACK4Y jmiPUuLiG4t28XGQM+yu3d+0da496ZGF7p6CSviP+7pRSVinD7j2Q/lDMfrbzs05 KxA+SF3B6f0RCzjyS4sKV1O8i0lIfC9kgiBffWQoE6rpWGONF4pK65Tm/1ZE5RPB CdIjXxFg+HX/85SQ787SckhOdKpc+zxB2XldnKIRCEt07hg5K4E/3aEGf7GYXHkm v3eR/R8zv15HkMijwCezNievBZgY0ULy/s/iRsHXy+JJ5cVsapwhNg2Hh+0lRA4a wtFg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684324139; x=1684410539; bh=fVMMzq9hRkc2k XRlI1eMhydet6eRIFeoDKrYv9w2Uxc=; b=Vs7H4mi4MlQw/5I3UFiPq9iFXVZnJ FGW1SVeMadWSbr1TehHz2J9w1IO1ADKFo85q9OpboKTo2Y1pxD+080UmDPqMVrLr PuLZhY35zRsCkIKt1za1KdRsT3HaeURk4+UqQndsNlg5kFRe/wulocai+SJ6/eNy P2xq6SMSHM8K7QhSh97EWXpHiRulsQsfnZl4zD1wKmP1PTFkwlmagyydIKzdiqRL bihzMnMf1JMrM5Cskzshc3UelcULvGrs9xvxDXPQ0fQUjNrbF9Mr3o5n4A56d4P3 E7zGWHxaHhcr/sssrAFaz3OGz2LYOMZxGRBKT9pRtRjB3XntUohOz/VkA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeiuddggeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 17 May 2023 07:48:58 -0400 (EDT) Received: by pks.im (OpenSMTPD) with ESMTPSA id 899e0444 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 17 May 2023 11:48:34 +0000 (UTC) Date: Wed, 17 May 2023 13:48:56 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 4/9] fetch: use `fetch_config` to store "fetch.prune" value Message-ID: <1fa4922bea12ef0363e2638bbb5c70218c6ec357.1684324059.git.ps@pks.im> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the parsed "fetch.prune" config value into the `fetch_config` structure. This reduces our reliance on global variables and further unifies the way we parse the configuration in git-fetch(1). Signed-off-by: Patrick Steinhardt --- builtin/fetch.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 401543e05d..488705b519 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -73,7 +73,6 @@ struct display_state { int url_len, shown_url; }; -static int fetch_prune_config = -1; /* unspecified */ static int fetch_show_forced_updates = 1; static uint64_t forced_updates_ms = 0; static int prefetch = 0; @@ -108,6 +107,7 @@ static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP; struct fetch_config { enum display_format display_format; + int prune; }; static int git_fetch_config(const char *k, const char *v, void *cb) @@ -115,7 +115,7 @@ static int git_fetch_config(const char *k, const char *v, void *cb) struct fetch_config *fetch_config = cb; if (!strcmp(k, "fetch.prune")) { - fetch_prune_config = git_config_bool(k, v); + fetch_config->prune = git_config_bool(k, v); return 0; } @@ -2047,8 +2047,8 @@ static int fetch_one(struct remote *remote, int argc, const char **argv, /* no command line request */ if (0 <= remote->prune) prune = remote->prune; - else if (0 <= fetch_prune_config) - prune = fetch_prune_config; + else if (0 <= config->prune) + prune = config->prune; else prune = PRUNE_BY_DEFAULT; } @@ -2108,6 +2108,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) { struct fetch_config config = { .display_format = DISPLAY_FORMAT_FULL, + .prune = -1, }; const char *submodule_prefix = ""; const char *bundle_uri; From patchwork Wed May 17 11:49:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13244767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A40EC77B75 for ; Wed, 17 May 2023 11:49:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231314AbjEQLtP (ORCPT ); Wed, 17 May 2023 07:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230464AbjEQLtE (ORCPT ); Wed, 17 May 2023 07:49:04 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8564B55A6 for ; Wed, 17 May 2023 04:49:03 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 0376B32000F9 for ; Wed, 17 May 2023 07:49:02 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 17 May 2023 07:49:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1684324142; x=1684410542; bh=oi 3WQx5ml4mCOJQ3vAt6QwS7Smz/2w63JEUYLLntlDA=; b=r3m5AQhDJBqECZJoRq erFRZI1bcOQlKIQ+hVY1V80SlUk88/ck5SRhFZa7jcQb5+m8ZCB6jofun3mFEPwy bHXDq4sxnNELlvp3f2bHTj9ziG6QEqAgH3ZT8dWUzNTmDZJsN5+Um8B30/OZo0VB EGsaJGLN65gVTKOeKy+9DxdlvmWeYpDW8RdJ099IAEJ00kvw9gSajfO6neDWKB9z k0SiNL1qzg0c8K4nSFwrqr4g7EL0ZueJMVhbj4dKREgu8rHN0HS40n0Egf5zJo1P jnxekWtcu9krXz2rhM8jLngVUav2C5J6QhJTmFR85+3ST4AYJqANe87ssBdoIDDf NjKg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684324142; x=1684410542; bh=oi3WQx5ml4mCO JQ3vAt6QwS7Smz/2w63JEUYLLntlDA=; b=qL+H50xobp8PtEEEAcUG7yZzK4UXq D2DGQPG4T5okPNpK2JmMb0jg9+kpazDR3VamieM32jzTkF9uCCxbkIgBrIXD+4Be BkIllVlesOFZYlpM6E2zKlGBUOmHEfEhtPREh/2k0DwAnh3XUyamJMwolOsDjvL3 7Q2BLLQQlRkpR4HrRiq6T18SGxIx8hzOGFxkXGkyYozyMnJc8EhivZgUtLpTh3cf 7l+7R4bp/j9g6MZH6tCt4NKopOGGDep/qwO1+HJECBm244o33OotriNsmZixyKbo nLmjKZKpt+p3U+suXCp0MbLu3br4JEHcrJMP128YWkKEwKFBrSMJcUuvg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeiuddggeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 17 May 2023 07:49:01 -0400 (EDT) Received: by pks.im (OpenSMTPD) with ESMTPSA id 69fbfc6c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 17 May 2023 11:48:38 +0000 (UTC) Date: Wed, 17 May 2023 13:49:00 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 5/9] fetch: use `fetch_config` to store "fetch.pruneTags" value Message-ID: <3aa64ca1941cb8204448a48e1d44b9563c002d19.1684324059.git.ps@pks.im> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the parsed "fetch.pruneTags" config value into the `fetch_config` structure. This reduces our reliance on global variables and further unifies the way we parse the configuration in git-fetch(1). Signed-off-by: Patrick Steinhardt --- builtin/fetch.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 488705b519..94718bcb2a 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -79,7 +79,6 @@ static int prefetch = 0; static int prune = -1; /* unspecified */ #define PRUNE_BY_DEFAULT 0 /* do we prune by default? */ -static int fetch_prune_tags_config = -1; /* unspecified */ static int prune_tags = -1; /* unspecified */ #define PRUNE_TAGS_BY_DEFAULT 0 /* do we prune tags by default? */ @@ -108,6 +107,7 @@ static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP; struct fetch_config { enum display_format display_format; int prune; + int prune_tags; }; static int git_fetch_config(const char *k, const char *v, void *cb) @@ -120,7 +120,7 @@ static int git_fetch_config(const char *k, const char *v, void *cb) } if (!strcmp(k, "fetch.prunetags")) { - fetch_prune_tags_config = git_config_bool(k, v); + fetch_config->prune_tags = git_config_bool(k, v); return 0; } @@ -2057,8 +2057,8 @@ static int fetch_one(struct remote *remote, int argc, const char **argv, /* no command line request */ if (0 <= remote->prune_tags) prune_tags = remote->prune_tags; - else if (0 <= fetch_prune_tags_config) - prune_tags = fetch_prune_tags_config; + else if (0 <= config->prune_tags) + prune_tags = config->prune_tags; else prune_tags = PRUNE_TAGS_BY_DEFAULT; } @@ -2109,6 +2109,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) struct fetch_config config = { .display_format = DISPLAY_FORMAT_FULL, .prune = -1, + .prune_tags = -1, }; const char *submodule_prefix = ""; const char *bundle_uri; From patchwork Wed May 17 11:49:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13244768 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B13EFC77B75 for ; Wed, 17 May 2023 11:49:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230151AbjEQLtR (ORCPT ); Wed, 17 May 2023 07:49:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231245AbjEQLtJ (ORCPT ); Wed, 17 May 2023 07:49:09 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CD5344AB for ; Wed, 17 May 2023 04:49:08 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 78E6C320034E for ; Wed, 17 May 2023 07:49:07 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 17 May 2023 07:49:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1684324147; x=1684410547; bh=Vs dbTYRdPXVbLietTon7fuQz8GWgaU/13o1fInKTTMk=; b=Wkv/omSpZw5D3I9m3N LXcDtOEd922a8SDUOFl2q1Gs/7PNuk+DrdpIuRXNNybbtHXuDZ7Pigp0A4fudkrR 9+bQxJf3/r6YQCULfhvi2ScKzwnuCnLcHfKi4YjF+oz2Ed44hTGZa5++jBsehfJv nU1G+SEyD8nZbLHERKhiOPeF4K67e+DOnD8loo1Ijgr9iuooMtCsf5FdqNRckF6T JuJCB10O9510uwi7oFbQBuIrmwt/HNHM4GV5or8OuVR8WuMfS67TyQItBl4mlsKZ HWwlWOgVsmJdPI87wSvfN4+YRVceOkxtxsBzzBV1Q+DDiHVe2cjHvf6FOaMo9I/d +fmg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684324147; x=1684410547; bh=VsdbTYRdPXVbL ietTon7fuQz8GWgaU/13o1fInKTTMk=; b=e95EC1aBfF4JSGjwQOz1pbwWMvZp+ o5q92P8hMiAESZskt+SwcTq5Wu5Ht1CknRbHdoTmru5bXGjZfU/0FPmJ89cQ7J9x FV80X6KXCRMIbJH6az884HDoS/P4AO8LTJiw4gPRmCWhNjUB++j1mlBBQIa0XRKf wRfiOzFAY0OALc1Gd+Q7n5fUUBlF0jqm/fgIuCOLTdFn3ENBV1tHWjs/uT3q5xia lBdlwXoxwfj5SPTo0j1G2vtn8hi7gGTEkvlhfr7hwwVtGpNbinbcNy5YDDeu5qd9 v/ftnInbXmEg/5Sfm+XW6T33qvL3maw7o9Hl9it3WKBiKk8Ec7Y89Yzuw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeiuddggeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgepudenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 17 May 2023 07:49:06 -0400 (EDT) Received: by pks.im (OpenSMTPD) with ESMTPSA id 801929af (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 17 May 2023 11:48:43 +0000 (UTC) Date: Wed, 17 May 2023 13:49:04 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 6/9] fetch: use `fetch_config` to store "fetch.showForcedUpdates" value Message-ID: <5e842c1327efa73cac4f51160d70dd16ba09bfb3.1684324059.git.ps@pks.im> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the parsed "fetch.showForcedUpdaets" config value into the `fetch_config` structure. This reduces our reliance on global variables and further unifies the way we parse the configuration in git-fetch(1). Signed-off-by: Patrick Steinhardt --- builtin/fetch.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 94718bcb2a..eec04d7660 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -73,7 +73,6 @@ struct display_state { int url_len, shown_url; }; -static int fetch_show_forced_updates = 1; static uint64_t forced_updates_ms = 0; static int prefetch = 0; static int prune = -1; /* unspecified */ @@ -108,6 +107,7 @@ struct fetch_config { enum display_format display_format; int prune; int prune_tags; + int show_forced_updates; }; static int git_fetch_config(const char *k, const char *v, void *cb) @@ -125,7 +125,7 @@ static int git_fetch_config(const char *k, const char *v, void *cb) } if (!strcmp(k, "fetch.showforcedupdates")) { - fetch_show_forced_updates = git_config_bool(k, v); + fetch_config->show_forced_updates = git_config_bool(k, v); return 0; } @@ -891,7 +891,8 @@ static int update_local_ref(struct ref *ref, struct ref_transaction *transaction, struct display_state *display_state, const struct ref *remote_ref, - int summary_width) + int summary_width, + const struct fetch_config *config) { struct commit *current = NULL, *updated; int fast_forward = 0; @@ -972,7 +973,7 @@ static int update_local_ref(struct ref *ref, return r; } - if (fetch_show_forced_updates) { + if (config->show_forced_updates) { uint64_t t_before = getnanotime(); fast_forward = repo_in_merge_bases(the_repository, current, updated); @@ -1125,7 +1126,8 @@ static int store_updated_refs(struct display_state *display_state, const char *remote_name, int connectivity_checked, struct ref_transaction *transaction, struct ref *ref_map, - struct fetch_head *fetch_head) + struct fetch_head *fetch_head, + const struct fetch_config *config) { int rc = 0; struct strbuf note = STRBUF_INIT; @@ -1241,7 +1243,7 @@ static int store_updated_refs(struct display_state *display_state, if (ref) { rc |= update_local_ref(ref, transaction, display_state, - rm, summary_width); + rm, summary_width, config); free(ref); } else if (write_fetch_head || dry_run) { /* @@ -1265,7 +1267,7 @@ static int store_updated_refs(struct display_state *display_state, "branches"), remote_name); if (advice_enabled(ADVICE_FETCH_SHOW_FORCED_UPDATES)) { - if (!fetch_show_forced_updates) { + if (!config->show_forced_updates) { warning(_(warn_show_forced_updates)); } else if (forced_updates_ms > FORCED_UPDATES_DELAY_WARNING_IN_MS) { warning(_(warn_time_show_forced_updates), @@ -1326,7 +1328,8 @@ static int fetch_and_consume_refs(struct display_state *display_state, struct transport *transport, struct ref_transaction *transaction, struct ref *ref_map, - struct fetch_head *fetch_head) + struct fetch_head *fetch_head, + const struct fetch_config *config) { int connectivity_checked = 1; int ret; @@ -1349,7 +1352,7 @@ static int fetch_and_consume_refs(struct display_state *display_state, trace2_region_enter("fetch", "consume_refs", the_repository); ret = store_updated_refs(display_state, transport->remote->name, connectivity_checked, transaction, ref_map, - fetch_head); + fetch_head, config); trace2_region_leave("fetch", "consume_refs", the_repository); out: @@ -1520,7 +1523,8 @@ static int backfill_tags(struct display_state *display_state, struct transport *transport, struct ref_transaction *transaction, struct ref *ref_map, - struct fetch_head *fetch_head) + struct fetch_head *fetch_head, + const struct fetch_config *config) { int retcode, cannot_reuse; @@ -1541,7 +1545,8 @@ static int backfill_tags(struct display_state *display_state, transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL); transport_set_option(transport, TRANS_OPT_DEPTH, "0"); transport_set_option(transport, TRANS_OPT_DEEPEN_RELATIVE, NULL); - retcode = fetch_and_consume_refs(display_state, transport, transaction, ref_map, fetch_head); + retcode = fetch_and_consume_refs(display_state, transport, transaction, ref_map, + fetch_head, config); if (gsecondary) { transport_disconnect(gsecondary); @@ -1668,7 +1673,8 @@ static int do_fetch(struct transport *transport, retcode = 1; } - if (fetch_and_consume_refs(&display_state, transport, transaction, ref_map, &fetch_head)) { + if (fetch_and_consume_refs(&display_state, transport, transaction, ref_map, + &fetch_head, config)) { retcode = 1; goto cleanup; } @@ -1691,7 +1697,7 @@ static int do_fetch(struct transport *transport, * the transaction and don't commit anything. */ if (backfill_tags(&display_state, transport, transaction, tags_ref_map, - &fetch_head)) + &fetch_head, config)) retcode = 1; } @@ -2110,6 +2116,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) .display_format = DISPLAY_FORMAT_FULL, .prune = -1, .prune_tags = -1, + .show_forced_updates = 1, }; const char *submodule_prefix = ""; const char *bundle_uri; @@ -2207,7 +2214,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) N_("run 'maintenance --auto' after fetching")), OPT_BOOL(0, "auto-gc", &enable_auto_gc, N_("run 'maintenance --auto' after fetching")), - OPT_BOOL(0, "show-forced-updates", &fetch_show_forced_updates, + OPT_BOOL(0, "show-forced-updates", &config.show_forced_updates, N_("check for forced-updates on all updated branches")), OPT_BOOL(0, "write-commit-graph", &fetch_write_commit_graph, N_("write the commit-graph after fetching")), From patchwork Wed May 17 11:49:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13244769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9C77C77B75 for ; Wed, 17 May 2023 11:49:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231139AbjEQLtW (ORCPT ); Wed, 17 May 2023 07:49:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230489AbjEQLtO (ORCPT ); Wed, 17 May 2023 07:49:14 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95C453A8D for ; Wed, 17 May 2023 04:49:12 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 0F18332003D3 for ; Wed, 17 May 2023 07:49:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 17 May 2023 07:49:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1684324151; x=1684410551; bh=bF gp8hkBbbIMWO0IUzjlTdREL2Gx8KIlZaYqmGlT4xE=; b=VTQd7OZZbZbBnTstp6 XdCTuUSjhW3fmkMHTT+kaDOvPBJo6u/6vDMMrmEjzT6Z2GcHdvd4rz1ct2Io4zIB z3LLqea2RDq4Z6CtzyxZ9Sv/LYTtYvFjQ5cHJZTIPQirEjLdSS9uZMIvBXkH0iFZ 9SiB7XAIGoLU/Aup+tpcQ8yZSA5pzpgbZ7creHgEWAfnqKbka3IPskqDJreSyyhh UdHWO942H75dtoS0Lpitbec7s3EKh1Lw56M8sBnGBC7bCDxyGD3ooIbV56oZwonJ UDWOFC5JMxgAJxY7t82vL22yBl6Xpc2i1WvQCGJvyQn60NRZlBggIU4wFG7hDbWi N8Ww== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684324151; x=1684410551; bh=bFgp8hkBbbIMW O0IUzjlTdREL2Gx8KIlZaYqmGlT4xE=; b=V+ixL9mum2Ksehu14OzF8GIuk2B9L 4/dqOP3GwoNyriExVvqRAwckOhtKBAmTuaF1vCzKMkZJi2OkiRFo8hKohKSWSdZR zdaVSljvbgbuCP2icOdHTKt0oJqc/DCsfP9SELmBqCx8+gywSCd7fYbso71bvK2D qQc5dYzcNZCrfHapvtpmvjrAx3frq21jeboH0si7wYI2wSK9NFbh0dvJodc5uAel CLzF8X3ZBq4owvh3TxJXSRHDLZoyjY0TbJd0DRDHAAoNU5pXAmwjDPj5yEj/knnS 7WwwupG4C5Aadp+4Zgt7cv7QFpAfM/QS+g3amiB1RPynaGiMqCZlQ5QBQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeiuddggeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 17 May 2023 07:49:10 -0400 (EDT) Received: by pks.im (OpenSMTPD) with ESMTPSA id 612d832b (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 17 May 2023 11:48:47 +0000 (UTC) Date: Wed, 17 May 2023 13:49:08 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 7/9] fetch: use `fetch_config` to store "fetch.recurseSubmodules" value Message-ID: <74eee5858d1511e35a0039ef8bd65585676b3f72.1684324059.git.ps@pks.im> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the parsed "fetch.recurseSubmodules" config value into the `fetch_config` structure. This reduces our reliance on global variables and further unifies the way we parse the configuration in git-fetch(1). Signed-off-by: Patrick Steinhardt --- builtin/fetch.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index eec04d7660..b40df7e7ca 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -97,7 +97,6 @@ static struct string_list deepen_not = STRING_LIST_INIT_NODUP; static struct strbuf default_rla = STRBUF_INIT; static struct transport *gtransport; static struct transport *gsecondary; -static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT; static struct refspec refmap = REFSPEC_INIT_FETCH; static struct list_objects_filter_options filter_options = LIST_OBJECTS_FILTER_INIT; static struct string_list server_options = STRING_LIST_INIT_DUP; @@ -108,6 +107,7 @@ struct fetch_config { int prune; int prune_tags; int show_forced_updates; + int recurse_submodules; }; static int git_fetch_config(const char *k, const char *v, void *cb) @@ -132,14 +132,14 @@ static int git_fetch_config(const char *k, const char *v, void *cb) if (!strcmp(k, "submodule.recurse")) { int r = git_config_bool(k, v) ? RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF; - recurse_submodules = r; + fetch_config->recurse_submodules = r; } if (!strcmp(k, "submodule.fetchjobs")) { submodule_fetch_jobs_config = parse_submodule_fetchjobs(k, v); return 0; } else if (!strcmp(k, "fetch.recursesubmodules")) { - recurse_submodules = parse_fetch_recurse_submodules_arg(k, v); + fetch_config->recurse_submodules = parse_fetch_recurse_submodules_arg(k, v); return 0; } @@ -1210,7 +1210,7 @@ static int store_updated_refs(struct display_state *display_state, ref->force = rm->peer_ref->force; } - if (recurse_submodules != RECURSE_SUBMODULES_OFF && + if (config->recurse_submodules != RECURSE_SUBMODULES_OFF && (!rm->peer_ref || !oideq(&ref->old_oid, &ref->new_oid))) { check_for_new_submodule_commits(&rm->old_oid); } @@ -1849,11 +1849,11 @@ static void add_options_to_argv(struct strvec *argv, strvec_push(argv, "--force"); if (keep) strvec_push(argv, "--keep"); - if (recurse_submodules == RECURSE_SUBMODULES_ON) + if (config->recurse_submodules == RECURSE_SUBMODULES_ON) strvec_push(argv, "--recurse-submodules"); - else if (recurse_submodules == RECURSE_SUBMODULES_OFF) + else if (config->recurse_submodules == RECURSE_SUBMODULES_OFF) strvec_push(argv, "--no-recurse-submodules"); - else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) + else if (config->recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) strvec_push(argv, "--recurse-submodules=on-demand"); if (tags == TAGS_SET) strvec_push(argv, "--tags"); @@ -2117,6 +2117,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) .prune = -1, .prune_tags = -1, .show_forced_updates = 1, + .recurse_submodules = RECURSE_SUBMODULES_DEFAULT, }; const char *submodule_prefix = ""; const char *bundle_uri; @@ -2245,7 +2246,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) builtin_fetch_options, builtin_fetch_usage, 0); if (recurse_submodules_cli != RECURSE_SUBMODULES_DEFAULT) - recurse_submodules = recurse_submodules_cli; + config.recurse_submodules = recurse_submodules_cli; if (negotiate_only) { switch (recurse_submodules_cli) { @@ -2256,7 +2257,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) * submodules. Skip it by setting recurse_submodules to * RECURSE_SUBMODULES_OFF. */ - recurse_submodules = RECURSE_SUBMODULES_OFF; + config.recurse_submodules = RECURSE_SUBMODULES_OFF; break; default: @@ -2265,11 +2266,11 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) } } - if (recurse_submodules != RECURSE_SUBMODULES_OFF) { + if (config.recurse_submodules != RECURSE_SUBMODULES_OFF) { int *sfjc = submodule_fetch_jobs_config == -1 ? &submodule_fetch_jobs_config : NULL; - int *rs = recurse_submodules == RECURSE_SUBMODULES_DEFAULT - ? &recurse_submodules : NULL; + int *rs = config.recurse_submodules == RECURSE_SUBMODULES_DEFAULT + ? &config.recurse_submodules : NULL; fetch_config_from_gitmodules(sfjc, rs); } @@ -2283,7 +2284,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) * Reference updates in submodules would be ambiguous * in porcelain mode, so we reject this combination. */ - recurse_submodules = RECURSE_SUBMODULES_OFF; + config.recurse_submodules = RECURSE_SUBMODULES_OFF; break; default: @@ -2425,7 +2426,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) * the fetched history from each remote, so there is no need * to fetch submodules from here. */ - if (!result && remote && (recurse_submodules != RECURSE_SUBMODULES_OFF)) { + if (!result && remote && (config.recurse_submodules != RECURSE_SUBMODULES_OFF)) { struct strvec options = STRVEC_INIT; int max_children = max_jobs; @@ -2438,7 +2439,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) result = fetch_submodules(the_repository, &options, submodule_prefix, - recurse_submodules, + config.recurse_submodules, recurse_submodules_default, verbosity < 0, max_children); From patchwork Wed May 17 11:49:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13244770 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB649C7EE23 for ; Wed, 17 May 2023 11:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231296AbjEQLtY (ORCPT ); Wed, 17 May 2023 07:49:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229630AbjEQLtR (ORCPT ); Wed, 17 May 2023 07:49:17 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D79655A6 for ; Wed, 17 May 2023 04:49:16 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 84C0D32008FE for ; Wed, 17 May 2023 07:49:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 17 May 2023 07:49:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1684324155; x=1684410555; bh=WM qvXvXb3ZzAa4iyf4MkYprrXQSaVYKyp9cMuIm7n24=; b=JS8U2GeX/93a2Y3KXF 7B/fc6b0eAvxaWVQqvsjTZ5rYHrtA9zHJlj7lWbShBmfibaDi5FbLQPsMPW8+pRT 9seBV+uCQVt/C7vAXYoXXOsIYD84XyOeiXP28k2rgE4lcjodq89BbrTvLvSYdXXR 3PvlJ/aK55eXEuak76c98DEM/txJN8HzjxZ6KnXuItUGdSiAGqk35Mo2165K8dIt Ebu80rbvdTe4wrTTLIEBW6l2Az5R1T2jLRxcGn6ncj93hEN23bR6RHMYbj/yH/6y 2y6EKvANzMVnX7cuvCwMtxiciTrsMa+Lq58LL2unEk9WJy62UyiX2DKdvG9+TyTS 3WeA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684324155; x=1684410555; bh=WMqvXvXb3ZzAa 4iyf4MkYprrXQSaVYKyp9cMuIm7n24=; b=DhJ89AURj875dA50sI+xKMER5Dk2H /bMlAkGMHmq713P74t1b3mNgrkGnhjGmSblBAlnpHbJw0pcsI3ZTn0d2oMLuqsbd oK0Pra3PSLZ22JvxzrwkRKPlUC2SqPNGCsk6N3vP2SGSBF1wac2nmRhdRnClmcPb sqc5iNMh2biKy0rivYyj5Zowl8hUy4G7dDAr+YacuYQWwG99+lTDww14uK7ChSYb IrBjhpTIsHMft8imAZu4a8Pun2+OmCiTVwgqlMSB7Px+UKpfF0DladVL+OF2cx27 UufG6i0mu3cdmj9ImcsCOMik28gyxCG606zfVARv/sGABnWeI8i5nYGqQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeiuddggeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgepudenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 17 May 2023 07:49:14 -0400 (EDT) Received: by pks.im (OpenSMTPD) with ESMTPSA id a64995a5 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 17 May 2023 11:48:51 +0000 (UTC) Date: Wed, 17 May 2023 13:49:13 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 8/9] fetch: use `fetch_config` to store "fetch.parallel" value Message-ID: <8e729d7035a5dc2e1bc1272522eeba465051ee37.1684324059.git.ps@pks.im> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the parsed "fetch.parallel" config value into the `fetch_config` structure. This reduces our reliance on global variables and further unifies the way we parse the configuration in git-fetch(1). Signed-off-by: Patrick Steinhardt --- builtin/fetch.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index b40df7e7ca..29b36da18a 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -87,7 +87,6 @@ static int verbosity, deepen_relative, set_upstream, refetch; static int progress = -1; static int tags = TAGS_DEFAULT, update_shallow, deepen; static int submodule_fetch_jobs_config = -1; -static int fetch_parallel_config = 1; static int atomic_fetch; static enum transport_family family; static const char *depth; @@ -108,6 +107,7 @@ struct fetch_config { int prune_tags; int show_forced_updates; int recurse_submodules; + int parallel; }; static int git_fetch_config(const char *k, const char *v, void *cb) @@ -144,11 +144,11 @@ static int git_fetch_config(const char *k, const char *v, void *cb) } if (!strcmp(k, "fetch.parallel")) { - fetch_parallel_config = git_config_int(k, v); - if (fetch_parallel_config < 0) + fetch_config->parallel = git_config_int(k, v); + if (fetch_config->parallel < 0) die(_("fetch.parallel cannot be negative")); - if (!fetch_parallel_config) - fetch_parallel_config = online_cpus(); + if (!fetch_config->parallel) + fetch_config->parallel = online_cpus(); return 0; } @@ -2118,6 +2118,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) .prune_tags = -1, .show_forced_updates = 1, .recurse_submodules = RECURSE_SUBMODULES_DEFAULT, + .parallel = 1, }; const char *submodule_prefix = ""; const char *bundle_uri; @@ -2411,7 +2412,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) "from one remote")); if (max_children < 0) - max_children = fetch_parallel_config; + max_children = config.parallel; /* TODO should this also die if we have a previous partial-clone? */ result = fetch_multiple(&list, max_children, &config); @@ -2433,7 +2434,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) if (max_children < 0) max_children = submodule_fetch_jobs_config; if (max_children < 0) - max_children = fetch_parallel_config; + max_children = config.parallel; add_options_to_argv(&options, &config); result = fetch_submodules(the_repository, From patchwork Wed May 17 11:49:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13244777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EF25C77B75 for ; Wed, 17 May 2023 11:49:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbjEQLti (ORCPT ); Wed, 17 May 2023 07:49:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230296AbjEQLtV (ORCPT ); Wed, 17 May 2023 07:49:21 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FE7159DA for ; Wed, 17 May 2023 04:49:20 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 1C1F032008C3 for ; Wed, 17 May 2023 07:49:20 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 17 May 2023 07:49:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1684324159; x=1684410559; bh=64 wpYUiW4jS/CcCCMLrzOd2XSkgM0m9UnFKQwP/r1pc=; b=k67yWIfJZZZ94diRj1 rBqqMEQ0wywueUNV9Dp+qM51PUY3Q1tR+tu6B8B96Fzl52SHN14l6hDB0DY1fTLz HMq3UizZ2VJQkL9Qk1OazcJJS06v/mcsLMb3vk0PjX2J3HG91K0tynOm+/7w8bAL 4PPENBTTpqRPbXHNUhnZUa1/PSECv4GPYRFraBZTrVVO/czdG9K0wpQG3Aaps3EH uTlrZYunRzJOsaDOw0mM7/E9xbfytu4cbPcEG8Esejxh+WkDgZ27lBemPEjs8x8z TD1e1+xNvG63KC4j26EspbdchBEBZXUhZnnt0DTgwh3ilqPACoX9m6OVG/kWtCuv j9cA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684324159; x=1684410559; bh=64wpYUiW4jS/C cCCMLrzOd2XSkgM0m9UnFKQwP/r1pc=; b=BGD3leJgzljO7zUmFyTs7ZuSLkEeJ Tg/yxLBu2QAIM5ww/EyUDGF0fFs47VLj7ILPfb3g4YfjFftqS77cI7CXV8hP6+un By0q51pui86qAysz9QdWk76yMasm5iNrddyGodJKPFCb0mO68k1EXLW7Np0ZJM8s 0dJqNJFvtBywp70Qgd/5Ra9h4InLd0XIj7oZUzZlrTBcgtKspezXYR0CpVTHOEhb k58zz4dwTc9lQ5QfCexVB3PHWXJtKIXs8mA3vYgmbjpJ/KUahZsdpttvYzr5FfqS 223m95t6FMDswv9TaxI70YJrpPF8E6vR0UyDcJrry77Yqo31HhKD0CStg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeiuddggeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgepvdenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 17 May 2023 07:49:18 -0400 (EDT) Received: by pks.im (OpenSMTPD) with ESMTPSA id 8c8e0dc7 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 17 May 2023 11:48:55 +0000 (UTC) Date: Wed, 17 May 2023 13:49:17 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 9/9] fetch: use `fetch_config` to store "submodule.fetchJobs" value Message-ID: <0eb84712a07243957d8037d7f1b3ad01260abe2f.1684324059.git.ps@pks.im> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the parsed "submodule.fetchJobs" config value into the `fetch_config` structure. This reduces our reliance on global variables and further unifies the way we parse the configuration in git-fetch(1). Signed-off-by: Patrick Steinhardt --- builtin/fetch.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 29b36da18a..e3871048cf 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -86,7 +86,6 @@ static int write_fetch_head = 1; static int verbosity, deepen_relative, set_upstream, refetch; static int progress = -1; static int tags = TAGS_DEFAULT, update_shallow, deepen; -static int submodule_fetch_jobs_config = -1; static int atomic_fetch; static enum transport_family family; static const char *depth; @@ -108,6 +107,7 @@ struct fetch_config { int show_forced_updates; int recurse_submodules; int parallel; + int submodule_fetch_jobs; }; static int git_fetch_config(const char *k, const char *v, void *cb) @@ -136,7 +136,7 @@ static int git_fetch_config(const char *k, const char *v, void *cb) } if (!strcmp(k, "submodule.fetchjobs")) { - submodule_fetch_jobs_config = parse_submodule_fetchjobs(k, v); + fetch_config->submodule_fetch_jobs = parse_submodule_fetchjobs(k, v); return 0; } else if (!strcmp(k, "fetch.recursesubmodules")) { fetch_config->recurse_submodules = parse_fetch_recurse_submodules_arg(k, v); @@ -2119,6 +2119,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) .show_forced_updates = 1, .recurse_submodules = RECURSE_SUBMODULES_DEFAULT, .parallel = 1, + .submodule_fetch_jobs = -1, }; const char *submodule_prefix = ""; const char *bundle_uri; @@ -2268,8 +2269,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) } if (config.recurse_submodules != RECURSE_SUBMODULES_OFF) { - int *sfjc = submodule_fetch_jobs_config == -1 - ? &submodule_fetch_jobs_config : NULL; + int *sfjc = config.submodule_fetch_jobs == -1 + ? &config.submodule_fetch_jobs : NULL; int *rs = config.recurse_submodules == RECURSE_SUBMODULES_DEFAULT ? &config.recurse_submodules : NULL; @@ -2432,7 +2433,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) int max_children = max_jobs; if (max_children < 0) - max_children = submodule_fetch_jobs_config; + max_children = config.submodule_fetch_jobs; if (max_children < 0) max_children = config.parallel;