git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 14/18] setup: stop using `the_repository` in `upgrade_repository_format()`

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 30, 2026, 13:17 UTC
Message-ID
<20260330-pks-setup-wo-the-repository-v1-14-0d2e822837aa@pks.im>
In-Reply-To
<20260330-pks-setup-wo-the-repository-v1-0-0d2e822837aa@pks.im>

Stop using `the_repository` in `upgrade_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.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 list-objects-filter-options.c | 2 +-
 repository.h                  | 2 +-
 setup.c                       | 6 +++---
 worktree.c                    | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
index cef67e5919..bc5d98f9e6 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
@@ -378,7 +378,7 @@ void partial_clone_register(
 			 */
 			return;
 	} else {
-		if (upgrade_repository_format(1) < 0)
+		if (upgrade_repository_format(the_repository, 1) < 0)
 			die(_("unable to upgrade repository format to support partial clone"));
 
 		/* Add promisor config for the remote */
diff --git a/repository.h b/repository.h
index 7ae3d34484..bb83d03bbf 100644
--- a/repository.h
+++ b/repository.h
@@ -271,6 +271,6 @@ void repo_update_index_if_able(struct repository *, struct lock_file *);
  * Return 1 if upgrade repository format to target_version succeeded,
  * 0 if no upgrade is necessary, and -1 when upgrade is not possible.
  */
-int upgrade_repository_format(int target_version);
+int upgrade_repository_format(struct repository *repo, int target_version);
 
 #endif /* REPOSITORY_H */
diff --git a/setup.c b/setup.c
index da0576d28a..6dbd096f20 100644
--- a/setup.c
+++ b/setup.c
@@ -808,7 +808,7 @@ static int check_repository_format_gently(struct repository *repo,
 	return 0;
 }
 
-int upgrade_repository_format(int target_version)
+int upgrade_repository_format(struct repository *repo, int target_version)
 {
 	struct strbuf sb = STRBUF_INIT;
 	struct strbuf err = STRBUF_INIT;
@@ -816,7 +816,7 @@ int upgrade_repository_format(int target_version)
 	struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
 	int ret;
 
-	repo_common_path_append(the_repository, &sb, "config");
+	repo_common_path_append(repo, &sb, "config");
 	read_repository_format(&repo_fmt, sb.buf);
 	strbuf_release(&sb);
 
@@ -838,7 +838,7 @@ int upgrade_repository_format(int target_version)
 	}
 
 	strbuf_addf(&repo_version, "%d", target_version);
-	repo_config_set(the_repository, "core.repositoryformatversion", repo_version.buf);
+	repo_config_set(repo, "core.repositoryformatversion", repo_version.buf);
 
 	ret = 1;
 
diff --git a/worktree.c b/worktree.c
index 56732f8f33..8ca0a172c6 100644
--- a/worktree.c
+++ b/worktree.c
@@ -1104,7 +1104,7 @@ void write_worktree_linking_files(const char *dotgit, const char *gitdir,
 	strbuf_realpath(&repo, repo.buf, 1);
 
 	if (use_relative_paths && !the_repository->repository_format_relative_worktrees) {
-		if (upgrade_repository_format(1) < 0)
+		if (upgrade_repository_format(the_repository, 1) < 0)
 			die(_("unable to upgrade repository format to support relative worktrees"));
 		if (repo_config_set_gently(the_repository, "extensions.relativeWorktrees", "true"))
 			die(_("unable to set extensions.relativeWorktrees setting"));
-- 
2.53.0.1185.g05d4b7b318.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 23 of 31 in “setup: drop uses of `the_repository`”
  1. 00/18 setup: drop uses of `the_repository`Patrick Steinhardt, Mar 30, 2026
  2. 01/18 setup: replace use of `the_repository` in static functionsPatrick Steinhardt, Mar 30, 2026
  3. 02/18 setup: stop using `the_repository` in `is_inside_worktree()`Patrick Steinhardt, Mar 30, 2026
  4. Karthik NayakApr 9, 2026
  5. 03/18 setup: stop using `the_repository` in `is_inside_git_dir()`Patrick Steinhardt, Mar 30, 2026
  6. Karthik NayakApr 9, 2026
  7. Patrick SteinhardtApr 13, 2026
  8. Junio C HamanoApr 13, 2026
  9. 04/18 setup: stop using `the_repository` in `prefix_path()`Patrick Steinhardt, Mar 30, 2026
  10. 05/18 setup: stop using `the_repository` in `path_inside_repo()`Patrick Steinhardt, Mar 30, 2026
  11. 06/18 setup: stop using `the_repository` in `verify_filename()`Patrick Steinhardt, Mar 30, 2026
  12. 07/18 setup: stop using `the_repository` in `verify_non_filename()`Patrick Steinhardt, Mar 30, 2026
  13. 08/18 setup: stop using `the_repository` in `enter_repo()`Patrick Steinhardt, Mar 30, 2026
  14. 09/18 setup: stop using `the_repository` in `setup_work_tree()`Patrick Steinhardt, Mar 30, 2026
  15. Elijah NewrenApr 18, 2026
  16. Patrick SteinhardtApr 20, 2026
  17. 10/18 setup: stop using `the_repository` in `set_git_work_tree()`Patrick Steinhardt, Mar 30, 2026
  18. Elijah NewrenApr 18, 2026
  19. Patrick SteinhardtApr 20, 2026
  20. 11/18 setup: stop using `the_repository` in `setup_git_env()`Patrick Steinhardt, Mar 30, 2026
  21. 12/18 setup: stop using `the_repository` in `setup_git_directory_gently()`Patrick Steinhardt, Mar 30, 2026
  22. 13/18 setup: stop using `the_repository` in `setup_git_directory()`Patrick Steinhardt, Mar 30, 2026
  23. 14/18 setup: stop using `the_repository` in `upgrade_repository_format()`Patrick Steinhardt, Mar 30, 2026
  24. 15/18 setup: stop using `the_repository` in `check_repository_format()`Patrick Steinhardt, Mar 30, 2026
  25. Elijah NewrenApr 18, 2026
  26. Patrick SteinhardtApr 20, 2026
  27. 16/18 setup: stop using `the_repository` in `initialize_repository_version()`Patrick Steinhardt, Mar 30, 2026
  28. 17/18 setup: stop using `the_repository` in `create_reference_database()`Patrick Steinhardt, Mar 30, 2026
  29. 18/18 setup: stop using `the_repository` in `init_db()`Patrick Steinhardt, Mar 30, 2026
  30. Karthik NayakApr 9, 2026
  31. Patrick SteinhardtApr 13, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.