From: Elijah Newren Date: Sat, 18 Apr 2026 01:23:13 GMT Subject: Re: [PATCH 15/18] setup: stop using `the_repository` in `check_repository_format()` Message-ID: In-Reply-To: <20260330-pks-setup-wo-the-repository-v1-15-0d2e822837aa@pks.im> On Mon, Mar 30, 2026 at 6:19 AM Patrick Steinhardt wrote: > > Stop using `the_repository` in `check_repository_format()` and instead > accept the repository as a parameter. The injection of `the_repository` > is thus bumped one level higher, where callers now pass it in > explicitly. > > Furthermore, the function is never used outside "setup.c". Drop its > declaration in "setup.h" and make it static. Note that this requires us > to reorder the function. > > Signed-off-by: Patrick Steinhardt > --- > setup.c | 58 +++++++++++++++++++++++++++++++++------------------------- > setup.h | 10 ---------- > 2 files changed, 33 insertions(+), 35 deletions(-) > > diff --git a/setup.c b/setup.c > index 6dbd096f20..c32d6e96bb 100644 > --- a/setup.c > +++ b/setup.c > @@ -1755,6 +1755,37 @@ enum discovery_result discover_git_directory_reason(struct strbuf *commondir, > return result; > } > > +/* > + * Check the repository format version in the path found in repo_get_git_dir(the_repository), Can we make the code comment match the code below, i.e. the_repository -> repo ? > + * and die if it is a version we don't understand. Generally one would > + * set_git_dir() before calling this, and use it only for "are we in a valid > + * repo?". > + * > + * If successful and fmt is not NULL, fill fmt with data. > + */ > +static void check_repository_format(struct repository *repo, struct repository_format *fmt) > +{ > + struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT; > + if (!fmt) > + fmt = &repo_fmt; > + check_repository_format_gently(repo, repo_get_git_dir(repo), fmt, NULL);