From a5f0aeb6c10cf6e89e2b67d3d3e150cf45f5e862 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 30 Mar 2026 15:17:29 +0200 Subject: [PATCH] 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 --- builtin/checkout.c | 2 +- builtin/grep.c | 2 +- builtin/reset.c | 2 +- revision.c | 4 ++-- setup.c | 4 ++-- setup.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index e031e61886..d7069765e7 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -1485,7 +1485,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 57cf00ae6b..9071a38b85 100644 --- a/revision.c +++ b/revision.c @@ -2082,7 +2082,7 @@ static int handle_dotdot_1(const char *arg, char *dotdot, if (!cant_be_filename) { *dotdot = '.'; - verify_non_filename(revs->prefix, arg); + verify_non_filename(the_repository, revs->prefix, arg); *dotdot = '\0'; } @@ -2227,7 +2227,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 736f950bd0..c6b5b85f3a 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);