git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 07/18] setup: stop using `the_repository` in `verify_non_filename()`

From
Patrick Steinhardt <ps@pks.im>
Date
May 18, 2026, 09:30 UTC
Message-ID
<20260518-pks-setup-wo-the-repository-v2-7-6933c0f1d568@pks.im>
In-Reply-To
<20260518-pks-setup-wo-the-repository-v2-0-6933c0f1d568@pks.im>

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>
---
 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 ac0186a33e..14cefa0199 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1492,7 +1492,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);
-- 
2.54.0.771.g3ed373ac14.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 40 of 73 in “setup: drop uses of `the_repository`”
  1. 00/18 setup: drop uses of `the_repository`Patrick Steinhardt, Apr 20, 2026
  2. 01/18 setup: replace use of `the_repository` in static functionsPatrick Steinhardt, Apr 20, 2026
  3. 02/18 setup: stop using `the_repository` in `is_inside_worktree()`Patrick Steinhardt, Apr 20, 2026
  4. Tian YuchenMay 17, 2026
  5. Junio C HamanoMay 17, 2026
  6. Patrick SteinhardtMay 18, 2026
  7. Junio C HamanoMay 19, 2026
  8. Patrick SteinhardtMay 19, 2026
  9. 03/18 setup: stop using `the_repository` in `is_inside_git_dir()`Patrick Steinhardt, Apr 20, 2026
  10. 04/18 setup: stop using `the_repository` in `prefix_path()`Patrick Steinhardt, Apr 20, 2026
  11. 05/18 setup: stop using `the_repository` in `path_inside_repo()`Patrick Steinhardt, Apr 20, 2026
  12. 06/18 setup: stop using `the_repository` in `verify_filename()`Patrick Steinhardt, Apr 20, 2026
  13. 07/18 setup: stop using `the_repository` in `verify_non_filename()`Patrick Steinhardt, Apr 20, 2026
  14. 08/18 setup: stop using `the_repository` in `enter_repo()`Patrick Steinhardt, Apr 20, 2026
  15. 09/18 setup: stop using `the_repository` in `setup_work_tree()`Patrick Steinhardt, Apr 20, 2026
  16. 10/18 setup: stop using `the_repository` in `set_git_work_tree()`Patrick Steinhardt, Apr 20, 2026
  17. 11/18 setup: stop using `the_repository` in `setup_git_env()`Patrick Steinhardt, Apr 20, 2026
  18. 12/18 setup: stop using `the_repository` in `setup_git_directory_gently()`Patrick Steinhardt, Apr 20, 2026
  19. 13/18 setup: stop using `the_repository` in `setup_git_directory()`Patrick Steinhardt, Apr 20, 2026
  20. 14/18 setup: stop using `the_repository` in `upgrade_repository_format()`Patrick Steinhardt, Apr 20, 2026
  21. 15/18 setup: stop using `the_repository` in `check_repository_format()`Patrick Steinhardt, Apr 20, 2026
  22. 16/18 setup: stop using `the_repository` in `initialize_repository_version()`Patrick Steinhardt, Apr 20, 2026
  23. 17/18 setup: stop using `the_repository` in `create_reference_database()`Patrick Steinhardt, Apr 20, 2026
  24. 18/18 setup: stop using `the_repository` in `init_db()`Patrick Steinhardt, Apr 20, 2026
  25. Elijah NewrenApr 20, 2026
  26. Patrick SteinhardtApr 21, 2026
  27. Junio C HamanoApr 20, 2026
  28. Patrick SteinhardtApr 21, 2026
  29. 00/18 setup: drop uses of `the_repository`Patrick Steinhardt, May 18, 2026
  30. 01/18 setup: replace use of `the_repository` in static functionsPatrick Steinhardt, May 18, 2026
  31. Karthik NayakMay 19, 2026
  32. 02/18 setup: stop using `the_repository` in `is_inside_worktree()`Patrick Steinhardt, May 18, 2026
  33. Karthik NayakMay 19, 2026
  34. Patrick SteinhardtMay 19, 2026
  35. 03/18 setup: stop using `the_repository` in `is_inside_git_dir()`Patrick Steinhardt, May 18, 2026
  36. Karthik NayakMay 19, 2026
  37. 04/18 setup: stop using `the_repository` in `prefix_path()`Patrick Steinhardt, May 18, 2026
  38. 05/18 setup: stop using `the_repository` in `path_inside_repo()`Patrick Steinhardt, May 18, 2026
  39. 06/18 setup: stop using `the_repository` in `verify_filename()`Patrick Steinhardt, May 18, 2026
  40. 07/18 setup: stop using `the_repository` in `verify_non_filename()`Patrick Steinhardt, May 18, 2026
  41. 08/18 setup: stop using `the_repository` in `enter_repo()`Patrick Steinhardt, May 18, 2026
  42. 09/18 setup: stop using `the_repository` in `setup_work_tree()`Patrick Steinhardt, May 18, 2026
  43. 10/18 setup: stop using `the_repository` in `set_git_work_tree()`Patrick Steinhardt, May 18, 2026
  44. 11/18 setup: stop using `the_repository` in `setup_git_env()`Patrick Steinhardt, May 18, 2026
  45. 12/18 setup: stop using `the_repository` in `setup_git_directory_gently()`Patrick Steinhardt, May 18, 2026
  46. 13/18 setup: stop using `the_repository` in `setup_git_directory()`Patrick Steinhardt, May 18, 2026
  47. 14/18 setup: stop using `the_repository` in `upgrade_repository_format()`Patrick Steinhardt, May 18, 2026
  48. 15/18 setup: stop using `the_repository` in `check_repository_format()`Patrick Steinhardt, May 18, 2026
  49. 16/18 setup: stop using `the_repository` in `initialize_repository_version()`Patrick Steinhardt, May 18, 2026
  50. 17/18 setup: stop using `the_repository` in `create_reference_database()`Patrick Steinhardt, May 18, 2026
  51. 18/18 setup: stop using `the_repository` in `init_db()`Patrick Steinhardt, May 18, 2026
  52. Karthik NayakMay 19, 2026
  53. Patrick SteinhardtMay 19, 2026
  54. 00/18 setup: drop uses of `the_repository`Patrick Steinhardt, May 19, 2026
  55. 01/18 setup: replace use of `the_repository` in static functionsPatrick Steinhardt, May 19, 2026
  56. 02/18 setup: stop using `the_repository` in `is_inside_git_dir()`Patrick Steinhardt, May 19, 2026
  57. 03/18 setup: stop using `the_repository` in `is_inside_work_tree()`Patrick Steinhardt, May 19, 2026
  58. 04/18 setup: stop using `the_repository` in `prefix_path()`Patrick Steinhardt, May 19, 2026
  59. 05/18 setup: stop using `the_repository` in `path_inside_repo()`Patrick Steinhardt, May 19, 2026
  60. 06/18 setup: stop using `the_repository` in `verify_filename()`Patrick Steinhardt, May 19, 2026
  61. 07/18 setup: stop using `the_repository` in `verify_non_filename()`Patrick Steinhardt, May 19, 2026
  62. 08/18 setup: stop using `the_repository` in `enter_repo()`Patrick Steinhardt, May 19, 2026
  63. 09/18 setup: stop using `the_repository` in `setup_work_tree()`Patrick Steinhardt, May 19, 2026
  64. 10/18 setup: stop using `the_repository` in `set_git_work_tree()`Patrick Steinhardt, May 19, 2026
  65. 11/18 setup: stop using `the_repository` in `setup_git_env()`Patrick Steinhardt, May 19, 2026
  66. 12/18 setup: stop using `the_repository` in `setup_git_directory_gently()`Patrick Steinhardt, May 19, 2026
  67. 14/18 setup: stop using `the_repository` in `upgrade_repository_format()`Patrick Steinhardt, May 19, 2026
  68. 13/18 setup: stop using `the_repository` in `setup_git_directory()`Patrick Steinhardt, May 19, 2026
  69. 15/18 setup: stop using `the_repository` in `check_repository_format()`Patrick Steinhardt, May 19, 2026
  70. 16/18 setup: stop using `the_repository` in `initialize_repository_version()`Patrick Steinhardt, May 19, 2026
  71. 17/18 setup: stop using `the_repository` in `create_reference_database()`Patrick Steinhardt, May 19, 2026
  72. 18/18 setup: stop using `the_repository` in `init_db()`Patrick Steinhardt, May 19, 2026
  73. Junio C HamanoMay 20, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.