Skip to content

Commit 1321c05

Browse files
committed
sequencer: remember the onelines when parsing the todo file
The `git-rebase-todo` file contains a list of commands. Most of those commands have the form <verb> <sha1> <oneline> The <oneline> is displayed primarily for the user's convenience, as rebase -i really interprets only the <verb> <sha1> part. However, there are *some* places in interactive rebase where the <oneline> is used to display messages, e.g. for reporting at which commit we stopped. So let's just remember it when parsing the todo file; we keep a copy of the entire todo file anyway (to write out the new `done` and `git-rebase-todo` file just before processing each command), so all we need to do is remember the begin and end offsets. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent d2cf3b2 commit 1321c05

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

sequencer.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,8 @@ static int read_and_refresh_cache(struct replay_opts *opts)
718718
struct todo_item {
719719
enum todo_command command;
720720
struct commit *commit;
721+
const char *arg;
722+
int arg_len;
721723
size_t offset_in_buf;
722724
};
723725

@@ -753,6 +755,8 @@ static int parse_insn_line(struct todo_item *item,
753755
if (bol == eol || *bol == '\r' || *bol == comment_line_char) {
754756
item->command = TODO_NOOP;
755757
item->commit = NULL;
758+
item->arg = bol;
759+
item->arg_len = eol - bol;
756760
return 0;
757761
}
758762

@@ -766,6 +770,8 @@ static int parse_insn_line(struct todo_item *item,
766770

767771
if (item->command == TODO_NOOP) {
768772
item->commit = NULL;
773+
item->arg = bol;
774+
item->arg_len = eol - bol;
769775
return 0;
770776
}
771777

@@ -781,6 +787,9 @@ static int parse_insn_line(struct todo_item *item,
781787
status = get_sha1(bol, commit_sha1);
782788
*end_of_object_name = saved;
783789

790+
item->arg = end_of_object_name + strspn(end_of_object_name, " \t");
791+
item->arg_len = (int)(eol - item->arg);
792+
784793
if (status < 0)
785794
return -1;
786795

0 commit comments

Comments
 (0)