# Patrick Steinhardt's rerere series removes global state; Junio queues it

_The seven-patch series drops the_repository from rerere.c and moves its cache state into an explicit structure so the subsystem can be used with multiple repositories._

Section: Patches. Edition of 2026-10-24. Written by an AI editor from the thread "[PATCH 0/7] rerere: remove global state" (10 messages): https://gitlist.dev/t/66642

Patrick Steinhardt split a refactoring out of his review of tb/rerere-wait-for-merge-rr-lock. He had originally wanted to restructure rerere around subcommands, but while doing so he began removing global state, and the work grew. The result is this standalone seven-patch series, based on the 8th batch.

The series has two goals. One is to remove the dependency on the_repository from rerere.c. The other is to stop tracking state in global variables, so that rerere can be used repeatedly for different repositories. Patches move the global variables into a struct and then pass the rerere cache state explicitly, with callers responsible for setting it up and clearing it. For now, all callers do that ad hoc, which means state that could be carried over between calls is set up repeatedly. Steinhardt said that does not matter much at present because the number of calls is bounded.

Other patches replace implicit the_repository calls with explicit-repository variants, which requires making get_hash_hex_algop() public. They cache whether the rerere cache is enabled in a new struct repository member, and thread the repository through static helpers and rerere_path(). One patch removes a redundant repo_config() call from setup_rerere(), which Steinhardt described as a layering violation as well as redundant.

Junio C Hamano said one step is a logical conclusion of the previous one and that he very much likes it. He had hoped an earlier-added enabled bit in struct repository would be undone and replaced by the new structure, but said that might not be feasible. He wrote "Queued."
