]> git.ipfire.org Git - thirdparty/git.git/commit
sequencer: factor out part of pick_commits()
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Wed, 6 Sep 2023 15:22:48 +0000 (15:22 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Sep 2023 17:29:43 +0000 (10:29 -0700)
commitf2b5f41eda52416d29fade2f823d3b5bd7aa2205
tree3fc2dfbf6730e6c367cd88c2f349c108849d7c9e
parent9f67899b41e5a95ce31af38c6b6d600433546d9e
sequencer: factor out part of pick_commits()

This simplifies the next commit. If a pick fails we now return the error
at the end of the loop body rather than returning early, a successful
"edit" command continues to return early. There are three things to
check to ensure that removing the early return for an error does not
change the behavior of the code:

(1) We could enter the block guarded by "if (reschedule)". This block
    is not entered because "reschedlue" is always zero when picking a
    commit.

(2) We could enter the block guarded by
    "else if (is_rebase_i(opts) &&  check_todo && !res)". This block is
    not entered when returning an error because "res" is non-zero in
    that case.

(3) todo_list->current could be incremented before returning. That is
    avoided by moving the increment which is of course a potential
    change in behavior itself. The move is safe because none of the
    callers look at todo_list after this function returns. Moving the
    increment makes it clear we only want to advance the current item
    if the command was successful.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c