From: Patrick Steinhardt Date: Tue, 19 May 2026 09:52:11 +0000 (+0200) Subject: setup: stop using `the_repository` in `verify_non_filename()` X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=920dba458188c41b4c2d354101c662bfedf6fe02;p=thirdparty%2Fgit.git setup: stop using `the_repository` in `verify_non_filename()` 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 Signed-off-by: Junio C Hamano --- diff --git a/builtin/checkout.c b/builtin/checkout.c index 1345e8574a..f82adcb740 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -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++; diff --git a/builtin/grep.c b/builtin/grep.c index b0e350cf89..4ec0c016b1 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -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); } diff --git a/builtin/reset.c b/builtin/reset.c index 1ac374d31b..11f57605b5 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -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 */ diff --git a/revision.c b/revision.c index 5d53244379..b5fe3ef95d 100644 --- a/revision.c +++ b/revision.c @@ -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 e673663cab..759aba4e2c 100644 --- 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 24a6f66629..364c2c728a 100644 --- 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);