git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: surprising behavior from merge

From
Michael Witten <mfwitten@gmail.com>
Date
May 11, 2012, 23:44 UTC
Message-ID
<ae419d8bbc2b44bfa4c0a7eb421f5037-mfwitten@gmail.com>
In-Reply-To
<9A9AD20F-B316-4DC1-8C6A-E0FC6ED80A61@highlab.com>
On Fri, 11 May 2012 16:25:29 -0600, Sebastian Kuzminsky wrote:
Show 23 quoted lines
> 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

Previous: Sebastian KuzminskyNext: Sebastian Kuzminsky
Message 2 of 5 in “surprising behavior from merge”
  1. Sebastian KuzminskyMay 11, 2012
  2. Michael WittenMay 11, 2012
  3. Sebastian KuzminskyMay 12, 2012
  4. Illia BobyrMay 12, 2012
  5. Sebastian KuzminskyMay 14, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.