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

Re: git merge strange result

From
Jeff King <peff@peff.net>
Date
Dec 1, 2011, 18:50 UTC
Message-ID
<20111201185032.GA2873@sigill.intra.peff.net>
In-Reply-To
<alpine.LFD.2.02.1112011733070.32682@mail.embedromix.ro>
On Thu, Dec 01, 2011 at 05:36:00PM +0200, Catalin(ux) M. BOIE wrote:
> Below is a script that reproduce what a coleague of mine found.
> Seems that if in a branch we have a commit that is cherry-picked be
> master, than revert that commit in branch and merge branch in master,
> the revert is ignored. Is it normal?

Yes, it's by design. When doing a merge, we look at three points: the tip of the current branch, the tip of the branch to be merged, and the point at which history diverged (the "merge base"). We don't look individually at the commits that happened between the merge base and each tip.

The non-conflicting case for a 3-way merge is that one side makes some change, but the other side does nothing. In this case, we include the change in the merge result. But remember that we are only looking at endpoints. So what the actual merge code sees is that one side's version of a file is identical to the merge base's version, and that the other side's version is now different.

In your case, one side makes the change, but then restores the original state. So from the perspective of the merge code, no change happened at all on that side.

-Peff
Previous: Catalin(ux) M. BOIE
Message 2 of 2 in “git merge strange result”
  1. Catalin(ux) M. BOIEDec 1, 2011
  2. Jeff KingDec 1, 2011

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.