Skip to content
  • Phillip Wood's avatar
    sequencer: do not squash 'reword' commits when we hit conflicts · a9279c67
    Phillip Wood authored and Junio C Hamano's avatar Junio C Hamano committed
    Ever since commit 18633e1a ("rebase -i: use the rebase--helper builtin",
    2017-02-09), when a commit marked as 'reword' in an interactive rebase
    has conflicts and fails to apply, when the rebase is resumed that commit
    will be squashed into its parent with its commit message taken.
    
    The issue can be understood better by looking at commit 56dc3ab0
    ("sequencer (rebase -i): implement the 'edit' command", 2017-01-02), which
    introduced error_with_patch() for the edit command.  For the edit command,
    it needs to stop the rebase whether or not the patch applies cleanly.  If
    the patch does apply cleanly, then when it resumes it knows it needs to
    amend all changes into the previous commit.  If it does not apply cleanly,
    then the changes should not be amended.  Thus, it passes !res (success of
    applying the 'edit' commit) to error_with_patch() for the to_amend flag.
    
    The problematic line of code actually came from commit 04efc8b5
    
    
    ("sequencer (rebase -i): implement the 'reword' command", 2017-01-02).
    Note that to get to this point in the code:
      * !!res (i.e. patch application failed)
      * item->command < TODO_SQUASH
      * item->command != TODO_EDIT
      * !is_fixup(item->command) [i.e. not squash or fixup]
    So that means this can only be a failed patch application that is either a
    pick, revert, or reword.  We only need to amend HEAD when rewording the
    root commit or a commit that has been fast-forwarded, for any of the other
    cases we want a new commit, so we should not set the to_amend flag.
    
    Helped-by: default avatarJohannes Schindelin <Johannes.Schindelin@gmx.de>
    Original-patch-by: default avatarElijah Newren <newren@gmail.com>
    Signed-off-by: default avatarPhillip Wood <phillip.wood@dunelm.org.uk>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    a9279c67