Re: [PATCH 00/18] setup: drop uses of `the_repository`
- From
Elijah Newren <newren@gmail.com>
- Date
- Apr 20, 2026, 15:50 UTC
- Message-ID
- <CABPp-BHOVhQPL4ScA+sJCvE2OYXjLJSyDim5AocbcqoxzObGxQ@mail.gmail.com>
- In-Reply-To
- <20260420-pks-setup-wo-the-repository-v1-0-f4a81c4988e8@pks.im>
On Mon, Apr 20, 2026 at 1:22 AM Patrick Steinhardt <ps@pks.im> wrote:
Show 39 quoted lines
> > Hi, > > I've had enough of "setup.c" and its complexities, so I finally decided > to take the bullet and start refactoring this subsystem. This here is > the first out of the following three steps: > > 1. Drop all uses of `the_repository`. This doesn't yet allow us to get > rid of `USE_THE_REPOSITORY_VARIABLE`. > > 2. Convert a couple of global variables and drop > `is_bare_repository_cfg`, which then allows us to drop > `USE_THE_REPOSITORY_VARIABLE`. > > 3. Refactor the subsystem a bit so that we stop intermixing repository > discovery and repository initialization. This is my original > motivation as I want to get rid of `odb_prepare_alternates()`, but > due to the way we initialize the repository it has proven to be > extremely tedious. > > Most of the patches in this series here are rather mechanical. There's > only a handful of patches that warrant more attention: > > - 2/18: setup: stop using `the_repository` in `is_inside_worktree()` > - 3/18: setup: stop using `the_repository` in `is_inside_git_dir()` > - 9/18: setup: stop using `the_repository` in `setup_work_tree()` > - 10/18: setup: stop using `the_repository` in `set_git_work_tree()` > > Those patches don't only mechanical move stuff around, but also change > some logic to make it work. > > The series is based on 5361983c07 (The 22nd batch, 2026-03-27). There is > a single merge commit with "seen", but it's trivial to resolve. > > Changes in v2: > - Remove static `initialized` variable in `setup_work_tree()`. > - Use enum values to initialize fields. > - Fix up a comment. > - Link to v1: https://lore.kernel.org/all/20260330-pks-setup-wo-the-repository-v1-0-0d2e822837aa@pks.im/
Thanks, I would have preferred this series to have used the "PATCH v2" prefix and for its cover letter to be sent in-response-to the cover letter of v1, but those are nitpicks that don't affect the overall series.
I thought to check one additional thing I didn't check when reviewing v1. I looked for all cases where this series added "the_repository" to some function between the beginning and end of the series, and for which the function where the code was found already had a repo/repository parameter. There were several of these in builtins, but those are already littered with cases where cmd_foo() has a repository parameter declared UNUSED and where we use the_repository anyway. Those should be cleaned up, but that's outside the scope of this series. However, I did spot one non-builtin case: in patch 16, repo_migrate_ref_storage_format() already has a repo parameter, so your call to initialize_repository_version() can use it instead of the_repository.
Other than that small issue, I think this series is ready.