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

[PATCH v2 03/12] builtin/rerere: drop `the_repository`

From
Patrick Steinhardt <ps@pks.im>
Date
Oct 29, 2026, 09:57 UTC
Message-ID
<20261029-pks-rerere-subcommands-v2-3-07d5ba18e882@pks.im>
In-Reply-To
<20261029-pks-rerere-subcommands-v2-0-07d5ba18e882@pks.im>

There are a couple of references to `the_repository` in git-rerere(1). As that command cannot run outside of a repository these references can be trivially replaced by the repository that's passed in as parameter to `cmd_rerere()`. We don't have to worry about the repository being `NULL` when called with "-h", either, as there are no references to the repo before we call `parse_options()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 builtin/rerere.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/builtin/rerere.c b/builtin/rerere.c
index a499e7b9151..83fb3783c61 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -1,5 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
-
 #include "builtin.h"
 #include "config.h"
 #include "gettext.h"
@@ -57,7 +55,7 @@ static int diff_two(const char *file1, const char *label1,
 int cmd_rerere(int argc,
 	       const char **argv,
 	       const char *prefix,
-	       struct repository *repo UNUSED)
+	       struct repository *repo)
 {
 	struct string_list merge_rr = STRING_LIST_INIT_DUP;
 	int autoupdate = -1, skip_locked = 0, flags = 0;
@@ -75,7 +73,7 @@ int cmd_rerere(int argc,
 	if (skip_locked && (argc < 1 || strcmp(argv[0], "gc")))
 		die(_("the option '%s' requires '%s'"), "--skip-locked", "gc");
 
-	repo_config(the_repository, git_xmerge_config, NULL);
+	repo_config(repo, git_xmerge_config, NULL);
 
 	if (autoupdate == 1)
 		flags = RERERE_AUTOUPDATE;
@@ -83,7 +81,7 @@ int cmd_rerere(int argc,
 		flags = RERERE_NOAUTOUPDATE;
 
 	if (argc < 1)
-		return rerere(the_repository, flags);
+		return rerere(repo, flags);
 
 	if (!strcmp(argv[0], "forget")) {
 		struct pathspec pathspec;
@@ -94,21 +92,21 @@ int cmd_rerere(int argc,
 		parse_pathspec(&pathspec, 0, PATHSPEC_PREFER_CWD,
 			       prefix, argv + 1);
 
-		ret = rerere_forget(the_repository, &pathspec);
+		ret = rerere_forget(repo, &pathspec);
 
 		clear_pathspec(&pathspec);
 		return ret;
 	}
 
 	if (!strcmp(argv[0], "clear")) {
-		rerere_clear(the_repository, &merge_rr);
+		rerere_clear(repo, &merge_rr);
 	} else if (!strcmp(argv[0], "gc"))
-		rerere_gc(the_repository, &merge_rr,
+		rerere_gc(repo, &merge_rr,
 			  skip_locked ? RERERE_NOWAIT : 0);
 	else if (!strcmp(argv[0], "status")) {
 		struct rerere_cache cache;
 
-		if (rerere_cache_setup(&cache, the_repository, &merge_rr,
+		if (rerere_cache_setup(&cache, repo, &merge_rr,
 				       flags | RERERE_READONLY) < 0)
 			return 0;
 		for (size_t i = 0; i < merge_rr.nr; i++)
@@ -116,7 +114,7 @@ int cmd_rerere(int argc,
 
 		rerere_cache_release(&cache);
 	} else if (!strcmp(argv[0], "remaining")) {
-		rerere_remaining(the_repository, &merge_rr);
+		rerere_remaining(repo, &merge_rr);
 		for (size_t i = 0; i < merge_rr.nr; i++) {
 			if (merge_rr.items[i].util != RERERE_RESOLVED)
 				printf("%s\n", merge_rr.items[i].string);
@@ -129,16 +127,16 @@ int cmd_rerere(int argc,
 		struct strbuf buf = STRBUF_INIT;
 		struct rerere_cache cache;
 
-		if (rerere_cache_setup(&cache, the_repository, &merge_rr,
+		if (rerere_cache_setup(&cache, repo, &merge_rr,
 				      flags | RERERE_READONLY) < 0)
 			return 0;
 		for (size_t i = 0; i < merge_rr.nr; i++) {
 			const char *path = merge_rr.items[i].string;
 			const struct rerere_id *id = merge_rr.items[i].util;
-			if (diff_two(rerere_path(the_repository, &buf, id, "preimage"),
+			if (diff_two(rerere_path(repo, &buf, id, "preimage"),
 				     path, path, path))
 				die(_("unable to generate diff for '%s'"),
-				    rerere_path(the_repository, &buf, id, NULL));
+				    rerere_path(repo, &buf, id, NULL));
 		}
 
 		rerere_cache_release(&cache);
-- 
2.56.0.341.g393f52fd96.dirty
Previous: Karthik NayakNext: Patrick Steinhardt
Message 29 of 93 in “builtin/rerere: convert to use subcommands”
  1. 00/12 builtin/rerere: convert to use subcommandsPatrick Steinhardt, Oct 27, 2026
  2. 01/12 rerere: rename `repo_rerere()`Patrick Steinhardt, Oct 27, 2026
  3. Junio C HamanoOct 27, 2026
  4. Patrick SteinhardtOct 28, 2026
  5. Junio C HamanoOct 28, 2026
  6. 02/12 rerere: convert flags into an enumPatrick Steinhardt, Oct 27, 2026
  7. Mark C. Chu-CarrollOct 27, 2026
  8. Junio C HamanoOct 27, 2026
  9. Patrick SteinhardtOct 28, 2026
  10. Mark C. Chu-CarrollOct 28, 2026
  11. Junio C HamanoOct 28, 2026
  12. 03/12 builtin/rerere: drop `the_repository`Patrick Steinhardt, Oct 27, 2026
  13. 04/12 builtin/rerere: stop passing flags to subcommands that ignore themPatrick Steinhardt, Oct 27, 2026
  14. 05/12 builtin/rerere: turn "forget" into a proper subcommandPatrick Steinhardt, Oct 27, 2026
  15. 06/12 builtin/rerere: turn "clear" into a proper subcommandPatrick Steinhardt, Oct 27, 2026
  16. 07/12 builtin/rerere: turn "status" into a proper subcommandPatrick Steinhardt, Oct 27, 2026
  17. 08/12 builtin/rerere: turn "remaining" into a proper subcommandPatrick Steinhardt, Oct 27, 2026
  18. 09/12 builtin/rerere: turn "diff" into a proper subcommandPatrick Steinhardt, Oct 27, 2026
  19. 10/12 builtin/rerere: turn "gc" into a proper subcommandPatrick Steinhardt, Oct 27, 2026
  20. 11/12 builtin/rerere: use `OPT_SUBCOMMAND()`Patrick Steinhardt, Oct 27, 2026
  21. 12/12 builtin/rerere: introduce proper usage strings for subcommandsPatrick Steinhardt, Oct 27, 2026
  22. Junio C HamanoOct 27, 2026
  23. 00/12 builtin/rerere: convert to use subcommandsPatrick Steinhardt, Oct 29, 2026
  24. 01/12 rerere: rename `repo_rerere()`Patrick Steinhardt, Oct 29, 2026
  25. 02/12 rerere: convert flags into an enumPatrick Steinhardt, Oct 29, 2026
  26. Karthik NayakNov 6, 2026
  27. Patrick SteinhardtNov 6, 2026
  28. Karthik NayakNov 6, 2026
  29. 03/12 builtin/rerere: drop `the_repository`Patrick Steinhardt, Oct 29, 2026
  30. 04/12 builtin/rerere: stop passing flags to subcommands that ignore themPatrick Steinhardt, Oct 29, 2026
  31. 05/12 builtin/rerere: turn "forget" into a proper subcommandPatrick Steinhardt, Oct 29, 2026
  32. 06/12 builtin/rerere: turn "clear" into a proper subcommandPatrick Steinhardt, Oct 29, 2026
  33. 07/12 builtin/rerere: turn "status" into a proper subcommandPatrick Steinhardt, Oct 29, 2026
  34. 08/12 builtin/rerere: turn "remaining" into a proper subcommandPatrick Steinhardt, Oct 29, 2026
  35. 09/12 builtin/rerere: turn "diff" into a proper subcommandPatrick Steinhardt, Oct 29, 2026
  36. 10/12 builtin/rerere: turn "gc" into a proper subcommandPatrick Steinhardt, Oct 29, 2026
  37. Karthik NayakNov 6, 2026
  38. 11/12 builtin/rerere: use `OPT_SUBCOMMAND()`Patrick Steinhardt, Oct 29, 2026
  39. Karthik NayakNov 6, 2026
  40. Patrick SteinhardtNov 6, 2026
  41. 12/12 builtin/rerere: introduce proper usage strings for subcommandsPatrick Steinhardt, Oct 29, 2026
  42. Karthik NayakNov 6, 2026
  43. 00/12 builtin/rerere: convert to use subcommandsPatrick Steinhardt, Nov 6, 2026
  44. 01/12 rerere: rename `repo_rerere()`Patrick Steinhardt, Nov 6, 2026
  45. 02/12 rerere: convert flags into an enumPatrick Steinhardt, Nov 6, 2026
  46. Junio C HamanoNov 6, 2026
  47. Patrick SteinhardtNov 9, 2026
  48. Junio C HamanoNov 9, 2026
  49. Junio C HamanoNov 9, 2026
  50. Patrick SteinhardtNov 11, 2026
  51. 03/12 builtin/rerere: drop `the_repository`Patrick Steinhardt, Nov 6, 2026
  52. 04/12 builtin/rerere: stop passing flags to subcommands that ignore themPatrick Steinhardt, Nov 6, 2026
  53. 05/12 builtin/rerere: turn "forget" into a proper subcommandPatrick Steinhardt, Nov 6, 2026
  54. 06/12 builtin/rerere: turn "clear" into a proper subcommandPatrick Steinhardt, Nov 6, 2026
  55. 07/12 builtin/rerere: turn "status" into a proper subcommandPatrick Steinhardt, Nov 6, 2026
  56. 08/12 builtin/rerere: turn "remaining" into a proper subcommandPatrick Steinhardt, Nov 6, 2026
  57. 09/12 builtin/rerere: turn "diff" into a proper subcommandPatrick Steinhardt, Nov 6, 2026
  58. 10/12 builtin/rerere: turn "gc" into a proper subcommandPatrick Steinhardt, Nov 6, 2026
  59. 11/12 builtin/rerere: use `OPT_SUBCOMMAND()`Patrick Steinhardt, Nov 6, 2026
  60. 12/12 builtin/rerere: introduce proper usage strings for subcommandsPatrick Steinhardt, Nov 6, 2026
  61. 00/12 builtin/rerere: convert to use subcommandsPatrick Steinhardt, Nov 11, 2026
  62. 01/12 rerere: rename `repo_rerere()`Patrick Steinhardt, Nov 11, 2026
  63. 02/12 rerere: convert flags into an enumPatrick Steinhardt, Nov 11, 2026
  64. 03/12 builtin/rerere: drop `the_repository`Patrick Steinhardt, Nov 11, 2026
  65. 04/12 builtin/rerere: stop passing flags to subcommands that ignore themPatrick Steinhardt, Nov 11, 2026
  66. 05/12 builtin/rerere: turn "forget" into a proper subcommandPatrick Steinhardt, Nov 11, 2026
  67. 06/12 builtin/rerere: turn "clear" into a proper subcommandPatrick Steinhardt, Nov 11, 2026
  68. 07/12 builtin/rerere: turn "status" into a proper subcommandPatrick Steinhardt, Nov 11, 2026
  69. 08/12 builtin/rerere: turn "remaining" into a proper subcommandPatrick Steinhardt, Nov 11, 2026
  70. 09/12 builtin/rerere: turn "diff" into a proper subcommandPatrick Steinhardt, Nov 11, 2026
  71. Junio C HamanoNov 17, 2026
  72. 10/12 builtin/rerere: turn "gc" into a proper subcommandPatrick Steinhardt, Nov 11, 2026
  73. Junio C HamanoNov 17, 2026
  74. 11/12 builtin/rerere: use `OPT_SUBCOMMAND()`Patrick Steinhardt, Nov 11, 2026
  75. Junio C HamanoNov 17, 2026
  76. Patrick SteinhardtNov 18, 2026
  77. Junio C HamanoNov 18, 2026
  78. 12/12 builtin/rerere: introduce proper usage strings for subcommandsPatrick Steinhardt, Nov 11, 2026
  79. Junio C HamanoNov 17, 2026
  80. Patrick SteinhardtNov 18, 2026
  81. Karthik NayakNov 12, 2026
  82. Patrick SteinhardtNov 13, 2026
  83. Junio C HamanoNov 13, 2026
  84. Tuomas AholaNov 13, 2026
  85. Phillip WoodNov 13, 2026
  86. Junio C HamanoNov 13, 2026
  87. Tuomas AholaNov 14, 2026
  88. Patrick SteinhardtNov 16, 2026
  89. Junio C HamanoNov 14, 2026
  90. Patrick SteinhardtNov 16, 2026
  91. Junio C HamanoNov 16, 2026
  92. Junio C HamanoNov 17, 2026
  93. Patrick SteinhardtNov 18, 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.