sequencer (rebase -i): implement the 'reword' command

This is now trivial, as all the building blocks are in place: all we need
to do is to flip the "edit" switch when committing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin 2017-01-02 16:28:00 +01:00 коммит произвёл Junio C Hamano
Родитель 4a5146f9d2
Коммит 04efc8b57c
1 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -718,6 +718,7 @@ enum todo_command {
TODO_PICK = 0, TODO_PICK = 0,
TODO_REVERT, TODO_REVERT,
TODO_EDIT, TODO_EDIT,
TODO_REWORD,
TODO_FIXUP, TODO_FIXUP,
TODO_SQUASH, TODO_SQUASH,
/* commands that do something else than handling a single commit */ /* commands that do something else than handling a single commit */
@ -733,6 +734,7 @@ static struct {
{ 'p', "pick" }, { 'p', "pick" },
{ 0, "revert" }, { 0, "revert" },
{ 'e', "edit" }, { 'e', "edit" },
{ 'r', "reword" },
{ 'f', "fixup" }, { 'f', "fixup" },
{ 's', "squash" }, { 's', "squash" },
{ 'x', "exec" }, { 'x', "exec" },
@ -962,7 +964,9 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
} }
} }
if (is_fixup(command)) { if (command == TODO_REWORD)
edit = 1;
else if (is_fixup(command)) {
if (update_squash_messages(command, commit, opts)) if (update_squash_messages(command, commit, opts))
return -1; return -1;
amend = 1; amend = 1;
@ -1771,7 +1775,8 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
item->arg_len, item->arg); item->arg_len, item->arg);
} else if (res && is_rebase_i(opts)) } else if (res && is_rebase_i(opts))
return res | error_with_patch(item->commit, return res | error_with_patch(item->commit,
item->arg, item->arg_len, opts, res, 0); item->arg, item->arg_len, opts, res,
item->command == TODO_REWORD);
} else if (item->command == TODO_EXEC) { } else if (item->command == TODO_EXEC) {
char *end_of_arg = (char *)(item->arg + item->arg_len); char *end_of_arg = (char *)(item->arg + item->arg_len);
int saved = *end_of_arg; int saved = *end_of_arg;