Skip to content

Commit 498bb5b

Browse files
phillipwoodgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Charvi Mendiratta <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eab0df0 commit 498bb5b

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

sequencer.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,17 @@ static int is_pick_or_similar(enum todo_command command)
17181718
}
17191719
}
17201720

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+
17211732
static int update_squash_messages(struct repository *r,
17221733
enum todo_command command,
17231734
struct commit *commit,
@@ -1779,12 +1790,7 @@ static int update_squash_messages(struct repository *r,
17791790
find_commit_subject(message, &body);
17801791

17811792
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);
17881794
} else if (command == TODO_FIXUP) {
17891795
strbuf_addf(&buf, "\n%c ", comment_line_char);
17901796
strbuf_addf(&buf, _("The commit message #%d will be skipped:"),

0 commit comments

Comments
 (0)