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

index 1345e8574a79c83ee4862688e11f14eb50939673..f82adcb740287ebbce152bf2ff415c5dccb1ebc2 100644 (file)
@@ -1484,7 +1484,7 @@ static int parse_branchname_arg(int argc, const char **argv,
                 * it would be extremely annoying.
                 */
                if (argc)
-                       verify_non_filename(opts->prefix, arg);
+                       verify_non_filename(the_repository, opts->prefix, arg);
        } else if (opts->accept_pathspec) {
                argcount++;
                argv++;
index b0e350cf8938fb1706046247a9282503db4508ff..4ec0c016b1f11cebed076b22f4b0fb599a07d08e 100644 (file)
@@ -1151,7 +1151,7 @@ int cmd_grep(int argc,
 
                object = parse_object_or_die(the_repository, &oid, arg);
                if (!seen_dashdash)
-                       verify_non_filename(prefix, arg);
+                       verify_non_filename(the_repository, prefix, arg);
                add_object_array_with_path(object, arg, &list, oc.mode, oc.path);
                object_context_release(&oc);
        }
index 1ac374d31b9a5ee1242a3cf47a87f5ae5008e768..11f57605b510aee87c30787ea3ee01f998b836f4 100644 (file)
@@ -281,7 +281,7 @@ static void parse_args(struct pathspec *pathspec,
                         * Ok, argv[0] looks like a commit/tree; it should not
                         * be a filename.
                         */
-                       verify_non_filename(prefix, argv[0]);
+                       verify_non_filename(the_repository, prefix, argv[0]);
                        rev = *argv++;
                } else {
                        /* Otherwise we treat this as a filename */
index 5d5324437969e929b72f382329eadf7fb1a4bf3b..b5fe3ef95d7e6be46af62ab5882c1130096ca231 100644 (file)
@@ -2072,7 +2072,7 @@ static int handle_dotdot_1(const char *a_name, const char *b_name,
                return -1;
 
        if (!cant_be_filename) {
-               verify_non_filename(revs->prefix, full_name);
+               verify_non_filename(the_repository, revs->prefix, full_name);
        }
 
        a_obj = parse_object(revs->repo, &a_oid);
@@ -2225,7 +2225,7 @@ static int handle_revision_arg_1(const char *arg_, struct rev_info *revs, int fl
                goto out;
        }
        if (!cant_be_filename)
-               verify_non_filename(revs->prefix, arg);
+               verify_non_filename(the_repository, revs->prefix, arg);
        object = get_reference(revs, arg, &oid, flags ^ local_flags);
        if (!object) {
                ret = (revs->ignore_missing || revs->do_not_die_on_missing_objects) ? 0 : -1;
diff --git a/setup.c b/setup.c
index e673663cabb582d0f8633ad9c7b09a74fd46b7da..759aba4e2c9fe55ec2e3a7625dc73c181bf10b34 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -297,9 +297,9 @@ void verify_filename(struct repository *repo,
  * and we parsed the arg as a refname.  It should not be interpretable
  * as a filename.
  */
-void verify_non_filename(const char *prefix, const char *arg)
+void verify_non_filename(struct repository *repo, const char *prefix, const char *arg)
 {
-       if (!is_inside_work_tree(the_repository) || is_inside_git_dir(the_repository))
+       if (!is_inside_work_tree(repo) || is_inside_git_dir(repo))
                return;
        if (*arg == '-')
                return; /* flag */
diff --git a/setup.h b/setup.h
index 24a6f666294b714c5da78eb9813914f925d07e6f..364c2c728a69d6bc2955f538c6bdddd2ff0961fc 100644 (file)
--- a/setup.h
+++ b/setup.h
@@ -146,7 +146,7 @@ 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);
+void verify_non_filename(struct repository *repo, const char *prefix, const char *name);
 int path_inside_repo(struct repository *repo, const char *prefix, const char *path);
 
 void sanitize_stdfds(void);