threads / discuss / 30114

rebase -p loses amended changes

Subject: rebase -p loses amended changes

## tl;dr

2 messages between Mar 30, 2012 and Mar 30, 2012.

replies: 1people: 2as markdown or json

J Robert Ray· Mar 30, 2012, 21:31 UTC · lore

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· Mar 30, 2012, 22:49 UTC · re: J Robert Ray · lore

Re: rebase -p loses amended changes

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

← back to recent threads