]> git.ipfire.org Git - thirdparty/git.git/commit
sequencer: extract revert message formatting into shared function
authorSiddharth Asthana <siddharthasthana31@gmail.com>
Wed, 25 Mar 2026 20:23:51 +0000 (01:53 +0530)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Mar 2026 21:20:57 +0000 (14:20 -0700)
commit1e6434ebbd63d4ec0ad2f8bccf25bd0d98d55030
tree23067f37847c2fc9b8f5e01688c891ce16929061
parent864f55e1906897b630333675a52874c0fec2a45c
sequencer: extract revert message formatting into shared function

The logic for formatting revert commit messages (handling "Revert" and
"Reapply" cases, appending "This reverts commit <ref>.", and handling
merge-parent references) currently lives inline in do_pick_commit().
The upcoming replay --revert mode needs to reuse this logic.

Extract all of this into a new sequencer_format_revert_message()
function. The function takes a repository, the subject line, commit,
parent, a use_commit_reference flag, and the output strbuf. It handles
both regular reverts ("Revert "<subject>"") and revert-of-revert cases
("Reapply "<subject>""), and uses refer_to_commit() internally to
format the commit reference.

Update refer_to_commit() to take a struct repository parameter instead
of relying on the_repository, and a bool instead of reading from
replay_opts directly. This makes it usable from the new shared function
without pulling in sequencer-specific state.

Signed-off-by: Siddharth Asthana <siddharthasthana31@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c
sequencer.h