Re: surprising behavior from merge
From: Michael Witten <hidden>
Date: 2016-06-15 22:53:49
On Fri, 11 May 2012 16:25:29 -0600, Sebastian Kuzminsky wrote:
Hi folks, I just ran in to a strange behavior with git merge. Things start out with two branches (let's call them 'master' and 'other') pointing at a particular commit. In master I commit a small one-line change, then make a second commit that adds some stuff just after the line changed in the previous commit. In the other branch, i cherry-pick the second commit from master (the one that adds the new stuff). The cherry-pick succeeds, despite the fuzzy context. So far, so good. Next I try to merge other into master. I expected it to notice there was nothing to do and leave the master tree unchanged, but it applied the "add new stuff" patch to master (even though that patch is already in master) and made a commit from that. So it silently did the wrong thing, and now the file contains two copies of stuff I added. That is a simplified version of what happened, in my real repo there were several (unrelated and unimportant) commits on both master and the other branch. When the surprising double-add happened, i simplified the repo to remove distractions. The simplified repo is here if anyone wants to inspect it: https://github.com/SebKuzminsky/merge-problem
It would obviously be helpful to supply:
* Explicit commands that anyone on the list can try and discuss.
For example:
git init repo
cd repo
echo a > a; git add a; git commit -m 'small one-line change'
echo b >> a; git commit -am 'adds some stuff after'
...
* Expected behavior from those commands.
* Actual behavior from those commands.
In other words, rather than burdening people with the task of
constructing a mental picture of what you have done, you should
show them as directly and precisely as possible; in this way,
people can go about the business of discussing your issue much
more quickly and, most importantly, PRECISELY.
Sincerely,
Michael Witten