]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/refs: drop `the_repository`
authorPatrick Steinhardt <ps@pks.im>
Wed, 17 Jun 2026 10:15:58 +0000 (12:15 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Jun 2026 12:23:54 +0000 (05:23 -0700)
We still have a couple of uses of `the_repository` in "builtin/refs.c".
All of those are trivial to convert though as the command always
requires a repository to exist.

Convert them to use the passed-in repository and drop
`USE_THE_REPOSITORY_VARIABLE`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/refs.c

index e3125bc61b20e07a776e13ce1d4417bc860dbbfd..f0faabf45a9048de560d7f3b2eedf6839b4c8c79 100644 (file)
@@ -1,4 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
 #include "config.h"
 #include "fsck.h"
@@ -23,7 +22,7 @@
        N_("git refs optimize " PACK_REFS_OPTS)
 
 static int cmd_refs_migrate(int argc, const char **argv, const char *prefix,
-                           struct repository *repo UNUSED)
+                           struct repository *repo)
 {
        const char * const migrate_usage[] = {
                REFS_MIGRATE_USAGE,
@@ -59,13 +58,13 @@ static int cmd_refs_migrate(int argc, const char **argv, const char *prefix,
                goto out;
        }
 
-       if (the_repository->ref_storage_format == format) {
+       if (repo->ref_storage_format == format) {
                err = error(_("repository already uses '%s' format"),
                            ref_storage_format_to_name(format));
                goto out;
        }
 
-       if (repo_migrate_ref_storage_format(the_repository, format, flags, &errbuf) < 0) {
+       if (repo_migrate_ref_storage_format(repo, format, flags, &errbuf) < 0) {
                err = error("%s", errbuf.buf);
                goto out;
        }
@@ -99,8 +98,8 @@ static int cmd_refs_verify(int argc, const char **argv, const char *prefix,
        if (argc)
                usage(_("'git refs verify' takes no arguments"));
 
-       repo_config(the_repository, git_fsck_config, &fsck_refs_options);
-       prepare_repo_settings(the_repository);
+       repo_config(repo, git_fsck_config, &fsck_refs_options);
+       prepare_repo_settings(repo);
 
        worktrees = get_worktrees_without_reading_head();
        for (size_t i = 0; worktrees[i]; i++)
@@ -124,7 +123,7 @@ static int cmd_refs_list(int argc, const char **argv, const char *prefix,
 }
 
 static int cmd_refs_exists(int argc, const char **argv, const char *prefix,
-                          struct repository *repo UNUSED)
+                          struct repository *repo)
 {
        struct strbuf unused_referent = STRBUF_INIT;
        struct object_id unused_oid;
@@ -145,7 +144,7 @@ static int cmd_refs_exists(int argc, const char **argv, const char *prefix,
                die(_("'git refs exists' requires a reference"));
 
        ref = *argv++;
-       if (refs_read_raw_ref(get_main_ref_store(the_repository), ref,
+       if (refs_read_raw_ref(get_main_ref_store(repo), ref,
                              &unused_oid, &unused_referent, &unused_type,
                              &failure_errno)) {
                if (failure_errno == ENOENT || failure_errno == EISDIR) {