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>
Alban Gruin committed
Mar 5, 2019 at 20:18 UTC
af1fc3adc5bf0d831ee3c1c8e86c1b7ce59e070e
3 files changed
+17
-15
rebase-interactive.c
+11
-1
@@ -28,7 +28,8 @@ static enum missing_commit_check_level get_missing_commit_check_level(void)
28
return MISSING_COMMIT_CHECK_IGNORE;
29
}
30
31
-void append_todo_help(unsigned edit_todo, unsigned keep_empty,
31
+void append_todo_help(unsigned keep_empty, int command_count,
32
+ const char *shortrevisions, const char *shortonto,
33
struct strbuf *buf)
34
{
35
const char *msg = _("\nCommands:\n"
@@ -48,6 +49,15 @@ void append_todo_help(unsigned edit_todo, unsigned keep_empty,
49
". specified). Use -c <commit> to reword the commit message.\n"
50
"\n"
51
"These lines can be re-ordered; they are executed from top to bottom.\n");
52
+ unsigned edit_todo = !(shortrevisions && shortonto);
53
+
54
+ if (!edit_todo) {
55
+ strbuf_addch(buf, '\n');
56
+ strbuf_commented_addf(buf, Q_("Rebase %s onto %s (%d command)",
57
+ "Rebase %s onto %s (%d commands)",
58
+ command_count),
59
+ shortrevisions, shortonto, command_count);
60
+ }
61
62
strbuf_add_commented_lines(buf, msg, strlen(msg));
63
rebase-interactive.h
+2
-1
@@ -5,7 +5,8 @@ struct strbuf;
5
struct repository;
6
struct todo_list;
7
8
-void append_todo_help(unsigned edit_todo, unsigned keep_empty,
8
+void append_todo_help(unsigned keep_empty, int command_count,
9
+ const char *shortrevisions, const char *shortonto,
10
struct strbuf *buf);
11
int edit_todo_list(struct repository *r, unsigned flags);
12
int todo_list_check(struct todo_list *old_todo, struct todo_list *new_todo);
sequencer.c
+4
-13
@@ -4619,22 +4619,13 @@ int todo_list_write_to_file(struct repository *r, struct todo_list *todo_list,
4619
const char *file, const char *shortrevisions,
4620
const char *shortonto, int num, unsigned flags)
4621
{
4622
- int edit_todo = !(shortrevisions && shortonto), res;
4622
+ int res;
4623
struct strbuf buf = STRBUF_INIT;
4624
4625
todo_list_to_strbuf(r, todo_list, &buf, num, flags);
4626
-
4627
- if (flags & TODO_LIST_APPEND_TODO_HELP) {
4628
- int command_count = count_commands(todo_list);
4629
- if (!edit_todo) {
4630
- strbuf_addch(&buf, '\n');
4631
- strbuf_commented_addf(&buf, Q_("Rebase %s onto %s (%d command)",
4632
- "Rebase %s onto %s (%d commands)",
4633
- command_count),
4634
- shortrevisions, shortonto, command_count);
4635
- }
4636
- append_todo_help(edit_todo, flags & TODO_LIST_KEEP_EMPTY, &buf);
4637
- }
4626
+ if (flags & TODO_LIST_APPEND_TODO_HELP)
4627
+ append_todo_help(flags & TODO_LIST_KEEP_EMPTY, count_commands(todo_list),
4628
+ shortrevisions, shortonto, &buf);
4629
4630
res = write_message(buf.buf, buf.len, file, 0);
4631
strbuf_release(&buf);