path: root/sequencer.h
diff options
authorAlban Gruin <>2019-03-05 19:17:54 (GMT)
committerJunio C Hamano <>2019-03-07 00:17:57 (GMT)
commit683153a438f1b6b8e1a289a71f36244bde67e38f (patch)
treecafa8f2d8cf438d11052caf8071c7b23523ca67e /sequencer.h
parent6ca89c6f399b86983c7e93a3c5b918cad8292b47 (diff)
sequencer: refactor sequencer_add_exec_commands() to work on a todo_list
This refactors sequencer_add_exec_commands() to work on a todo_list to avoid redundant reads and writes to the disk. Instead of inserting the `exec' commands between the other commands and re-parsing the buffer at the end, they are appended to the buffer once, and a new list of items is created. Items from the old list are copied across and new `exec' items are appended when necessary. This eliminates the need to reparse the buffer, but this also means we have to use todo_list_write_to_disk() to write the file. todo_list_add_exec_commands() and sequencer_add_exec_commands() are modified to take a string list instead of a string -- one item for each command. This makes it easier to insert a new command to the todo list for each command to execute. sequencer_add_exec_commands() still reads the todo list from the disk, as it is needed by rebase -p. complete_action() still uses sequencer_add_exec_commands() for now. This will be changed in a future commit. Signed-off-by: Alban Gruin <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'sequencer.h')
1 files changed, 3 insertions, 2 deletions
diff --git a/sequencer.h b/sequencer.h
index 217353e..87d04a3 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -146,12 +146,13 @@ int sequencer_make_script(struct repository *r, FILE *out, int argc,
const char **argv,
unsigned flags);
-int sequencer_add_exec_commands(struct repository *r, const char *command);
+int sequencer_add_exec_commands(struct repository *r,
+ struct string_list *commands);
int transform_todo_file(struct repository *r, unsigned flags);
int check_todo_list_from_file(struct repository *r);
int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
const char *shortrevisions, const char *onto_name,
- const char *onto, const char *orig_head, const char *cmd,
+ const char *onto, const char *orig_head, struct string_list *commands,
unsigned autosquash);
int rearrange_squash(struct repository *r);