Skip to content
Permalink
Branch: master
Commits on Mar 7, 2019
  1. rebase--interactive: move transform_todo_file()

    agrn authored and gitster committed Mar 5, 2019
    As transform_todo_file() is only needed inside of
    rebase--interactive.c for `rebase -p', it is moved there from
    sequencer.c.
    
    The parameter r (repository) is dropped along the way.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. sequencer: use edit_todo_list() in complete_action()

    agrn authored and gitster committed Mar 5, 2019
    This changes complete_action() to use edit_todo_list(), now that it can
    handle the initial edit of the todo list.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. rebase-interactive: rewrite edit_todo_list() to handle the initial edit

    agrn authored and gitster committed Mar 5, 2019
    edit_todo_list() is changed to work on a todo_list, and to handle the
    initial edition of the todo list (ie. making a backup of the todo
    list).
    
    It does not check for dropped commits yet, as todo_list_check() does not
    take the commits that have already been processed by the rebase (ie. the
    todo list is edited in the middle of a rebase session).
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. rebase-interactive: append_todo_help() changes

    agrn authored and gitster committed Mar 5, 2019
    This moves the writing of the comment "Rebase $shortrevisions onto
    $shortonto ($command_count commands)" from todo_list_write_to_file() to
    append_todo_help().
    
    shortrevisions, shortonto, and command_count are passed as parameters to
    append_todo_help().
    
    During the initial edit of the todo list, shortrevisions and shortonto
    are not NULL.  Therefore, if shortrevisions or shortonto is NULL, then
    edit_todo would be true, otherwise it would be false.  Thus, edit_todo
    is removed from the parameters of append_todo_help().
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5. rebase-interactive: use todo_list_write_to_file() in edit_todo_list()

    agrn authored and gitster committed Mar 5, 2019
    Just like complete_action(), edit_todo_list() used a
    function (transform_todo_file()) that read the todo list from the disk
    and wrote it back, resulting in useless disk accesses.
    
    This changes edit_todo_list() to call directly todo_list_write_to_file()
    instead.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6. sequencer: refactor skip_unnecessary_picks() to work on a todo_list

    agrn authored and gitster committed Mar 5, 2019
    This refactors skip_unnecessary_picks() to work on a todo_list.  As this
    function is only called by complete_action() (and thus is not used by
    rebase -p), the file-handling logic is completely dropped here.
    
    Instead of truncating the todo list’s buffer, the items are moved to
    the beginning of the list, eliminating the need to reparse the list.
    This also means its buffer cannot be directly written to the disk.
    
    rewrite_file() is then removed, as it is now unused.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7. rebase--interactive: move rearrange_squash_in_todo_file()

    agrn authored and gitster committed Mar 5, 2019
    As rearrange_squash_in_todo_file() is only needed inside of
    rebase--interactive.c for `rebase -p', it is moved there from
    sequencer.c.
    
    The parameter r (repository) is dropped along the way, and the error
    handling is slightly improved.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8. rebase--interactive: move sequencer_add_exec_commands()

    agrn authored and gitster committed Mar 5, 2019
    As sequencer_add_exec_commands() is only needed inside of
    rebase--interactive.c for `rebase -p', it is moved there from
    sequencer.c.
    
    The parameter r (repository) is dropped along the way.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9. sequencer: change complete_action() to use the refactored functions

    agrn authored and gitster committed Mar 5, 2019
    complete_action() used functions that read the todo-list file, made some
    changes to it, and wrote it back to the disk.
    
    The previous commits were dedicated to separate the part that deals with
    the file from the actual logic of these functions.  Now that this is
    done, we can call directly the "logic" functions to avoid useless file
    access.
    
    The parsing of the list has to be done by the caller.  If the buffer of
    the todo list provided by the caller is empty, a `noop' command is
    directly added to the todo list, without touching the buffer.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10. sequencer: make sequencer_make_script() write its script to a strbuf

    agrn authored and gitster committed Mar 5, 2019
    This makes sequencer_make_script() write its script to a strbuf (ie. the
    buffer of a todo_list) instead of a FILE.  This reduce the amount of
    read/write made by rebase interactive.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11. sequencer: refactor rearrange_squash() to work on a todo_list

    agrn authored and gitster committed Mar 5, 2019
    This refactors rearrange_squash() to work on a todo_list to avoid
    redundant reads and writes.  The function is renamed
    todo_list_rearrange_squash().
    
    The old version created a new buffer, which was directly written to the
    disk.  This new version creates a new item list by just copying items
    from the old item list, without creating a new buffer.  This eliminates
    the need to reparse the todo list, but this also means its buffer cannot
    be directly written to the disk.
    
    As rebase -p still need to check the todo list from the disk, a new
    function is introduced, rearrange_squash_in_todo_file().
    
    complete_action() still uses rearrange_squash_in_todo_file() for now.
    This will be changed in a future commit.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12. sequencer: refactor sequencer_add_exec_commands() to work on a todo_list

    agrn authored and gitster committed Mar 5, 2019
    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 <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jan 29, 2019
  1. sequencer: refactor check_todo_list() to work on a todo_list

    agrn authored and gitster committed Jan 29, 2019
    This refactors check_todo_list() to work on a todo_list to avoid
    redundant reads and writes to the disk.  The function is renamed
    todo_list_check().  The parsing of the two todo lists is left to the
    caller.
    
    As rebase -p still need to check the todo list from the disk, a new
    function is introduced, check_todo_list_from_file().  It reads the file
    from the disk, parses it, pass the todo_list to todo_list_check(), and
    writes it back to the disk.
    
    As get_missing_commit_check_level() and the enum
    missing_commit_check_level are no longer needed inside of sequencer.c,
    they are moved to rebase-interactive.c, and made static again.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. sequencer: introduce todo_list_write_to_file()

    agrn authored and gitster committed Jan 29, 2019
    This introduces a new function to recreate the text of a todo list from
    its commands and write it to a file.  This will be useful as the next
    few commits will change the use of the buffer in struct todo_list so it
    will no longer be a mirror of the file on disk.
    
    This functionality already exists in todo_list_transform(), but this
    function was made to replace the buffer of a todo list, which is not
    what we want here.  Thus, the part of todo_list_transform() that
    replaces the buffer is dropped, and the function is renamed
    todo_list_to_strbuf().  It is called by todo_list_write_to_file() to
    fill the buffer to write to the disk.
    
    todo_list_write_to_file() can also take care of appending the help text
    to the buffer before writing it to the disk, or to write only the first
    n items of the list.  This feature will be used by
    skip_unnecessary_picks(), which has to write done commands in a file.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. sequencer: refactor transform_todos() to work on a todo_list

    agrn authored and gitster committed Jan 29, 2019
    This refactors transform_todos() to work on a todo_list.  The function
    is renamed todo_list_transform().
    
    As rebase -p still need to check the todo list from the disk, a new
    function is introduced, transform_todo_file().  It is still used by
    complete_action() and edit_todo_list() for now, but they will be
    replaced in a future commit.
    
    todo_list_transform() is not a static function, because it will be used
    by edit_todo_list() from rebase-interactive.c in a future commit.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. sequencer: remove the 'arg' field from todo_item

    agrn authored and gitster committed Jan 29, 2019
    The 'arg' field of todo_item used to store the address of the first byte
    of the parameter of a command in a todo list.  It was associated with
    the length of the parameter (the 'arg_len' field).
    
    This replaces the 'arg' field by 'arg_offset'.  This new field does not
    store the address of the parameter, but the position of the first
    character of the parameter in the buffer.  todo_item_get_arg() is added
    to return the address of the parameter of an item.
    
    This will prevent todo_list_add_exec_commands() from having to do awful
    pointer arithmetics when growing the todo list buffer.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jan 8, 2019
  1. sequencer: make the todo_list structure public

    agrn authored and gitster committed Dec 29, 2018
    This makes the structures todo_list and todo_item, and the functions
    todo_list_release() and parse_insn_buffer(), accessible outside of
    sequencer.c.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. sequencer: changes in parse_insn_buffer()

    agrn authored and gitster committed Dec 29, 2018
    This clears the number of items of a todo_list before parsing it to
    allow to parse the same list multiple times without issues.  As its
    items are not dynamically allocated, or don’t need to allocate memory,
    no additionnal memory management is required here.
    
    Furthermore, if a line is invalid, the type of the corresponding
    command is set to a garbage value, and its argument is defined properly.
    This will allow to recreate the text of a todo list from its commands,
    even if one of them is incorrect.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Nov 12, 2018
  1. p3400: replace calls to `git checkout -b' by `git checkout -B'

    agrn authored and gitster committed Nov 9, 2018
    p3400 makes a copy of the current repository to test git-rebase
    performance, and creates new branches in the copy with `git checkout
    -b'.  If the original repository has branches with the same name as the
    script is trying to create, this operation will fail.
    
    This replaces these calls by `git checkout -B' to force the creation and
    update of these branches.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 9, 2018
  1. rebase -i: move rebase--helper modes to rebase--interactive

    agrn authored and gitster committed Sep 27, 2018
    This moves the rebase--helper modes still used by
    git-rebase--preserve-merges.sh (`--shorten-ids`, `--expand-ids`,
    `--check-todo-list`, `--rearrange-squash` and `--add-exec-commands`) to
    rebase--interactive.c.
    
    git-rebase--preserve-merges.sh is modified accordingly, and
    rebase--helper.c is removed as it is useless now.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. rebase -i: remove git-rebase--interactive.sh

    agrn authored and gitster committed Sep 27, 2018
    This removes git-rebase--interactive.sh, as its functionnality has been
    replaced by git-rebase--interactive2.
    
    git-rebase--interactive2.c is then renamed to git-rebase--interactive.c.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. rebase--interactive2: rewrite the submodes of interactive rebase in C

    agrn authored and gitster committed Sep 27, 2018
    This rewrites the submodes of interactive rebase (`--continue`,
    `--skip`, `--edit-todo`, and `--show-current-patch`) in C.
    
    git-rebase.sh is then modified to call directly git-rebase--interactive2
    instead of git-rebase--interactive.sh.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. rebase -i: implement the main part of interactive rebase as a builtin

    agrn authored and gitster committed Sep 27, 2018
    This rewrites the part of interactive rebase which initializes the
    basic state, make the script and complete the action, as a buitin, named
    git-rebase--interactive2 for now.  Others modes (`--continue`,
    `--edit-todo`, etc.) will be rewritten in the next commit.
    
    git-rebase--interactive.sh is modified to call git-rebase--interactive2
    instead of git-rebase--helper.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Aug 29, 2018
  1. rebase -i: rewrite init_basic_state() in C

    agrn authored and gitster committed Aug 28, 2018
    This rewrites init_basic_state() from shell to C.  The call to
    write_basic_state() in cmd_rebase__helper() is replaced by a call to the
    new function.
    
    The shell version is then stripped from git-rebase--interactive.sh.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. rebase -i: rewrite write_basic_state() in C

    agrn authored and gitster committed Aug 28, 2018
    This rewrites write_basic_state() from git-rebase.sh in C.  This is the
    first step in the conversion of init_basic_state(), hence the mode in
    rebase--helper.c is called INIT_BASIC_STATE.  init_basic_state() will be
    converted in the next commit.
    
    The part of read_strategy_opts() that parses the stategy options is
    moved to a new function to allow its use in rebase--helper.c.
    
    Finally, the call to write_basic_state() is removed from
    git-rebase--interactive.sh, replaced by a call to `--init-basic-state`.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. rebase -i: rewrite the rest of init_revisions_and_shortrevisions() in C

    agrn authored and gitster committed Aug 28, 2018
    This rewrites the part of init_revisions_and_shortrevisions() needed by
    `--complete-action` (which initialize $shortrevisions) from shell to C.
    
    When `upstream` is empty, it means that the user launched a `rebase
    --root`, and `onto` contains the ID of an empty commit.  As a range
    between an empty commit and `head` is not really meaningful, `onto` is
    not used to initialize `shortrevisions` in this case.
    
    The corresponding arguments passed to `--complete-action` are then
    dropped, and init_revisions_and_shortrevisions() is stripped from
    git-rebase--interactive.sh
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. rebase -i: implement the logic to initialize $revisions in C

    agrn authored and gitster committed Aug 28, 2018
    This rewrites the part of init_revisions_and_shortrevisions() needed by
    `--make-script` from shell to C.  The new version is called
    get_revision_ranges(), and is a static function inside of
    rebase--helper.c.  As this does not initialize $shortrevision, the
    original shell version is not yet stripped.
    
    Unlike init_revisions_and_shortrevisions(), get_revision_ranges()
    doesn’t write $squash_onto to the state directory, it’s done by the
    handler of `--make-script` instead.
    
    Finally, this drops the $revision argument passed to `--make-script` in
    git-rebase--interactive.sh, and rebase--helper is changed accordingly.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5. rebase -i: remove unused modes and functions

    agrn authored and gitster committed Aug 28, 2018
    This removes the modes `--skip-unnecessary-picks`, `--append-todo-help`,
    and `--checkout-onto` from rebase--helper.c, the functions of
    git-rebase--interactive.sh that were rendered useless by the rewrite of
    complete_action(), and append_todo_help_to_file() from
    rebase-interactive.c.
    
    skip_unnecessary_picks() and checkout_onto() becomes static, as they are
    only used inside of the sequencer.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6. rebase -i: rewrite complete_action() in C

    agrn authored and gitster committed Aug 28, 2018
    This rewrites complete_action() from shell to C.
    
    A new mode is added to rebase--helper (`--complete-action`), as well as
    a new flag (`--autosquash`).
    
    Finally, complete_action() is stripped from git-rebase--interactive.sh.
    
    The original complete_action() would return the code 2 when the todo
    list contained no actions.  This was a special case for rebase -i and
    -p; git-rebase.sh would then apply the autostash, delete the state
    directory, and die with the message "Nothing to do".  This cleanup is
    rewritten in C instead of returning 2.  As rebase -i no longer returns
    2, the comment describing this behaviour in git-rebase.sh is updated to
    reflect this change.
    
    The message "Nothing to do" is now printed with error(), and so becomes
    "error: nothing to do".  Some tests in t3404 check this value, so they
    are updated to fit this change.
    
    The first check might seem useless as we write "noop" to the todo list
    if it is empty.  Actually, the todo list might contain commented
    commands (ie. empty commits).  In this case, complete_action() won’t
    write "noop", and will abort without starting the editor.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Aug 10, 2018
  1. t3404: todo list with commented-out commands only aborts

    agrn authored and gitster committed Aug 10, 2018
    If the todo list generated by `--make-script` is empty,
    complete_action() writes a noop, but if it has only commented-out
    commands, it will abort with the message "Nothing to do", and does not
    launch the editor.  This adds a new test to ensure that
    complete_action() behaves this way.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. sequencer: change the way skip_unnecessary_picks() returns its result

    agrn authored and gitster committed Aug 10, 2018
    Instead of skip_unnecessary_picks() printing its result to stdout, it
    returns it into a struct object_id, as the rewrite of complete_action()
    (to come in the next commit) will need it.
    
    rebase--helper then is modified to fit this change.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. sequencer: refactor append_todo_help() to write its message to a buffer

    agrn authored and gitster committed Aug 10, 2018
    This refactors append_todo_help() to write its message to a buffer
    instead of the todo-list.  This is needed for the rewrite of
    complete_action(), which will come after the next commit.
    
    As rebase--helper still needs the file manipulation part of
    append_todo_help(), it is extracted to a temporary function,
    append_todo_help_to_file().  This function will go away after the
    rewrite of complete_action().
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. rebase -i: rewrite checkout_onto() in C

    agrn authored and gitster committed Aug 10, 2018
    This rewrites checkout_onto() from shell to C.
    
    A new command (“checkout-onto”) is added to rebase--helper.c. The shell
    version is then stripped.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5. rebase -i: rewrite setup_reflog_action() in C

    agrn authored and gitster committed Aug 10, 2018
    This rewrites (the misnamed) setup_reflog_action() from shell to C. The
    new version is called prepare_branch_to_be_rebased().
    
    A new command is added to rebase--helper.c, “checkout-base”, as well as
    a new flag, “verbose”, to avoid silencing the output of the checkout
    operation called by checkout_base_commit().
    
    The function `run_git_checkout()` will also be used in the next commit,
    therefore its code is not part of `checkout_base_commit()`.
    
    The shell version is then stripped in favour of a call to the helper.
    
    As $GIT_REFLOG_ACTION is no longer set at the first call of
    checkout_onto(), a call to comment_for_reflog() is added at the
    beginning of this function.
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6. sequencer: add a new function to silence a command, except if it fails

    agrn authored and gitster committed Aug 10, 2018
    This adds a new function, run_command_silent_on_success(), to
    redirect the stdout and stderr of a command to a strbuf, and then to run
    that command. This strbuf is printed only if the command fails. It is
    functionnaly similar to output() from git-rebase.sh.
    
    run_git_commit() is then refactored to use of
    run_command_silent_on_success().
    
    Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Older
You can’t perform that action at this time.