# rebase -p loses amended changes

2 messages from 2012-03-30 to 2012-03-30. Participants: J Robert Ray, Thomas Rast.
Thread: https://gitlist.dev/t/30114

## J Robert Ray, 2012-03-30 21:31

Subject: rebase -p loses amended changes
Message-ID: <CADb3U=4DNt7Jnzq4eW-K+W1_sEfMgL6MxqY6qmPaJZagiFdmmg@mail.gmail.com>
URL: https://gitlist.dev/e/CADb3U%3D4DNt7Jnzq4eW-K%2BW1_sEfMgL6MxqY6qmPaJZagiFdmmg%40mail.gmail.com

```
I've found that 'rebase -p' can discard changes from a merge commit
when it recreates the merge.

If a merge is amended to add changes to a file unaffected by the
merge, these changes are lost after a rebase. Attached is a script to
demonstrate the problem.

I've tested the script against git 1.7.9.5.

I'll outline the steps starting from an empty repo.

1. Create a file (a) with some contents, then create three branches
from this point, "mod-a," "mod-b," and "master-copy."

2. In "mod-a," modify a.

3. In "mod-b," create a different file (b).

4. Merge (--no-ff) "mod-a" onto master.

5. Amend the merge with a modification to a.

6. Merge (--no-ff) "mod-b" onto "master-copy."

7. Rebase -p master onto "master-copy."

Notice the change to "a" from step #5 is now gone. "a" reverts to the
pre-amended version after step #4.

I assume this isn't expected behavior and is a bug.

```

## Thomas Rast, 2012-03-30 22:49

Subject: Re: rebase -p loses amended changes
Message-ID: <87ty15vh4c.fsf@thomas.inf.ethz.ch>
URL: https://gitlist.dev/e/87ty15vh4c.fsf%40thomas.inf.ethz.ch
In-Reply-To: <CADb3U=4DNt7Jnzq4eW-K+W1_sEfMgL6MxqY6qmPaJZagiFdmmg@mail.gmail.com>

```
J Robert Ray <jrobertray@gmail.com> writes:

> If a merge is amended to add changes to a file unaffected by the
> merge, these changes are lost after a rebase. Attached is a script to
> demonstrate the problem.

> 4. Merge (--no-ff) "mod-a" onto master.
>
> 5. Amend the merge with a modification to a.

> 7. Rebase -p master onto "master-copy."
>
> Notice the change to "a" from step #5 is now gone. "a" reverts to the
> pre-amended version after step #4.

That's pretty much expected. rebase -p attempts to (conflicts will
happen again) replay the merge.  I don't think anybody's come up with a
clear idea of how to apply the conflicted or evil parts of the merge
mechanically.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

```
