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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2026-03-30 15:17:29 +02:00
committed by Junio C Hamano
parent 3706c713f2
commit a5f0aeb6c1
6 changed files with 8 additions and 8 deletions

View File

@@ -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++;

View 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);
}

View 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 */

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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);