At the center of the "interactive" part of the interactive rebase lies the todo list. When the user starts an interactive rebase, a todo list is generated, presented to the user (who then edits it using a text editor), read back, and then is checked and processed before the actual rebase takes place. Some of this processing includes adding execs commands, reordering fixup! and squash! commits, and checking if no commits were accidentally dropped by the user. Before I converted the interactive rebase in C, these functions were called by git-rebase--interactive.sh through git-rebase--helper. Since the only way to pass around a large amount of data between a shell script and a C program is to use a file (or any declination of a file), the functions that checked and processed the todo list were directly working on a file, the same file that the user edited. During the conversion, I did not address this issue, which lead to a complete_action() that reads the todo list file, does some computation based on its content, and writes it back to the disk, several times in the same function. As it is not an efficient way to handle a data structure, this patch series refactor the functions that processes the todo list to work on a todo_list structure instead of reading it from the disk. Some commits consists in modifying edit_todo_list() (initially used by --edit-todo) to handle the initial edition of the todo list, to increase code sharing. This is based on 8858448bb4 ("Ninth batch for 2.20", 2018-11-06) to avoid conflicts with 'js/rebase-i-break'. Changes since v2: - Clarifying some commit messages - Reducing the number of parameters in todo_list_write_to_file() - sequencer_add_exec_commands() now requests a string list instead of a string. - Replacing calls to memcpy() by shallow copies - Applying array.cocci.patch Alban Gruin (16): sequencer: changes in parse_insn_buffer() sequencer: make the todo_list structure public sequencer: refactor transform_todos() to work on a todo_list sequencer: introduce todo_list_write_to_file() sequencer: refactor check_todo_list() to work on a todo_list sequencer: refactor sequencer_add_exec_commands() to work on a todo_list sequencer: refactor rearrange_squash() to work on a todo_list sequencer: make sequencer_make_script() write its script to a strbuf sequencer: change complete_action() to use the refactored functions sequencer: refactor skip_unnecessary_picks() to work on a todo_list rebase-interactive: use todo_list_write_to_file() in edit_todo_list() rebase-interactive: append_todo_help() changes rebase-interactive: rewrite edit_todo_list() to handle the initial edit sequencer: use edit_todo_list() in complete_action() sequencer: fix a call to error() in transform_todo_file() rebase--interactive: move transform_todo_file() to rebase--interactive.c builtin/rebase--interactive.c | 81 +++-- rebase-interactive.c | 142 ++++++-- rebase-interactive.h | 8 +- sequencer.c | 615 +++++++++++++--------------------- sequencer.h | 75 ++++- 5 files changed, 481 insertions(+), 440 deletions(-) Range-diff against v2: 1: 55fa1fff03 = 1: 9ae965b73e sequencer: changes in parse_insn_buffer() 2: 192fb771ed < -: ---------- sequencer: make the todo_list structure public -: ---------- > 2: 9c15cdede4 sequencer: make the todo_list structure public 3: e2f821ffbe = 3: a5c01d5a95 sequencer: refactor transform_todos() to work on a todo_list 4: 0001e8dbde < -: ---------- sequencer: introduce todo_list_write_to_file() -: ---------- > 4: f2781fe4c3 sequencer: introduce todo_list_write_to_file() 5: aa9554d81d = 5: 337e0dce57 sequencer: refactor check_todo_list() to work on a todo_list 6: 8bd793caf5 < -: ---------- sequencer: refactor sequencer_add_exec_commands() to work on a todo_list 7: e984946cef < -: ---------- sequencer: refactor rearrange_squash() to work on a todo_list 8: cf05254acf < -: ---------- sequencer: make sequencer_make_script() write its script to a strbuf 9: ac79151792 < -: ---------- sequencer: change complete_action() to use the refactored functions 10: e227e38b24 < -: ---------- sequencer: refactor skip_unnecessary_picks() to work on a todo_list 11: 5bfd9d3460 < -: ---------- rebase-interactive: use todo_list_write_to_file() in edit_todo_list() 12: f4d7578a77 < -: ---------- rebase-interactive: append_todo_help() changes 13: 11c43f1dfe < -: ---------- rebase-interactive: rewrite edit_todo_list() to handle the initial edit 14: e9a6396c26 < -: ---------- sequencer: use edit_todo_list() in complete_action() -: ---------- > 6: 2c75eed153 sequencer: refactor sequencer_add_exec_commands() to work on a todo_list -: ---------- > 7: 90e01bc713 sequencer: refactor rearrange_squash() to work on a todo_list -: ---------- > 8: 850261fbf7 sequencer: make sequencer_make_script() write its script to a strbuf -: ---------- > 9: 7bcfe98241 sequencer: change complete_action() to use the refactored functions -: ---------- > 10: 50cdea7ef7 sequencer: refactor skip_unnecessary_picks() to work on a todo_list -: ---------- > 11: 6d4fcf96e0 rebase-interactive: use todo_list_write_to_file() in edit_todo_list() -: ---------- > 12: 3bea4eb9ba rebase-interactive: append_todo_help() changes -: ---------- > 13: bfe8f568ee rebase-interactive: rewrite edit_todo_list() to handle the initial edit -: ---------- > 14: 0d6499b7c8 sequencer: use edit_todo_list() in complete_action() 15: a36d094610 = 15: 21d3d1abd7 sequencer: fix a call to error() in transform_todo_file() 16: 344e8ceeed < -: ---------- rebase--interactive: move transform_todo_file() to rebase--interactive.c -: ---------- > 16: 22fd27fa2f rebase--interactive: move transform_todo_file() to rebase--interactive.c -- 2.19.1.872.ga867da739e