# git rerere moves to standard subcommand parsing

_Patrick Steinhardt replaces rerere's hand-rolled subcommand handling with parse-options subcommands, at the cost of a small compatibility break._

Section: Patches. Edition of 2026-10-28. Written by an AI editor from the thread "[PATCH 00/12] builtin/rerere: convert to use subcommands" (110 messages): https://gitlist.dev/t/66677

Patrick Steinhardt says he was appalled by rerere's custom subcommand parsing while reviewing other rerere patches, and the series makes git-rerere(1) behave like other Git commands with subcommands. It is based on the 9th batch with ps/rerere-remove-global-state merged in. Preparatory patches rename `repo_rerere()`, turn flags into an enum, drop `the_repository` from builtin/rerere, and move the gc and diff subcommands onto parse-options. The final patches switch to `OPT_SUBCOMMAND()` and give each subcommand its own usage string.

The switch is backward-incompatible. The "--[no-]rerere-autoupdate" flag is no longer accepted for every subcommand. Steinhardt argues it was ignored by all but one, and that accepting it was misleading, so he calls the old behavior a bug.

Junio C Hamano, whom Steinhardt calls the inventor of the mechanism, took special interest and found the patches well done. He was surprised that so small a change removes USE_THE_REPOSITORY_VARIABLE from builtin/rerere.c, though he does not consider making cmd_foo() independent of the_repository high priority.

Hamano also supports dropping the "repo_" prefix eventually, but objects to the verb "record" in the function's new name. The function works out its situation itself: it resolves when a recorded resolution exists and records when it sees a conflict for the first time. He suggested something like "perform rerere".

Mark C. Chu-Carroll asked whether, with the flags now an enum, an explicit RERE_MERGE_LOCK_TOKEN value would be better than documenting that value only in a comment. Hamano replied that the comment explains the next line: callers who want immediate failure when locked should pass the _NOWAIT bit.
