setup: stop using `the_repository` in `enter_repo()`
Stop using `the_repository` in `enter_repo()` 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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
May 19, 2026 at 11:52 UTC
ea1d0f886da89edb28a0a64f19e7f4a67a50c6ef
7 files changed
+9
-9
builtin/receive-pack.c
+1
-1
@@ -2643,7 +2643,7 @@ int cmd_receive_pack(int argc,
2643
2644
setup_path();
2645
2646
- if (!enter_repo(service_dir, 0))
2646
+ if (!enter_repo(the_repository, service_dir, 0))
2647
die("'%s' does not appear to be a git repository", service_dir);
2648
2649
repo_config(the_repository, receive_pack_config, NULL);
builtin/upload-archive.c
+1
-1
@@ -31,7 +31,7 @@ int cmd_upload_archive_writer(int argc,
31
if (argc != 2)
32
usage(upload_archive_usage);
33
34
- if (!enter_repo(argv[1], 0))
34
+ if (!enter_repo(the_repository, argv[1], 0))
35
die("'%s' does not appear to be a git repository", argv[1]);
36
37
init_archivers();
builtin/upload-pack.c
+1
-1
@@ -59,7 +59,7 @@ int cmd_upload_pack(int argc,
59
60
if (strict)
61
enter_repo_flags |= ENTER_REPO_STRICT;
62
- if (!enter_repo(dir, enter_repo_flags))
62
+ if (!enter_repo(the_repository, dir, enter_repo_flags))
63
die("'%s' does not appear to be a git repository", dir);
64
65
switch (determine_protocol_version_server()) {
daemon.c
+2
-2
@@ -244,14 +244,14 @@ static const char *path_ok(const char *directory, struct hostinfo *hi)
244
}
245
246
enter_repo_flags = strict_paths ? ENTER_REPO_STRICT : 0;
247
- path = enter_repo(dir, enter_repo_flags);
247
+ path = enter_repo(the_repository, dir, enter_repo_flags);
248
if (!path && base_path && base_path_relaxed) {
249
/*
250
* if we fail and base_path_relaxed is enabled, try without
251
* prefixing the base path
252
*/
253
dir = directory;
254
- path = enter_repo(dir, enter_repo_flags);
254
+ path = enter_repo(the_repository, dir, enter_repo_flags);
255
}
256
257
if (!path) {
http-backend.c
+1
-1
@@ -809,7 +809,7 @@ int cmd_main(int argc UNUSED, const char **argv UNUSED)
809
not_found(&hdr, "Request not supported: '%s'", dir);
810
811
setup_path();
812
- if (!enter_repo(dir, 0))
812
+ if (!enter_repo(the_repository, dir, 0))
813
not_found(&hdr, "Not a git repository: '%s'", dir);
814
if (!getenv("GIT_HTTP_EXPORT_ALL") &&
815
access("git-daemon-export-ok", F_OK) )
setup.c
+2
-2
@@ -1765,7 +1765,7 @@ enum discovery_result discover_git_directory_reason(struct strbuf *commondir,
1765
return result;
1766
}
1767
1768
-const char *enter_repo(const char *path, unsigned flags)
1768
+const char *enter_repo(struct repository *repo, const char *path, unsigned flags)
1769
{
1770
static struct strbuf validated_path = STRBUF_INIT;
1771
static struct strbuf used_path = STRBUF_INIT;
@@ -1838,7 +1838,7 @@ const char *enter_repo(const char *path, unsigned flags)
1838
}
1839
1840
if (is_git_directory(".")) {
1841
- set_git_dir(the_repository, ".", 0);
1841
+ set_git_dir(repo, ".", 0);
1842
check_repository_format(NULL);
1843
return path;
1844
}
setup.h
+1
-1
@@ -134,7 +134,7 @@ enum {
134
* links. User relative paths are also returned as they are given,
135
* except DWIM suffixing.
136
*/
137
-const char *enter_repo(const char *path, unsigned flags);
137
+const char *enter_repo(struct repository *repo, const char *path, unsigned flags);
138
139
const char *setup_git_directory_gently(int *);
140
const char *setup_git_directory(void);