git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: ch <cr@onlinehome.de>
To: git@vger.kernel.org
Subject: [BUG] git-rebase: reword squashes commits in case of merge-conflicts
Date: Mon, 11 Jun 2018 18:06:11 +0200	[thread overview]
Message-ID: <8e28202a-8646-53e8-8c22-389d61791c70@onlinehome.de> (raw)

Hi all!

During a recent rebase operation on one of my repositories a number of commits
unexpectedly ended up getting squashed into other commits. After some
experiments it turned out that the 'reword' instruction seems to squash the
referenced commit into the preceding commit if there's a merge-conflict.

Here's a small reproduction recipe to illustrate the behavior:

   1. Create a small test repository using the following Bash script:

----
function add_file()
{
     echo "$1" > "$2"
     git add "$2"
     git commit -m "$3"
}

git init .

add_file "test" "file-1" "master"

git checkout -b stuff

add_file "aaa" "file-2" "feature_a"
add_file "bbb" "file-2" "fixup! feature_a"
add_file "ccc" "file-2" "fixup! feature_a"

add_file "ddd" "file-2" "feature_b"
add_file "eee" "file-2" "fixup! feature_b"
add_file "fff" "file-2" "fixup! feature_b"
----

   2. Run

        $ git rebase --autosquash --interactive --onto master master stuff

      to interactively rebase 'stuff' onto 'master'. This should generate the
      following todo-stream:

----
pick ... feature_a
fixup ... fixup! feature_a
fixup <hash_1> fixup! feature_a
pick <hash_2> feature_b
fixup ... fixup! feature_b
fixup ... fixup! feature_b
----

   3. Remove the fixup line right before the second pick (i.e. 'fixup <hash_1>')
      in order to enforce a merge-conflict later when applying commit <hash_2>.

   4. Replace the second pick instruction (i.e. 'pick <hash_2>') with a reword.

   5. Launch the rebase operation. It should fail at the 'reword <hash_2>'
      instruction due to a merge-conflict.

   6. Resolve the conflict by taking the remote-side (i.e. 'ddd'), add the
      change to the index with git-add and run

        $ git rebase --continue

      This should spawn the commit message editor and after saving and quitting
      the rebase should finish cleanly.

After the rebase the 'stuff' branch only has a single commit even though I'd
expect there to be two according to the instructions that were passed to
git-rebase. It works as expected if there's either no merge-conflict at the
reword or if the conflicting commit is applied as 'pick'.

I'm running git version 2.17.1.windows.2. I also tried native git version 2.7.4
via WSL (running Ubuntu 16.04.4 LTS) and this version does not exhibit this
behavior.

- ch

             reply	other threads:[~2018-06-11 16:05 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-11 16:06 ch [this message]
2018-06-12 10:08 ` [BUG] git-rebase: reword squashes commits in case of merge-conflicts Jeff King
2018-06-15 14:35   ` ch
2018-06-16 16:08 ` Elijah Newren
2018-06-17  3:36   ` Eric Sunshine
2018-06-17  5:37     ` [PATCH v2] sequencer: do not squash 'reword' commits when we hit conflicts Elijah Newren
2018-06-17 15:04       ` Phillip Wood
2018-06-17 19:28         ` Johannes Schindelin
2018-06-18 10:20           ` Phillip Wood
2018-06-18 15:42             ` Junio C Hamano
2018-06-18 21:42             ` Johannes Schindelin
2018-06-19 10:00               ` [PATCH v2] sequencer: do not squash 'reword' commits when wehit conflicts Phillip Wood
2018-06-19 12:46               ` [PATCH v3] sequencer: do not squash 'reword' commits when we hit conflicts Phillip Wood
2018-06-19 14:29                 ` Elijah Newren
2018-06-19 16:59                   ` Junio C Hamano
2018-08-23 10:09                 ` [PATCH] t/lib-rebase.sh: support explicit 'pick' commands in 'fake_editor.sh' SZEDER Gábor
2018-08-23 16:20                   ` Junio C Hamano
2018-08-23 20:53                   ` Johannes Schindelin
2018-06-17 18:46       ` [PATCH v2] sequencer: do not squash 'reword' commits when we hit conflicts Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e28202a-8646-53e8-8c22-389d61791c70@onlinehome.de \
    --to=cr@onlinehome.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).