rebase -i: pass struct replay_opts to parse_insn_line()
This new parameter will be used in the next commit. As adding the parameter requires quite a few changes to plumb it through the call chain these are separated into their own commit to avoid cluttering up the next commit with incidental changes. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
19981daefd
commit
0c26738aa4
22
sequencer.c
22
sequencer.c
@ -2573,8 +2573,9 @@ static int check_label_or_ref_arg(enum todo_command command, const char *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_insn_line(struct repository *r, struct todo_item *item,
|
||||
const char *buf, const char *bol, char *eol)
|
||||
static int parse_insn_line(struct repository *r, struct replay_opts *opts UNUSED,
|
||||
struct todo_item *item, const char *buf,
|
||||
const char *bol, char *eol)
|
||||
{
|
||||
struct object_id commit_oid;
|
||||
char *end_of_object_name;
|
||||
@ -2708,8 +2709,8 @@ int sequencer_get_last_command(struct repository *r UNUSED, enum replay_action *
|
||||
return ret;
|
||||
}
|
||||
|
||||
int todo_list_parse_insn_buffer(struct repository *r, char *buf,
|
||||
struct todo_list *todo_list)
|
||||
int todo_list_parse_insn_buffer(struct repository *r, struct replay_opts *opts,
|
||||
char *buf, struct todo_list *todo_list)
|
||||
{
|
||||
struct todo_item *item;
|
||||
char *p = buf, *next_p;
|
||||
@ -2727,7 +2728,7 @@ int todo_list_parse_insn_buffer(struct repository *r, char *buf,
|
||||
|
||||
item = append_new_todo(todo_list);
|
||||
item->offset_in_buf = p - todo_list->buf.buf;
|
||||
if (parse_insn_line(r, item, buf, p, eol)) {
|
||||
if (parse_insn_line(r, opts, item, buf, p, eol)) {
|
||||
res = error(_("invalid line %d: %.*s"),
|
||||
i, (int)(eol - p), p);
|
||||
item->command = TODO_COMMENT + 1;
|
||||
@ -2875,7 +2876,7 @@ static int read_populate_todo(struct repository *r,
|
||||
if (strbuf_read_file_or_whine(&todo_list->buf, todo_file) < 0)
|
||||
return -1;
|
||||
|
||||
res = todo_list_parse_insn_buffer(r, todo_list->buf.buf, todo_list);
|
||||
res = todo_list_parse_insn_buffer(r, opts, todo_list->buf.buf, todo_list);
|
||||
if (res) {
|
||||
if (is_rebase_i(opts))
|
||||
return error(_("please fix this using "
|
||||
@ -2905,7 +2906,7 @@ static int read_populate_todo(struct repository *r,
|
||||
struct todo_list done = TODO_LIST_INIT;
|
||||
|
||||
if (strbuf_read_file(&done.buf, rebase_path_done(), 0) > 0 &&
|
||||
!todo_list_parse_insn_buffer(r, done.buf.buf, &done))
|
||||
!todo_list_parse_insn_buffer(r, opts, done.buf.buf, &done))
|
||||
todo_list->done_nr = count_commands(&done);
|
||||
else
|
||||
todo_list->done_nr = 0;
|
||||
@ -5251,7 +5252,8 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)
|
||||
goto release_todo_list;
|
||||
|
||||
if (file_exists(rebase_path_dropped())) {
|
||||
if ((res = todo_list_check_against_backup(r, &todo_list)))
|
||||
if ((res = todo_list_check_against_backup(r, opts,
|
||||
&todo_list)))
|
||||
goto release_todo_list;
|
||||
|
||||
unlink(rebase_path_dropped());
|
||||
@ -6294,7 +6296,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
|
||||
return error(_("nothing to do"));
|
||||
}
|
||||
|
||||
res = edit_todo_list(r, todo_list, &new_todo, shortrevisions,
|
||||
res = edit_todo_list(r, opts, todo_list, &new_todo, shortrevisions,
|
||||
shortonto, flags);
|
||||
if (res == -1)
|
||||
return -1;
|
||||
@ -6322,7 +6324,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
|
||||
strbuf_release(&buf2);
|
||||
/* Nothing is done yet, and we're reparsing, so let's reset the count */
|
||||
new_todo.total_nr = 0;
|
||||
if (todo_list_parse_insn_buffer(r, new_todo.buf.buf, &new_todo) < 0)
|
||||
if (todo_list_parse_insn_buffer(r, opts, new_todo.buf.buf, &new_todo) < 0)
|
||||
BUG("invalid todo list after expanding IDs:\n%s",
|
||||
new_todo.buf.buf);
|
||||
|
||||
|
Reference in New Issue
Block a user