]> git.ipfire.org Git - thirdparty/git.git/commitdiff
setup: stop using `the_repository` in `enter_repo()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 19 May 2026 09:52:12 +0000 (11:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 May 2026 10:36:24 +0000 (19:36 +0900)
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>
builtin/receive-pack.c
builtin/upload-archive.c
builtin/upload-pack.c
daemon.c
http-backend.c
setup.c
setup.h

index f0771590a73ef02aa945d2c67f2bc04d2652518c..322d178c926452dd9abca99adda5645ad183e7b2 100644 (file)
@@ -2643,7 +2643,7 @@ int cmd_receive_pack(int argc,
 
        setup_path();
 
-       if (!enter_repo(service_dir, 0))
+       if (!enter_repo(the_repository, service_dir, 0))
                die("'%s' does not appear to be a git repository", service_dir);
 
        repo_config(the_repository, receive_pack_config, NULL);
index 25312bb2a528878a03071bddcbc7ced7eb479d0d..718e74b3acf85d0a4e6cdb0e696f6f2d1c5cf923 100644 (file)
@@ -31,7 +31,7 @@ int cmd_upload_archive_writer(int argc,
        if (argc != 2)
                usage(upload_archive_usage);
 
-       if (!enter_repo(argv[1], 0))
+       if (!enter_repo(the_repository, argv[1], 0))
                die("'%s' does not appear to be a git repository", argv[1]);
 
        init_archivers();
index 30498fafea3a8b024b5cc8a8d2da7948325ac6c5..32831fb8796acc940e681b4bd4e5c881c126fc61 100644 (file)
@@ -59,7 +59,7 @@ int cmd_upload_pack(int argc,
 
        if (strict)
                enter_repo_flags |= ENTER_REPO_STRICT;
-       if (!enter_repo(dir, enter_repo_flags))
+       if (!enter_repo(the_repository, dir, enter_repo_flags))
                die("'%s' does not appear to be a git repository", dir);
 
        switch (determine_protocol_version_server()) {
index 0a7b1aae447912aadfbbedea9bd10e6b5dddf7f9..947dd906554963092705b4a9f8bba565ecbb6b92 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -244,14 +244,14 @@ static const char *path_ok(const char *directory, struct hostinfo *hi)
        }
 
        enter_repo_flags = strict_paths ? ENTER_REPO_STRICT : 0;
-       path = enter_repo(dir, enter_repo_flags);
+       path = enter_repo(the_repository, dir, enter_repo_flags);
        if (!path && base_path && base_path_relaxed) {
                /*
                 * if we fail and base_path_relaxed is enabled, try without
                 * prefixing the base path
                 */
                dir = directory;
-               path = enter_repo(dir, enter_repo_flags);
+               path = enter_repo(the_repository, dir, enter_repo_flags);
        }
 
        if (!path) {
index 1a171c5c5a0b02e9810bf69b62992e523da9cc35..c7566b1d12d35fff93a9a2d0ebbf4be0aa295257 100644 (file)
@@ -809,7 +809,7 @@ int cmd_main(int argc UNUSED, const char **argv UNUSED)
                not_found(&hdr, "Request not supported: '%s'", dir);
 
        setup_path();
-       if (!enter_repo(dir, 0))
+       if (!enter_repo(the_repository, dir, 0))
                not_found(&hdr, "Not a git repository: '%s'", dir);
        if (!getenv("GIT_HTTP_EXPORT_ALL") &&
            access("git-daemon-export-ok", F_OK) )
diff --git a/setup.c b/setup.c
index 759aba4e2c9fe55ec2e3a7625dc73c181bf10b34..cb479cd91a871bb8f164bb46b1ca21aa2858a2fa 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1765,7 +1765,7 @@ enum discovery_result discover_git_directory_reason(struct strbuf *commondir,
        return result;
 }
 
-const char *enter_repo(const char *path, unsigned flags)
+const char *enter_repo(struct repository *repo, const char *path, unsigned flags)
 {
        static struct strbuf validated_path = STRBUF_INIT;
        static struct strbuf used_path = STRBUF_INIT;
@@ -1838,7 +1838,7 @@ const char *enter_repo(const char *path, unsigned flags)
        }
 
        if (is_git_directory(".")) {
-               set_git_dir(the_repository, ".", 0);
+               set_git_dir(repo, ".", 0);
                check_repository_format(NULL);
                return path;
        }
diff --git a/setup.h b/setup.h
index 364c2c728a69d6bc2955f538c6bdddd2ff0961fc..d0cfdfd44a67a84f52679a8044b9fcb74a400e48 100644 (file)
--- a/setup.h
+++ b/setup.h
@@ -134,7 +134,7 @@ enum {
  * links.  User relative paths are also returned as they are given,
  * except DWIM suffixing.
  */
-const char *enter_repo(const char *path, unsigned flags);
+const char *enter_repo(struct repository *repo, const char *path, unsigned flags);
 
 const char *setup_git_directory_gently(int *);
 const char *setup_git_directory(void);