sequencer: factor out code to append squash message
This code is going to grow over the next two commits so move it to its own function. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Charvi Mendiratta <charvi077@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood committed
Jan 19, 2021 at 13:10 UTC
498bb5b82e78ddf880ab8516d4e6ac4fc5f9b215
1 file changed
+12
-6
sequencer.c
+12
-6
@@ -1718,6 +1718,17 @@ static int is_pick_or_similar(enum todo_command command)
1718
}
1719
}
1720
1721
+static void append_squash_message(struct strbuf *buf, const char *body,
1722
+ struct replay_opts *opts)
1723
+{
1724
+ unlink(rebase_path_fixup_msg());
1725
+ strbuf_addf(buf, "\n%c ", comment_line_char);
1726
+ strbuf_addf(buf, _("This is the commit message #%d:"),
1727
+ ++opts->current_fixup_count + 1);
1728
+ strbuf_addstr(buf, "\n\n");
1729
+ strbuf_addstr(buf, body);
1730
+}
1731
+
1732
static int update_squash_messages(struct repository *r,
1733
enum todo_command command,
1734
struct commit *commit,
@@ -1779,12 +1790,7 @@ static int update_squash_messages(struct repository *r,
1790
find_commit_subject(message, &body);
1791
1792
if (command == TODO_SQUASH) {
1782
- unlink(rebase_path_fixup_msg());
1783
- strbuf_addf(&buf, "\n%c ", comment_line_char);
1784
- strbuf_addf(&buf, _("This is the commit message #%d:"),
1785
- ++opts->current_fixup_count + 1);
1786
- strbuf_addstr(&buf, "\n\n");
1787
- strbuf_addstr(&buf, body);
1793
+ append_squash_message(&buf, body, opts);
1794
} else if (command == TODO_FIXUP) {
1795
strbuf_addf(&buf, "\n%c ", comment_line_char);
1796
strbuf_addf(&buf, _("The commit message #%d will be skipped:"),