setup: stop using `the_repository` in `verify_filename()`

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>
main
Patrick Steinhardt 2026-05-19 11:52:10 +02:00 committed by Junio C Hamano
parent e6a380201e
commit 6e7e50cc7b
6 changed files with 10 additions and 8 deletions

View 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,

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


View 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) {

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

View File

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

/*

View File

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