Skip to content

Commit c22f7df

Browse files
dschogitster
authored andcommitted
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 offsets and lengths. As we will have to parse and remember the command-line for `exec` commands later, we do not call the field "oneline" but rather "arg" (and will reuse that for exec's command-line). Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2863584 commit c22f7df

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

sequencer.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,8 @@ static int read_and_refresh_cache(struct replay_opts *opts)
706706
struct todo_item {
707707
enum todo_command command;
708708
struct commit *commit;
709+
const char *arg;
710+
int arg_len;
709711
size_t offset_in_buf;
710712
};
711713

@@ -757,6 +759,9 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)
757759
status = get_sha1(bol, commit_sha1);
758760
*end_of_object_name = saved;
759761

762+
item->arg = end_of_object_name + strspn(end_of_object_name, " \t");
763+
item->arg_len = (int)(eol - item->arg);
764+
760765
if (status < 0)
761766
return -1;
762767

@@ -907,6 +912,8 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
907912

908913
item->command = command;
909914
item->commit = commit;
915+
item->arg = NULL;
916+
item->arg_len = 0;
910917
item->offset_in_buf = todo_list->buf.len;
911918
subject_len = find_commit_subject(commit_buffer, &subject);
912919
strbuf_addf(&todo_list->buf, "%s %s %.*s\n", command_string,

0 commit comments

Comments
 (0)