summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Alban Gruin <alban.gruin@gmail.com>2019-03-05 20:18:02 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-03-07 09:17:57 +0900
commitaf1fc3adc5bf0d831ee3c1c8e86c1b7ce59e070e (patch)
tree18138a3a1ab2301972df0700fa66bd90fb48a94c
parentrebase-interactive: use todo_list_write_to_file() in edit_todo_list() (diff)
downloadtgif-af1fc3adc5bf0d831ee3c1c8e86c1b7ce59e070e.tar.xz
rebase-interactive: append_todo_help() changes
This moves the writing of the comment "Rebase $shortrevisions onto $shortonto ($command_count commands)" from todo_list_write_to_file() 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(). Signed-off-by: Alban Gruin <alban.gruin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--rebase-interactive.c12
-rw-r--r--rebase-interactive.h3
-rw-r--r--sequencer.c17
3 files changed, 17 insertions, 15 deletions
diff --git a/rebase-interactive.c b/rebase-interactive.c
index d396ecc599..807f8370db 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"
@@ -48,6 +49,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));
diff --git a/rebase-interactive.h b/rebase-interactive.h
index 187b5032d6..0e5925e3aa 100644
--- a/rebase-interactive.h
+++ b/rebase-interactive.h
@@ -5,7 +5,8 @@ struct strbuf;
struct repository;
struct todo_list;
-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(struct repository *r, 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 b7289c93d4..8f3836c479 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -4619,22 +4619,13 @@ int todo_list_write_to_file(struct repository *r, struct todo_list *todo_list,
const char *file, const char *shortrevisions,
const char *shortonto, int num, unsigned flags)
{
- int edit_todo = !(shortrevisions && shortonto), res;
+ int res;
struct strbuf buf = STRBUF_INIT;
todo_list_to_strbuf(r, todo_list, &buf, num, flags);
-
- if (flags & TODO_LIST_APPEND_TODO_HELP) {
- int command_count = count_commands(todo_list);
- 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);
- }
- append_todo_help(edit_todo, flags & TODO_LIST_KEEP_EMPTY, &buf);
- }
+ if (flags & TODO_LIST_APPEND_TODO_HELP)
+ append_todo_help(flags & TODO_LIST_KEEP_EMPTY, count_commands(todo_list),
+ shortrevisions, shortonto, &buf);
res = write_message(buf.buf, buf.len, file, 0);
strbuf_release(&buf);