mbox series

[v5,00/16] sequencer: refactor functions working on a todo_list

Message ID 20190123205821.27459-1-alban.gruin@gmail.com (mailing list archive)
Headers show
Series sequencer: refactor functions working on a todo_list | expand

Message

Alban Gruin Jan. 23, 2019, 8:58 p.m. UTC
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 nd/the-index (36e7ed69de, "rebase-interactive.c: remove
the_repository references").

Changes since v4:

 - Adding todo_item_get_arg() to return the address of the parameter of
   an item to avoid confusion.

 - Squashed <d414e1a2-e5a1-ce15-96b5-cf294c7f3c92@ramsayjones.plus.com>
   and <5440ddf5-0b80-3d00-7daf-133a8611efa8@ramsayjones.plus.com> from
   Ramsay Jones.

Alban Gruin (16):
  sequencer: changes in parse_insn_buffer()
  sequencer: make the todo_list structure public
  sequencer: remove the 'arg' field from todo_item
  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()
  rebase--interactive: move transform_todo_file() to
    rebase--interactive.c

 builtin/rebase--interactive.c |  90 +++--
 rebase-interactive.c          | 143 +++++--
 rebase-interactive.h          |   9 +-
 sequencer.c                   | 687 ++++++++++++++--------------------
 sequencer.h                   |  81 +++-
 5 files changed, 533 insertions(+), 477 deletions(-)

Comments

Junio C Hamano Jan. 24, 2019, 9:54 p.m. UTC | #1
Alban Gruin <alban.gruin@gmail.com> writes:

Before I comment on anything else.

> This is based on nd/the-index (36e7ed69de, "rebase-interactive.c: remove
> the_repository references").

My attempt to apply these in order on top of that commit seems to
stop at step 5/16.  Are you sure you based them on it?

Thanks.
Alban Gruin Jan. 24, 2019, 10:43 p.m. UTC | #2
[I’m resending this as I clicked on the wrong button…]

Hi,

Le 24/01/2019 à 22:54, Junio C Hamano a écrit :
> Alban Gruin <alban.gruin@gmail.com> writes:
> 
> Before I comment on anything else.
> 
> > This is based on nd/the-index (36e7ed69de, "rebase-interactive.c: remove
> > the_repository references").
> 
> My attempt to apply these in order on top of that commit seems to
> stop at step 5/16.  Are you sure you based them on it?
> 
> Thanks.

It is based on that commit, but I mistakenly added a newline between `--- a/
sequencer.c` and `+++ b/sequencer.c` before sending this series.  Sorry about 
this.

I just reapplied all the patches I sent, and there is no other problem.  
Should I send this back?

-- Alban