Web lists-archives.com

[PATCH 11/15] rebase-interactive: append_todo_help() changes




This moves the writing of the comment "Rebase $shortrevisions onto
$shortonto ($command_count commands)" from complete_action() to
append_todo_help().

shortrevisions, shortonto, and command_count are passed as parameters to
append_todo_help().

During the initial edit of the todo list, shortrevisions and shortonto
are not NULL.  Therefore, if shortrevisions or shortonto is NULL, then
edit_todo would be true, otherwise it would be false.  Thus, edit_todo
is removed from the parameters of append_todo_help().

edit_todo_list() and complete_action() are modified to fit these
changes.

Signed-off-by: Alban Gruin <alban.gruin@xxxxxxxxx>
---
 rebase-interactive.c | 14 ++++++++++++--
 rebase-interactive.h |  3 ++-
 sequencer.c          |  8 ++------
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/rebase-interactive.c b/rebase-interactive.c
index f42d48e192..7168d56d17 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -28,7 +28,8 @@ static enum missing_commit_check_level get_missing_commit_check_level(void)
 	return MISSING_COMMIT_CHECK_IGNORE;
 }
 
-void append_todo_help(unsigned edit_todo, unsigned keep_empty,
+void append_todo_help(unsigned keep_empty, int command_count,
+		      const char *shortrevisions, const char *shortonto,
 		      struct strbuf *buf)
 {
 	const char *msg = _("\nCommands:\n"
@@ -47,6 +48,15 @@ void append_todo_help(unsigned edit_todo, unsigned keep_empty,
 ".       specified). Use -c <commit> to reword the commit message.\n"
 "\n"
 "These lines can be re-ordered; they are executed from top to bottom.\n");
+	unsigned edit_todo = !(shortrevisions && shortonto);
+
+	if (!edit_todo) {
+		strbuf_addch(buf, '\n');
+		strbuf_commented_addf(buf, Q_("Rebase %s onto %s (%d command)",
+					      "Rebase %s onto %s (%d commands)",
+					      command_count),
+				      shortrevisions, shortonto, command_count);
+	}
 
 	strbuf_add_commented_lines(buf, msg, strlen(msg));
 
@@ -89,7 +99,7 @@ int edit_todo_list(unsigned flags)
 	if (!todo_list_parse_insn_buffer(todo_list.buf.buf, &todo_list))
 		todo_list_transform(&todo_list, flags | TODO_LIST_SHORTEN_IDS);
 
-	append_todo_help(1, 0, &todo_list.buf);
+	append_todo_help(flags, 0, NULL, NULL, &todo_list.buf);
 
 	if (write_message(todo_list.buf.buf, todo_list.buf.len, todo_file, 0)) {
 		todo_list_release(&todo_list);
diff --git a/rebase-interactive.h b/rebase-interactive.h
index 6bc7bc315d..61858f3a02 100644
--- a/rebase-interactive.h
+++ b/rebase-interactive.h
@@ -1,7 +1,8 @@
 #ifndef REBASE_INTERACTIVE_H
 #define REBASE_INTERACTIVE_H
 
-void append_todo_help(unsigned edit_todo, unsigned keep_empty,
+void append_todo_help(unsigned keep_empty, int command_count,
+		      const char *shortrevisions, const char *shortonto,
 		      struct strbuf *buf);
 int edit_todo_list(unsigned flags);
 int todo_list_check(struct todo_list *old_todo, struct todo_list *new_todo);
diff --git a/sequencer.c b/sequencer.c
index a432b64048..94d3058359 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -4636,12 +4636,8 @@ int complete_action(struct replay_opts *opts, unsigned flags,
 
 	todo_list_transform(todo_list, flags | TODO_LIST_SHORTEN_IDS);
 
-	strbuf_addch(buf, '\n');
-	strbuf_commented_addf(buf, Q_("Rebase %s onto %s (%d command)",
-				      "Rebase %s onto %s (%d commands)",
-				      command_count),
-			      shortrevisions, shortonto, command_count);
-	append_todo_help(0, flags & TODO_LIST_KEEP_EMPTY, buf);
+	append_todo_help(flags & TODO_LIST_KEEP_EMPTY, command_count,
+			 shortrevisions, shortonto, buf);
 
 	if (write_message(buf->buf, buf->len, todo_file, 0))
 		return error_errno(_("could not write '%s'"), todo_file);
-- 
2.19.1