From 1e6434ebbd63d4ec0ad2f8bccf25bd0d98d55030 Mon Sep 17 00:00:00 2001 From: Siddharth Asthana Date: Thu, 26 Mar 2026 01:53:51 +0530 Subject: sequencer: extract revert message formatting into shared function The logic for formatting revert commit messages (handling "Revert" and "Reapply" cases, appending "This reverts commit .", 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 """) and revert-of-revert cases ("Reapply """), 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 Signed-off-by: Junio C Hamano --- sequencer.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'sequencer.h') diff --git a/sequencer.h b/sequencer.h index 719684c8a9..56cd50233a 100644 --- a/sequencer.h +++ b/sequencer.h @@ -271,4 +271,17 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence) */ int sequencer_get_update_refs_state(const char *wt_dir, struct string_list *refs); +/* + * Format a revert commit message with appropriate 'Revert ""' or + * 'Reapply ""' prefix and 'This reverts commit .' body. + * When use_commit_reference is set, is an abbreviated hash with + * subject and date; otherwise the full hex hash is used. + */ +void sequencer_format_revert_message(struct repository *r, + const char *subject, + const struct commit *commit, + const struct commit *parent, + bool use_commit_reference, + struct strbuf *message); + #endif /* SEQUENCER_H */ -- cgit v1.3