@@ -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);
@@ -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);
@@ -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);
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@gmail.com> --- rebase-interactive.c | 14 ++++++++++++-- rebase-interactive.h | 3 ++- sequencer.c | 8 ++------ 3 files changed, 16 insertions(+), 9 deletions(-)