Skip to content

Commit af1fc3a

Browse files
agrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ddb81e5 commit af1fc3a

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

rebase-interactive.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ static enum missing_commit_check_level get_missing_commit_check_level(void)
2828
return MISSING_COMMIT_CHECK_IGNORE;
2929
}
3030

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,
3233
struct strbuf *buf)
3334
{
3435
const char *msg = _("\nCommands:\n"
@@ -48,6 +49,15 @@ void append_todo_help(unsigned edit_todo, unsigned keep_empty,
4849
". specified). Use -c <commit> to reword the commit message.\n"
4950
"\n"
5051
"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+
}
5161

5262
strbuf_add_commented_lines(buf, msg, strlen(msg));
5363

rebase-interactive.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ struct strbuf;
55
struct repository;
66
struct todo_list;
77

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,
910
struct strbuf *buf);
1011
int edit_todo_list(struct repository *r, unsigned flags);
1112
int todo_list_check(struct todo_list *old_todo, struct todo_list *new_todo);

sequencer.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4619,22 +4619,13 @@ int todo_list_write_to_file(struct repository *r, struct todo_list *todo_list,
46194619
const char *file, const char *shortrevisions,
46204620
const char *shortonto, int num, unsigned flags)
46214621
{
4622-
int edit_todo = !(shortrevisions && shortonto), res;
4622+
int res;
46234623
struct strbuf buf = STRBUF_INIT;
46244624

46254625
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);
46384629

46394630
res = write_message(buf.buf, buf.len, file, 0);
46404631
strbuf_release(&buf);

0 commit comments

Comments
 (0)