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

[PATCH 02/12] rerere: convert flags into an enum

From
Patrick Steinhardt <ps@pks.im>
Date
Oct 27, 2026, 10:46 UTC
Message-ID
<20261027-pks-rerere-subcommands-v1-2-d836c36ce0c5@pks.im>
In-Reply-To
<20261027-pks-rerere-subcommands-v1-0-d836c36ce0c5@pks.im>

Our modern coding guidelines say that flags should typically be passed around as enums so that it becomes trivial to see what kind of flags are expected. Adapt the rerere flags accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 rerere.c |  7 ++++---
 rerere.h | 21 ++++++++++++---------
 2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/rerere.c b/rerere.c
index fd1c1ed6015..1ae7983445a 100644
--- a/rerere.c
+++ b/rerere.c
@@ -908,7 +908,7 @@ static int is_rerere_enabled(struct repository *r)
 int rerere_cache_setup(struct rerere_cache *cache,
 		       struct repository *r,
 		       struct string_list *merge_rr,
-		       int flags)
+		       enum rerere_flags flags)
 {
 	int lock_timeout_ms = 1000;
 	int fd;
@@ -956,7 +956,7 @@ int rerere_cache_setup(struct rerere_cache *cache,
  * perform mergy operations, possibly leaving conflicted index entries
  * and working tree files.
  */
-int rerere_record(struct repository *r, int flags)
+int rerere_record(struct repository *r, enum rerere_flags flags)
 {
 	struct string_list merge_rr = STRING_LIST_INIT_DUP;
 	struct rerere_cache cache;
@@ -1341,7 +1341,8 @@ bool rerere_gc_needed(struct repository *r, size_t limit)
 	return needed;
 }
 
-void rerere_gc(struct repository *r, struct string_list *rr, int flags)
+void rerere_gc(struct repository *r, struct string_list *rr,
+	       enum rerere_flags flags)
 {
 	struct rerere_cache cache;
 	struct string_list to_remove = STRING_LIST_INIT_DUP;
diff --git a/rerere.h b/rerere.h
index a19d2407b59..362b348af25 100644
--- a/rerere.h
+++ b/rerere.h
@@ -9,12 +9,6 @@
 struct pathspec;
 struct repository;
 
-#define RERERE_AUTOUPDATE   01
-#define RERERE_NOAUTOUPDATE 02
-#define RERERE_READONLY     04
-/* If MERGE_RR.lock is taken, return -1 as if rerere were disabled */
-#define RERERE_NOWAIT       010
-
 /*
  * Marks paths that have been hand-resolved and added to the
  * index. Set in the util field of such paths after calling
@@ -39,13 +33,21 @@ struct rerere_id {
 	int variant;
 };
 
+enum rerere_flags {
+	RERERE_AUTOUPDATE = (1 << 0),
+	RERERE_NOAUTOUPDATE = (1 << 1),
+	RERERE_READONLY = (1 << 2),
+	/* If MERGE_RR.lock is taken, return -1 as if rerere were disabled */
+	RERERE_NOWAIT = (1 << 3),
+};
+
 int rerere_cache_setup(struct rerere_cache *cache,
 		       struct repository *r,
 		       struct string_list *merge_rr,
-		       int flags);
+		       enum rerere_flags flags);
 void rerere_cache_release(struct rerere_cache *cache);
 
-int rerere_record(struct repository *, int);
+int rerere_record(struct repository *r, enum rerere_flags flags);
 /*
  * Given the conflict ID and the name of a "file" used for replaying
  * the recorded resolution (e.g. "preimage", "postimage"), return the
@@ -58,7 +60,8 @@ const char *rerere_path(struct repository *,
 int rerere_forget(struct repository *, struct pathspec *);
 int rerere_remaining(struct repository *, struct string_list *);
 void rerere_clear(struct repository *, struct string_list *);
-void rerere_gc(struct repository *, struct string_list *, int);
+void rerere_gc(struct repository *, struct string_list *,
+	       enum rerere_flags flags);
 
 /*
  * Check whether garbage collection for rerere entries is needed, which is
-- 
2.56.0.341.g393f52fd96.dirty
Previous: Junio C HamanoNext: Mark C. Chu-Carroll
Message 6 of 108 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
  94. 00/13 builtin/rerere: convert to use subcommandsPatrick Steinhardt, Nov 19, 2026
  95. 01/13 rerere: rename `repo_rerere()`Patrick Steinhardt, Nov 19, 2026
  96. 02/13 rerere: convert flags into an enumPatrick Steinhardt, Nov 19, 2026
  97. 03/13 builtin/rerere: drop `the_repository`Patrick Steinhardt, Nov 19, 2026
  98. 04/13 builtin/rerere: stop passing flags to subcommands that ignore themPatrick Steinhardt, Nov 19, 2026
  99. 05/13 builtin/rerere: turn "forget" into a proper subcommandPatrick Steinhardt, Nov 19, 2026
  100. 06/13 builtin/rerere: turn "clear" into a proper subcommandPatrick Steinhardt, Nov 19, 2026
  101. 07/13 builtin/rerere: turn "status" into a proper subcommandPatrick Steinhardt, Nov 19, 2026
  102. 08/13 builtin/rerere: turn "remaining" into a proper subcommandPatrick Steinhardt, Nov 19, 2026
  103. 09/13 builtin/rerere: turn "diff" into a proper subcommandPatrick Steinhardt, Nov 19, 2026
  104. 10/13 builtin/rerere: turn "gc" into a proper subcommandPatrick Steinhardt, Nov 19, 2026
  105. 11/13 builtin/rerere: use `OPT_SUBCOMMAND()`Patrick Steinhardt, Nov 19, 2026
  106. Junio C HamanoNov 19, 2026
  107. 12/13 builtin/rerere: introduce proper usage strings for subcommandsPatrick Steinhardt, Nov 19, 2026
  108. 13/13 Documentation/git-rerere: drop claim that we pass args to diff(1)Patrick Steinhardt, Nov 19, 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.