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>

Patrick Steinhardt committed May 19, 2026 at 11:52 UTC 6e7e50cc7b9beab495c579249ba411a348bbdca4
6 files changed +10 -8
builtin/grep.c
+1 -1
@@ -1163,7 +1163,7 @@ int cmd_grep(int argc,
1163 if (!seen_dashdash) {
1164 int j;
1165 for (j = i; j < argc; j++)
1166 - verify_filename(prefix, argv[j], j == i && allow_revs);
1166 + verify_filename(the_repository, prefix, argv[j], j == i && allow_revs);
1167 }
1168
1169 parse_pathspec(&pathspec, 0,
builtin/reset.c
+1 -1
@@ -285,7 +285,7 @@ static void parse_args(struct pathspec *pathspec,
285 rev = *argv++;
286 } else {
287 /* Otherwise we treat this as a filename */
288 - verify_filename(prefix, argv[0], 1);
288 + verify_filename(the_repository, prefix, argv[0], 1);
289 }
290 }
291
builtin/rev-parse.c
+2 -2
@@ -749,7 +749,7 @@ int cmd_rev_parse(int argc,
749
750 if (as_is) {
751 if (show_file(arg, output_prefix) && as_is < 2)
752 - verify_filename(prefix, arg, 0);
752 + verify_filename(the_repository, prefix, arg, 0);
753 continue;
754 }
755
@@ -1173,7 +1173,7 @@ int cmd_rev_parse(int argc,
1173 as_is = 1;
1174 if (!show_file(arg, output_prefix))
1175 continue;
1176 - verify_filename(prefix, arg, 1);
1176 + verify_filename(the_repository, prefix, arg, 1);
1177 }
1178 strbuf_release(&buf);
1179 if (verify) {
revision.c
+1 -1
@@ -3067,7 +3067,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
3067 * but the latter we have checked in the main loop.
3068 */
3069 for (j = i; j < argc; j++)
3070 - verify_filename(revs->prefix, argv[j], j == i);
3070 + verify_filename(the_repository, revs->prefix, argv[j], j == i);
3071
3072 strvec_pushv(&prune_data, argv + i);
3073 break;
setup.c
+3 -2
@@ -280,7 +280,8 @@ static int looks_like_pathspec(const char *arg)
280 * diagnose_misspelt_rev == 0 for the next ones (because we already
281 * saw a filename, there's not ambiguity anymore).
282 */
283 -void verify_filename(const char *prefix,
283 +void verify_filename(struct repository *repo,
284 + const char *prefix,
285 const char *arg,
286 int diagnose_misspelt_rev)
287 {
@@ -288,7 +289,7 @@ void verify_filename(const char *prefix,
289 die(_("option '%s' must come before non-option arguments"), arg);
290 if (looks_like_pathspec(arg) || check_filename(prefix, arg))
291 return;
291 - die_verify_filename(the_repository, prefix, arg, diagnose_misspelt_rev);
292 + die_verify_filename(repo, prefix, arg, diagnose_misspelt_rev);
293 }
294
295 /*
setup.h
+2 -1
@@ -142,7 +142,8 @@ char *prefix_path(struct repository *repo, const char *prefix, int len, const ch
142 char *prefix_path_gently(struct repository *repo, const char *prefix, int len, int *remaining, const char *path);
143
144 int check_filename(const char *prefix, const char *name);
145 -void verify_filename(const char *prefix,
145 +void verify_filename(struct repository *repo,
146 + const char *prefix,
147 const char *name,
148 int diagnose_misspelt_rev);
149 void verify_non_filename(const char *prefix, const char *name);