зеркало из https://github.com/microsoft/git.git
sequencer (rebase -i): implement the 'noop' command
The 'noop' command is probably the most boring of all rebase -i commands to support in the sequencer. Which makes it an excellent candidate for this first stab to add support for rebase -i's commands to the sequencer. For the moment, let's also treat empty lines and commented-out lines as 'noop'; We will refine that handling later in this patch series. To make it easier to identify "classes" of todo_commands (such as: determine whether a command is pick-like, i.e. handles a single commit), let's enforce a certain order of said commands. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
845839575d
Коммит
25c4366782
39
sequencer.c
39
sequencer.c
|
@ -607,14 +607,23 @@ static int allow_empty(struct replay_opts *opts, struct commit *commit)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note that ordering matters in this enum. Not only must it match the mapping
|
||||
* below, it is also divided into several sections that matter. When adding
|
||||
* new commands, make sure you add it in the right section.
|
||||
*/
|
||||
enum todo_command {
|
||||
/* commands that handle commits */
|
||||
TODO_PICK = 0,
|
||||
TODO_REVERT
|
||||
TODO_REVERT,
|
||||
/* commands that do nothing but are counted for reporting progress */
|
||||
TODO_NOOP
|
||||
};
|
||||
|
||||
static const char *todo_command_strings[] = {
|
||||
"pick",
|
||||
"revert"
|
||||
"revert",
|
||||
"noop"
|
||||
};
|
||||
|
||||
static const char *command_to_string(const enum todo_command command)
|
||||
|
@ -624,6 +633,10 @@ static const char *command_to_string(const enum todo_command command)
|
|||
die("Unknown command: %d", command);
|
||||
}
|
||||
|
||||
static int is_noop(const enum todo_command command)
|
||||
{
|
||||
return TODO_NOOP <= (size_t)command;
|
||||
}
|
||||
|
||||
static int do_pick_commit(enum todo_command command, struct commit *commit,
|
||||
struct replay_opts *opts)
|
||||
|
@ -879,6 +892,14 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)
|
|||
/* left-trim */
|
||||
bol += strspn(bol, " \t");
|
||||
|
||||
if (bol == eol || *bol == '\r' || *bol == comment_line_char) {
|
||||
item->command = TODO_NOOP;
|
||||
item->commit = NULL;
|
||||
item->arg = bol;
|
||||
item->arg_len = eol - bol;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(todo_command_strings); i++)
|
||||
if (skip_prefix(bol, todo_command_strings[i], &bol)) {
|
||||
item->command = i;
|
||||
|
@ -887,6 +908,13 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)
|
|||
if (i >= ARRAY_SIZE(todo_command_strings))
|
||||
return -1;
|
||||
|
||||
if (item->command == TODO_NOOP) {
|
||||
item->commit = NULL;
|
||||
item->arg = bol;
|
||||
item->arg_len = eol - bol;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Eat up extra spaces/ tabs before object name */
|
||||
padding = strspn(bol, " \t");
|
||||
if (!padding)
|
||||
|
@ -1289,7 +1317,12 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
|
|||
struct todo_item *item = todo_list->items + todo_list->current;
|
||||
if (save_todo(todo_list, opts))
|
||||
return -1;
|
||||
res = do_pick_commit(item->command, item->commit, opts);
|
||||
if (item->command <= TODO_REVERT)
|
||||
res = do_pick_commit(item->command, item->commit,
|
||||
opts);
|
||||
else if (!is_noop(item->command))
|
||||
return error(_("unknown command %d"), item->command);
|
||||
|
||||
todo_list->current++;
|
||||
if (res)
|
||||
return res;
|
||||
|
|
Загрузка…
Ссылка в новой задаче