From: Patrick Steinhardt <ps@pks.im>
To: Tian Yuchen <cat@malon.dev>
Cc: git@vger.kernel.org, five231003@gmail.com, hariom18599@gmail.com,
Christian Couder <christian.couder@gmail.com>,
Ayush Chandekar <ayu.chandekar@gmail.com>,
Olamide Caleb Bello <belkid98@gmail.com>
Subject: Re: [PATCH v2] repository: move fetch_if_missing into struct repository
Date: Tue, 4 Aug 2026 10:24:21 +0200 [thread overview]
Message-ID: <anGhtfPaGK7v3NNR@pks.im> (raw)
In-Reply-To: <20260716072954.582235-1-cat@malon.dev>
On Thu, Jul 16, 2026 at 03:29:54PM +0800, Tian Yuchen wrote:
> The global variable 'fetch_if_missing' controls whether a missing
> object check should prompt a lazy fetch from a promisor remote.
> In order to continue the libification effort, move it into
> 'struct repository' and initialize it to 1 by default to keep the
> previous behavior.
>
> Note that in builtin/fsck.c and builtin/index-pack.c, when running
> related commands with the '-h' parameter, the 'repo' pointer is not
> passed in. To prevent null pointer dereferences, we defer
> operations on the repo until after parameter parsing is complete.
>
> Additionally, update the partial clone documentation to reflect
> that this is now a per-repository flag.
>
> Mentored-by: Christian Couder <christian.couder@gmail.com>
> Mentored-by: Ayush Chandekar <ayu.chandekar@gmail.com>
> Mentored-by: Olamide Caleb Bello <belkid98@gmail.com>
> Signed-off-by: Tian Yuchen <cat@malon.dev>
> ---
>
> Change since V1:
>
> - Following Patrick's advice, use the_repository whenever possible
> without re-introducing #define USE_THE_REPOSITORY_VARIABLE.
It would be great to include the range-diff compared to the previous
version so that it's easier for the reviewer to spot what's changed.
Tools like b4 automate this for you :)
> diff --git a/builtin/index-pack.c b/builtin/index-pack.c
> index 0793dc595c..74f9694662 100644
> --- a/builtin/index-pack.c
> +++ b/builtin/index-pack.c
> @@ -1898,15 +1898,16 @@ int cmd_index_pack(int argc,
> int report_end_of_input = 0;
> int hash_algo = 0;
>
> + show_usage_if_asked(argc, argv, index_pack_usage);
> +
> /*
> * index-pack never needs to fetch missing objects except when
> * REF_DELTA bases are missing (which are explicitly handled). It only
> * accesses the repo to do hash collision checks and to check which
> * REF_DELTA bases need to be fetched.
> */
> - fetch_if_missing = 0;
> -
> - show_usage_if_asked(argc, argv, index_pack_usage);
> + if (repo)
> + the_repository->fetch_if_missing = 0;
>
> disable_replace_refs();
>
This one looks a bit weird -- we check for `repo`, but then set
`the_repository->fetch_if_missing`. We can probably just loose the
conditional completely, and furthermore we don't need to reorder any
code here at all anymore.
Other than that this patch looks good to me, thanks!
Patrick
next prev parent reply other threads:[~2026-08-04 8:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 1:18 [PATCH v1] repository: move fetch_if_missing into struct repository Tian Yuchen
2026-07-15 3:27 ` Junio C Hamano
2026-07-15 4:58 ` Tian Yuchen
2026-07-15 6:35 ` Patrick Steinhardt
2026-07-16 7:06 ` Tian Yuchen
2026-07-16 15:28 ` Junio C Hamano
2026-07-16 7:29 ` [PATCH v2] " Tian Yuchen
2026-08-01 15:53 ` Tian Yuchen
2026-08-04 8:24 ` Patrick Steinhardt [this message]
2026-08-04 17:38 ` Junio C Hamano
2026-08-05 12:34 ` Tian Yuchen
2026-08-05 12:10 ` Tian Yuchen
2026-08-07 9:41 ` [PATCH v3] " Tian Yuchen
2026-08-07 17:03 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=anGhtfPaGK7v3NNR@pks.im \
--to=ps@pks.im \
--cc=ayu.chandekar@gmail.com \
--cc=belkid98@gmail.com \
--cc=cat@malon.dev \
--cc=christian.couder@gmail.com \
--cc=five231003@gmail.com \
--cc=git@vger.kernel.org \
--cc=hariom18599@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox