aboutsummaryrefslogtreecommitdiff
path: root/sequencer.h
diff options
context:
space:
mode:
authorSiddharth Asthana <siddharthasthana31@gmail.com>2026-03-26 01:53:51 +0530
committerJunio C Hamano <gitster@pobox.com>2026-03-25 14:20:57 -0700
commit1e6434ebbd63d4ec0ad2f8bccf25bd0d98d55030 (patch)
tree23067f37847c2fc9b8f5e01688c891ce16929061 /sequencer.h
parent864f55e1906897b630333675a52874c0fec2a45c (diff)
downloadgit-1e6434ebbd63d4ec0ad2f8bccf25bd0d98d55030.tar.xz
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>
Diffstat (limited to 'sequencer.h')
-rw-r--r--sequencer.h13
1 files changed, 13 insertions, 0 deletions
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 "<subject>"' or
+ * 'Reapply "<subject>"' prefix and 'This reverts commit <ref>.' body.
+ * When use_commit_reference is set, <ref> 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 */