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

[PATCH v4 00/12] builtin/rerere: convert to use subcommands

From
Patrick Steinhardt <ps@pks.im>
Date
Nov 11, 2026, 12:18 UTC
Message-ID
<20261111-pks-rerere-subcommands-v4-0-df0c8bf79e16@pks.im>
In-Reply-To
<20261027-pks-rerere-subcommands-v1-0-d836c36ce0c5@pks.im>
Hi,

while reviewing some patch series around git-rerere(1) recently I was a bit appalled by our custom subcommand parsing that we do here. This patch series here thus cleans up and modernizes that part a bit so that git-rerere(1) behaves like every other Git command that happens to have subcommands.

This series is based on 37b3475fb53 (The 9th batch, 2026-10-25) with ps/rerere-remove-global-state at b948c10c8b3 (rerere: get rid of global rerere cache state, 2026-10-23) merged into it.

Changes in v4:
  - Some more polishing for `RERERE_{NO,}AUTOUPDATE` documentation.
  - Die in case both of these flags are passed.
  - Link to v3: https://patch.msgid.link/20261106-pks-rerere-subcommands-v3-0-4ff164d8fb81@pks.im
Changes in v3:
  - Clarify what `RERERE_NOAUTOUPDATE` does.
  - Link to v2: https://patch.msgid.link/20261029-pks-rerere-subcommands-v2-0-07d5ba18e882@pks.im
Changes in v2:
  - Document rerere flags.
  - Rename `rerere_record()` to just `rerere()`.
  - Link to v1: https://patch.msgid.link/20261027-pks-rerere-subcommands-v1-0-d836c36ce0c5@pks.im
Thanks!
Patrick
---
Patrick Steinhardt (12):
      rerere: rename `repo_rerere()`
      rerere: convert flags into an enum
      builtin/rerere: drop `the_repository`
      builtin/rerere: stop passing flags to subcommands that ignore them
      builtin/rerere: turn "forget" into a proper subcommand
      builtin/rerere: turn "clear" into a proper subcommand
      builtin/rerere: turn "status" into a proper subcommand
      builtin/rerere: turn "remaining" into a proper subcommand
      builtin/rerere: turn "diff" into a proper subcommand
      builtin/rerere: turn "gc" into a proper subcommand
      builtin/rerere: use `OPT_SUBCOMMAND()`
      builtin/rerere: introduce proper usage strings for subcommands
 Documentation/git-rerere.adoc |   8 +-
 apply.c                       |   2 +-
 builtin/am.c                  |   4 +-
 builtin/commit.c              |   2 +-
 builtin/merge.c               |   2 +-
 builtin/rerere.c              | 319 ++++++++++++++++++++++++++++++++----------
 builtin/stash.c               |   2 +-
 rerere.c                      |  14 +-
 rerere.h                      |  43 ++++--
 sequencer.c                   |   4 +-
 t/t4200-rerere.sh             |   5 -
 11 files changed, 299 insertions(+), 106 deletions(-)
Range-diff versus v3:
 1:  e9237465706 =  1:  f669dc6eddf rerere: rename `repo_rerere()`
 2:  94d91a0620d !  2:  4fd3f6aa650 rerere: convert flags into an enum
    @@ Commit message
         around as enums so that it becomes trivial to see what kind of flags are
         expected. Adapt the rerere flags accordingly and document them.
     
    +    While at it, detect the case where both `RERERE_AUTOUPDATE` and
    +    `RERERE_NOAUTOUPDATE` are passed. This combination does not make a lot
    +    of sense, and it's not obvious which of those flags takes precedence
    +    (it's `RERERE_AUTOUPDATE`). All current callers know to only pass one of
    +    those flags, but let's be safe rather than sorry and `BUG()` in case
    +    both are passed.
    +
         Signed-off-by: Patrick Steinhardt <ps@pks.im>
     
      ## rerere.c ##
    @@ rerere.c: static int is_rerere_enabled(struct repository *r)
      {
      	int lock_timeout_ms = 1000;
      	int fd;
    +@@ rerere.c: int rerere_cache_setup(struct rerere_cache *cache,
    + 	repo_config_get_bool(r, "rerere.autoupdate", &cache->autoupdate);
    + 	repo_config_get_int(r, "rerere.locktimeout", &lock_timeout_ms);
    + 
    ++	if ((flags & RERERE_AUTOUPDATE) && (flags & RERERE_NOAUTOUPDATE))
    ++		BUG("RERERE_AUTOUPDATE cannot be used with RERERE_NOAUTOUPDATE");
    + 	if (flags & (RERERE_AUTOUPDATE|RERERE_NOAUTOUPDATE))
    + 		cache->autoupdate = !!(flags & RERERE_AUTOUPDATE);
    + 	if ((flags & RERERE_READONLY) && (flags & RERERE_NOWAIT))
     @@ rerere.c: int rerere_cache_setup(struct rerere_cache *cache,
      	return fd;
      }
    @@ rerere.h: struct rerere_id {
     +	RERERE_AUTOUPDATE = (1 << 0),
     +
     +	/*
    -+	 * Reverse of RERERE_AUTOUPDATE. That is, update the file in the
    -+	 * working tree but don't touch the index.
    ++	 * update the file in the working tree but don't touch the index. This
    ++	 * can be used to explicitly override "rerere.autoUpdate".
    ++	 *
    ++	 * This flag is essentially the reverse of `RERERE_AUTOUPDATE`. It is
    ++	 * invalid to pass both flags at the same time.
     +	 */
     +	RERERE_NOAUTOUPDATE = (1 << 1),
     +
 3:  99faad47068 =  3:  48692c2c88d builtin/rerere: drop `the_repository`
 4:  f164c482227 =  4:  e76991dd39d builtin/rerere: stop passing flags to subcommands that ignore them
 5:  0573d2323e8 =  5:  2474dca4713 builtin/rerere: turn "forget" into a proper subcommand
 6:  2098dedf4fd =  6:  cecdbb1c63b builtin/rerere: turn "clear" into a proper subcommand
 7:  e8eaa2b4092 =  7:  54fc766f9d2 builtin/rerere: turn "status" into a proper subcommand
 8:  a5781284b8b =  8:  fa2c839b2cb builtin/rerere: turn "remaining" into a proper subcommand
 9:  9a4278df0ea =  9:  416b8311ca9 builtin/rerere: turn "diff" into a proper subcommand
10:  e63b9be0d74 = 10:  adb2b68f833 builtin/rerere: turn "gc" into a proper subcommand
11:  47889896ecb = 11:  a12e19cb2e8 builtin/rerere: use `OPT_SUBCOMMAND()`
12:  5e16a247b49 = 12:  4b1b6170ba3 builtin/rerere: introduce proper usage strings for subcommands

--- base-commit: 710910c03a22ac663885049213b9fef5853ea8e0 change-id: 20261027-pks-rerere-subcommands-318d41553438

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 61 of 89 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. 12/12 builtin/rerere: introduce proper usage strings for subcommandsPatrick Steinhardt, Nov 11, 2026
  77. Junio C HamanoNov 17, 2026
  78. Karthik NayakNov 12, 2026
  79. Patrick SteinhardtNov 13, 2026
  80. Junio C HamanoNov 13, 2026
  81. Tuomas AholaNov 13, 2026
  82. Phillip WoodNov 13, 2026
  83. Junio C HamanoNov 13, 2026
  84. Tuomas AholaNov 14, 2026
  85. Patrick SteinhardtNov 16, 2026
  86. Junio C HamanoNov 14, 2026
  87. Patrick SteinhardtNov 16, 2026
  88. Junio C HamanoNov 16, 2026
  89. Junio C HamanoNov 17, 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.