]> git.ipfire.org Git - thirdparty/git.git/commitdiff
setup: stop using `the_repository` in `verify_filename()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 19 May 2026 09:52:10 +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 `verify_filename()` 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/grep.c
builtin/reset.c
builtin/rev-parse.c
revision.c
setup.c
setup.h

index e33285e5e692894abca9977939805042cf3f6810..b0e350cf8938fb1706046247a9282503db4508ff 100644 (file)
@@ -1163,7 +1163,7 @@ int cmd_grep(int argc,
        if (!seen_dashdash) {
                int j;
                for (j = i; j < argc; j++)
-                       verify_filename(prefix, argv[j], j == i && allow_revs);
+                       verify_filename(the_repository, prefix, argv[j], j == i && allow_revs);
        }
 
        parse_pathspec(&pathspec, 0,
index 3590be57a5f03c5ff7e881e0889c1ac9dbd7a99f..1ac374d31b9a5ee1242a3cf47a87f5ae5008e768 100644 (file)
@@ -285,7 +285,7 @@ static void parse_args(struct pathspec *pathspec,
                        rev = *argv++;
                } else {
                        /* Otherwise we treat this as a filename */
-                       verify_filename(prefix, argv[0], 1);
+                       verify_filename(the_repository, prefix, argv[0], 1);
                }
        }
 
index 2fcd6851d183974abf037df31380b171a55b3af8..8fdb75413d33a6ac139845b1100cd281f903f178 100644 (file)
@@ -749,7 +749,7 @@ int cmd_rev_parse(int argc,
 
                if (as_is) {
                        if (show_file(arg, output_prefix) && as_is < 2)
-                               verify_filename(prefix, arg, 0);
+                               verify_filename(the_repository, prefix, arg, 0);
                        continue;
                }
 
@@ -1173,7 +1173,7 @@ int cmd_rev_parse(int argc,
                as_is = 1;
                if (!show_file(arg, output_prefix))
                        continue;
-               verify_filename(prefix, arg, 1);
+               verify_filename(the_repository, prefix, arg, 1);
        }
        strbuf_release(&buf);
        if (verify) {
index 599b3a66c369ca3b0099311250cf758788fdf6ce..5d5324437969e929b72f382329eadf7fb1a4bf3b 100644 (file)
@@ -3067,7 +3067,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
                         * but the latter we have checked in the main loop.
                         */
                        for (j = i; j < argc; j++)
-                               verify_filename(revs->prefix, argv[j], j == i);
+                               verify_filename(the_repository, revs->prefix, argv[j], j == i);
 
                        strvec_pushv(&prune_data, argv + i);
                        break;
diff --git a/setup.c b/setup.c
index 4ef6216e829d3fbe11b7bf877ba569d9f613c164..e673663cabb582d0f8633ad9c7b09a74fd46b7da 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -280,7 +280,8 @@ static int looks_like_pathspec(const char *arg)
  * diagnose_misspelt_rev == 0 for the next ones (because we already
  * saw a filename, there's not ambiguity anymore).
  */
-void verify_filename(const char *prefix,
+void verify_filename(struct repository *repo,
+                    const char *prefix,
                     const char *arg,
                     int diagnose_misspelt_rev)
 {
@@ -288,7 +289,7 @@ void verify_filename(const char *prefix,
                die(_("option '%s' must come before non-option arguments"), arg);
        if (looks_like_pathspec(arg) || check_filename(prefix, arg))
                return;
-       die_verify_filename(the_repository, prefix, arg, diagnose_misspelt_rev);
+       die_verify_filename(repo, prefix, arg, diagnose_misspelt_rev);
 }
 
 /*
diff --git a/setup.h b/setup.h
index c3247d7fc8d4b7787510a59352f9672a4122cc42..24a6f666294b714c5da78eb9813914f925d07e6f 100644 (file)
--- a/setup.h
+++ b/setup.h
@@ -142,7 +142,8 @@ char *prefix_path(struct repository *repo, const char *prefix, int len, const ch
 char *prefix_path_gently(struct repository *repo, const char *prefix, int len, int *remaining, const char *path);
 
 int check_filename(const char *prefix, const char *name);
-void verify_filename(const char *prefix,
+void verify_filename(struct repository *repo,
+                    const char *prefix,
                     const char *name,
                     int diagnose_misspelt_rev);
 void verify_non_filename(const char *prefix, const char *name);