Thread (97 messages) 97 messages, 6 authors, 2021-02-06

[RFC PATCH 2/9] sequencer: factor out code to append squash message

flat view
STALE2075d SUPERSEDED

From: Charvi Mendiratta <hidden>
Date: 2021-01-08 09:26:26
Subsystem: the rest · Maintainer: Linus Torvalds

Revision rfc of 5 in this series.

Revisions (5)
  1. rfc current
  2. rfc
  3. v3 [diff vs current]
  4. v4 [diff vs current]
  5. v5 [diff vs current]
From: Phillip Wood <redacted>

This code is going to grow over the next two commits so move it to
its own function.

Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Charvi Mendiratta <redacted>
---
 sequencer.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index f888a7ed3b..5062976d10 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1718,6 +1718,17 @@ static int is_pick_or_similar(enum todo_command command)
 	}
 }
 
+static void append_squash_message(struct strbuf *buf, const char *body,
+				  struct replay_opts *opts)
+{
+	unlink(rebase_path_fixup_msg());
+	strbuf_addf(buf, "\n%c ", comment_line_char);
+	strbuf_addf(buf, _("This is the commit message #%d:"),
+		    ++opts->current_fixup_count + 1);
+	strbuf_addstr(buf, "\n\n");
+	strbuf_addstr(buf, body);
+}
+
 static int update_squash_messages(struct repository *r,
 				  enum todo_command command,
 				  struct commit *commit,
@@ -1782,12 +1793,7 @@ static int update_squash_messages(struct repository *r,
 	find_commit_subject(message, &body);
 
 	if (command == TODO_SQUASH) {
-		unlink(rebase_path_fixup_msg());
-		strbuf_addf(&buf, "\n%c ", comment_line_char);
-		strbuf_addf(&buf, _("This is the commit message #%d:"),
-			    ++opts->current_fixup_count + 1);
-		strbuf_addstr(&buf, "\n\n");
-		strbuf_addstr(&buf, body);
+		append_squash_message(&buf, body, opts);
 	} else if (command == TODO_FIXUP) {
 		strbuf_addf(&buf, "\n%c ", comment_line_char);
 		strbuf_addf(&buf, _("The commit message #%d will be skipped:"),
-- 
2.29.0.rc1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help