Git development
 help / color / mirror / Atom feed
* [PATCH 00/18] setup: drop uses of `the_repository`
@ 2026-03-30 13:17 Patrick Steinhardt
  2026-03-30 13:17 ` [PATCH 01/18] setup: replace use of `the_repository` in static functions Patrick Steinhardt
                   ` (18 more replies)
  0 siblings, 19 replies; 32+ messages in thread
From: Patrick Steinhardt @ 2026-03-30 13:17 UTC (permalink / raw)
  To: git

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.

Thanks!

Patrick

---
Patrick Steinhardt (18):
      setup: replace use of `the_repository` in static functions
      setup: stop using `the_repository` in `is_inside_worktree()`
      setup: stop using `the_repository` in `is_inside_git_dir()`
      setup: stop using `the_repository` in `prefix_path()`
      setup: stop using `the_repository` in `path_inside_repo()`
      setup: stop using `the_repository` in `verify_filename()`
      setup: stop using `the_repository` in `verify_non_filename()`
      setup: stop using `the_repository` in `enter_repo()`
      setup: stop using `the_repository` in `setup_work_tree()`
      setup: stop using `the_repository` in `set_git_work_tree()`
      setup: stop using `the_repository` in `setup_git_env()`
      setup: stop using `the_repository` in `setup_git_directory_gently()`
      setup: stop using `the_repository` in `setup_git_directory()`
      setup: stop using `the_repository` in `upgrade_repository_format()`
      setup: stop using `the_repository` in `check_repository_format()`
      setup: stop using `the_repository` in `initialize_repository_version()`
      setup: stop using `the_repository` in `create_reference_database()`
      setup: stop using `the_repository` in `init_db()`

 archive.c                                    |   2 +-
 blame.c                                      |   2 +-
 builtin/blame.c                              |   2 +-
 builtin/check-attr.c                         |   4 +-
 builtin/check-ref-format.c                   |   5 +-
 builtin/checkout-index.c                     |   4 +-
 builtin/checkout.c                           |   2 +-
 builtin/clone.c                              |  12 +-
 builtin/describe.c                           |   2 +-
 builtin/diff-index.c                         |   2 +-
 builtin/diff.c                               |  10 +-
 builtin/difftool.c                           |   2 +-
 builtin/grep.c                               |   8 +-
 builtin/hash-object.c                        |   4 +-
 builtin/help.c                               |   2 +-
 builtin/init-db.c                            |   8 +-
 builtin/ls-files.c                           |   4 +-
 builtin/merge-file.c                         |   2 +-
 builtin/mv.c                                 |   5 +-
 builtin/read-tree.c                          |   2 +-
 builtin/receive-pack.c                       |   2 +-
 builtin/reset.c                              |   6 +-
 builtin/rev-parse.c                          |  14 +-
 builtin/rm.c                                 |   2 +-
 builtin/sparse-checkout.c                    |  19 +-
 builtin/stripspace.c                         |   2 +-
 builtin/submodule--helper.c                  |   2 +-
 builtin/update-index.c                       |  16 +-
 builtin/upload-archive.c                     |   2 +-
 builtin/upload-pack.c                        |   2 +-
 daemon.c                                     |   4 +-
 environment.h                                |   2 -
 git.c                                        |  10 +-
 http-backend.c                               |   2 +-
 http-fetch.c                                 |   2 +-
 http-push.c                                  |   2 +-
 imap-send.c                                  |   2 +-
 line-log.c                                   |   2 +-
 list-objects-filter-options.c                |   2 +-
 object-name.c                                |   4 +-
 pathspec.c                                   |   2 +-
 refs.c                                       |   2 +-
 remote-curl.c                                |   4 +-
 repository.h                                 |   4 +-
 revision.c                                   |   6 +-
 scalar.c                                     |   4 +-
 setup.c                                      | 436 ++++++++++++++-------------
 setup.h                                      |  43 ++-
 submodule.c                                  |   2 +-
 t/helper/test-advise.c                       |   2 +-
 t/helper/test-bitmap.c                       |   2 +-
 t/helper/test-bloom.c                        |   2 +-
 t/helper/test-cache-tree.c                   |   2 +-
 t/helper/test-config.c                       |   2 +-
 t/helper/test-dump-cache-tree.c              |   2 +-
 t/helper/test-dump-fsmonitor.c               |   2 +-
 t/helper/test-dump-split-index.c             |   2 +-
 t/helper/test-dump-untracked-cache.c         |   2 +-
 t/helper/test-find-pack.c                    |   2 +-
 t/helper/test-fsmonitor-client.c             |   2 +-
 t/helper/test-lazy-init-name-hash.c          |   2 +-
 t/helper/test-match-trees.c                  |   2 +-
 t/helper/test-pack-deltas.c                  |   2 +-
 t/helper/test-pack-mtimes.c                  |   2 +-
 t/helper/test-partial-clone.c                |   4 +-
 t/helper/test-path-utils.c                   |   4 +-
 t/helper/test-path-walk.c                    |   2 +-
 t/helper/test-reach.c                        |   2 +-
 t/helper/test-read-cache.c                   |   2 +-
 t/helper/test-read-graph.c                   |   2 +-
 t/helper/test-read-midx.c                    |   2 +-
 t/helper/test-ref-store.c                    |   2 +-
 t/helper/test-revision-walking.c             |   2 +-
 t/helper/test-scrap-cache-tree.c             |   2 +-
 t/helper/test-serve-v2.c                     |   2 +-
 t/helper/test-submodule-config.c             |   2 +-
 t/helper/test-submodule-nested-repo-config.c |   2 +-
 t/helper/test-submodule.c                    |  10 +-
 t/helper/test-subprocess.c                   |   6 +-
 t/helper/test-userdiff.c                     |   2 +-
 t/helper/test-write-cache.c                  |   2 +-
 worktree.c                                   |   2 +-
 wt-status.c                                  |   2 +-
 83 files changed, 393 insertions(+), 377 deletions(-)


---
base-commit: 5361983c075154725be47b65cca9a2421789e410
change-id: 20260330-pks-setup-wo-the-repository-81e51bc55b91


^ permalink raw reply	[flat|nested] 32+ messages in thread
* [PATCH 00/18] setup: drop uses of `the_repository`
@ 2026-04-20  8:22 Patrick Steinhardt
  2026-04-20  8:22 ` [PATCH 03/18] setup: stop using `the_repository` in `is_inside_git_dir()` Patrick Steinhardt
  0 siblings, 1 reply; 32+ messages in thread
From: Patrick Steinhardt @ 2026-04-20  8:22 UTC (permalink / raw)
  To: git; +Cc: Karthik Nayak, Elijah Newren, Junio C Hamano

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!

Patrick

---
Patrick Steinhardt (18):
      setup: replace use of `the_repository` in static functions
      setup: stop using `the_repository` in `is_inside_worktree()`
      setup: stop using `the_repository` in `is_inside_git_dir()`
      setup: stop using `the_repository` in `prefix_path()`
      setup: stop using `the_repository` in `path_inside_repo()`
      setup: stop using `the_repository` in `verify_filename()`
      setup: stop using `the_repository` in `verify_non_filename()`
      setup: stop using `the_repository` in `enter_repo()`
      setup: stop using `the_repository` in `setup_work_tree()`
      setup: stop using `the_repository` in `set_git_work_tree()`
      setup: stop using `the_repository` in `setup_git_env()`
      setup: stop using `the_repository` in `setup_git_directory_gently()`
      setup: stop using `the_repository` in `setup_git_directory()`
      setup: stop using `the_repository` in `upgrade_repository_format()`
      setup: stop using `the_repository` in `check_repository_format()`
      setup: stop using `the_repository` in `initialize_repository_version()`
      setup: stop using `the_repository` in `create_reference_database()`
      setup: stop using `the_repository` in `init_db()`

 archive.c                                    |   2 +-
 blame.c                                      |   2 +-
 builtin/blame.c                              |   2 +-
 builtin/check-attr.c                         |   4 +-
 builtin/check-ref-format.c                   |   5 +-
 builtin/checkout-index.c                     |   4 +-
 builtin/checkout.c                           |   2 +-
 builtin/clone.c                              |  12 +-
 builtin/describe.c                           |   2 +-
 builtin/diff-index.c                         |   2 +-
 builtin/diff.c                               |  10 +-
 builtin/difftool.c                           |   2 +-
 builtin/grep.c                               |   8 +-
 builtin/hash-object.c                        |   4 +-
 builtin/help.c                               |   2 +-
 builtin/init-db.c                            |   8 +-
 builtin/ls-files.c                           |   4 +-
 builtin/merge-file.c                         |   2 +-
 builtin/mv.c                                 |   5 +-
 builtin/read-tree.c                          |   2 +-
 builtin/receive-pack.c                       |   2 +-
 builtin/reset.c                              |   6 +-
 builtin/rev-parse.c                          |  14 +-
 builtin/rm.c                                 |   2 +-
 builtin/sparse-checkout.c                    |  19 +-
 builtin/stripspace.c                         |   2 +-
 builtin/submodule--helper.c                  |   2 +-
 builtin/update-index.c                       |  16 +-
 builtin/upload-archive.c                     |   2 +-
 builtin/upload-pack.c                        |   2 +-
 daemon.c                                     |   4 +-
 environment.h                                |   2 -
 git.c                                        |  10 +-
 http-backend.c                               |   2 +-
 http-fetch.c                                 |   2 +-
 http-push.c                                  |   2 +-
 imap-send.c                                  |   2 +-
 line-log.c                                   |   2 +-
 list-objects-filter-options.c                |   2 +-
 object-name.c                                |   4 +-
 pathspec.c                                   |   2 +-
 refs.c                                       |   2 +-
 remote-curl.c                                |   4 +-
 repository.h                                 |   4 +-
 revision.c                                   |   6 +-
 scalar.c                                     |   4 +-
 setup.c                                      | 442 ++++++++++++++-------------
 setup.h                                      |  43 ++-
 submodule.c                                  |   2 +-
 t/helper/test-advise.c                       |   2 +-
 t/helper/test-bitmap.c                       |   2 +-
 t/helper/test-bloom.c                        |   2 +-
 t/helper/test-cache-tree.c                   |   2 +-
 t/helper/test-config.c                       |   2 +-
 t/helper/test-dump-cache-tree.c              |   2 +-
 t/helper/test-dump-fsmonitor.c               |   2 +-
 t/helper/test-dump-split-index.c             |   2 +-
 t/helper/test-dump-untracked-cache.c         |   2 +-
 t/helper/test-find-pack.c                    |   2 +-
 t/helper/test-fsmonitor-client.c             |   2 +-
 t/helper/test-lazy-init-name-hash.c          |   2 +-
 t/helper/test-match-trees.c                  |   2 +-
 t/helper/test-pack-deltas.c                  |   2 +-
 t/helper/test-pack-mtimes.c                  |   2 +-
 t/helper/test-partial-clone.c                |   4 +-
 t/helper/test-path-utils.c                   |   4 +-
 t/helper/test-path-walk.c                    |   2 +-
 t/helper/test-reach.c                        |   2 +-
 t/helper/test-read-cache.c                   |   2 +-
 t/helper/test-read-graph.c                   |   2 +-
 t/helper/test-read-midx.c                    |   2 +-
 t/helper/test-ref-store.c                    |   2 +-
 t/helper/test-revision-walking.c             |   2 +-
 t/helper/test-scrap-cache-tree.c             |   2 +-
 t/helper/test-serve-v2.c                     |   2 +-
 t/helper/test-submodule-config.c             |   2 +-
 t/helper/test-submodule-nested-repo-config.c |   2 +-
 t/helper/test-submodule.c                    |  10 +-
 t/helper/test-subprocess.c                   |   6 +-
 t/helper/test-userdiff.c                     |   2 +-
 t/helper/test-write-cache.c                  |   2 +-
 worktree.c                                   |   2 +-
 wt-status.c                                  |   2 +-
 83 files changed, 393 insertions(+), 383 deletions(-)


---
base-commit: 5361983c075154725be47b65cca9a2421789e410
change-id: 20260330-pks-setup-wo-the-repository-81e51bc55b91


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2026-04-20  8:22 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-30 13:17 [PATCH 00/18] setup: drop uses of `the_repository` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 01/18] setup: replace use of `the_repository` in static functions Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 02/18] setup: stop using `the_repository` in `is_inside_worktree()` Patrick Steinhardt
2026-04-09 11:55   ` Karthik Nayak
2026-03-30 13:17 ` [PATCH 03/18] setup: stop using `the_repository` in `is_inside_git_dir()` Patrick Steinhardt
2026-04-09 12:58   ` Karthik Nayak
2026-04-13  5:47     ` Patrick Steinhardt
2026-04-13 15:36       ` Junio C Hamano
2026-03-30 13:17 ` [PATCH 04/18] setup: stop using `the_repository` in `prefix_path()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 05/18] setup: stop using `the_repository` in `path_inside_repo()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 06/18] setup: stop using `the_repository` in `verify_filename()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 07/18] setup: stop using `the_repository` in `verify_non_filename()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 08/18] setup: stop using `the_repository` in `enter_repo()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 09/18] setup: stop using `the_repository` in `setup_work_tree()` Patrick Steinhardt
2026-04-18  1:11   ` Elijah Newren
2026-04-20  7:06     ` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 10/18] setup: stop using `the_repository` in `set_git_work_tree()` Patrick Steinhardt
2026-04-18  1:16   ` Elijah Newren
2026-04-20  7:06     ` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 11/18] setup: stop using `the_repository` in `setup_git_env()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 12/18] setup: stop using `the_repository` in `setup_git_directory_gently()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 13/18] setup: stop using `the_repository` in `setup_git_directory()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 14/18] setup: stop using `the_repository` in `upgrade_repository_format()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 15/18] setup: stop using `the_repository` in `check_repository_format()` Patrick Steinhardt
2026-04-18  1:23   ` Elijah Newren
2026-04-20  7:06     ` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 16/18] setup: stop using `the_repository` in `initialize_repository_version()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 17/18] setup: stop using `the_repository` in `create_reference_database()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 18/18] setup: stop using `the_repository` in `init_db()` Patrick Steinhardt
2026-04-09 13:05 ` [PATCH 00/18] setup: drop uses of `the_repository` Karthik Nayak
2026-04-13  5:48   ` Patrick Steinhardt
  -- strict thread matches above, loose matches on Subject: below --
2026-04-20  8:22 Patrick Steinhardt
2026-04-20  8:22 ` [PATCH 03/18] setup: stop using `the_repository` in `is_inside_git_dir()` Patrick Steinhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox