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

Re: question about a merge result

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Apr 30, 2009, 15:39 UTC
Message-ID
<20090430153917.GB18940@atjola.homenet>
In-Reply-To
<38b2ab8a0904300805j5ce19617mdda3254c37d06d38@mail.gmail.com>
On 2009.04.30 17:05:19 +0200, Francis Moreau wrote:
Show 27 quoted lines
> On Thu, Apr 30, 2009 at 4:26 PM, Jeff King <peff@peff.net> wrote:
> > On Thu, Apr 30, 2009 at 02:34:43PM +0200, Michael Gaber wrote:
> >
> >> > So merging 'b1' into master removed the B file even if in branch 'b1'
> >> > I restored it.
> >> >
> >> > Could anybody explain me why this is the correct behaviour and why not
> >> > file 'B' is not restored as it was done in branch 'b1' ?
> >>
> >> well, I'd say the thing is, that in b1 there is no change at all to the
> >> tree anymore, so when applied to master (without B) there is no b restored
> >
> > That is exactly it. Git's 3-way merge doesn't look at the intervening
> > history at all. It looks _only_ at the two endpoints and their
> > merge-base (well, that is a bit of a simplification, as there may be
> > multiple merge-bases, but it is what is happening here).
> >
> 
> Well, obviously it's how git works since it's what I got.
> 
> But the question was more about if the cortectness of the end result:
> should 'B' removed after the merge.
> 
> IOW if someone works on its own branch remove B file and thought it
> was a bad idea and restore it whereas another person remove B file but
> miss the fact that it was a bad idea, does the merge should silently
> remove B file ?

You can also have that in the opposite direction. You make a bugfix in your "master" branch, then cherry-pick that to "maint", but later realize that you actually can't backport it like and and revert the cherry-pick. Then, later, you go to merge "maint" to "master" (to get other bugfixes that were done directly on "maint"): Should the bugfix be reverted on "master"? Obviously not.

git takes an approach that's easy to understand: Look at the changes that the branch made compared to the common ancestor and apply those. And for a "do it and then revert it" case, the answer is: There are no changes.

Björn
Previous: Francis MoreauNext: Jeff King
Message 5 of 7 in “question about a merge result”
  1. Francis MoreauApr 30, 2009
  2. Michael GaberApr 30, 2009
  3. Jeff KingApr 30, 2009
  4. Francis MoreauApr 30, 2009
  5. Björn SteinbrinkApr 30, 2009
  6. Jeff KingApr 30, 2009
  7. Daniel BarkalowMay 1, 2009

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.