[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git
Subject:    Re: question about a merge result
From:       Jeff King <peff () peff ! net>
Date:       2009-04-30 15:42:40
Message-ID: 20090430154240.GA27416 () coredump ! intra ! peff ! net
[Download RAW message or body]

On Thu, Apr 30, 2009 at 05:05:19PM +0200, Francis Moreau wrote:

> Well, obviously it's how git works since it's what I got.

Yes, I meant also "this is what it is supposed to do, by design".

> 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 ?

Yes, it should be removed. And it has nothing to do with removal. Both
branches performed some action, but only one reverted it. Thus you still
have one branch wanting to make the change, and the other side leaving
it alone (in aggregate). So we want to take the changed side.

The only other thing that might make sense would be a conflict (because
both sides touched the same area and ended with different results). Git
doesn't try to find such a conflict because:

  1. Fundamentally, git cares about endpoints, not changelogs. So by
     design, you can arrive at the same tree state by many different
     routes and the merge will still happen in the same way.

  2. Finding such a conflict in the general case would be quite
     expensive, because you have to track every bit of content changed
     on one branch through every commit on the other branch, to see if
     they ever overlap.

If you want the result of the merge to keep it, you should do one of:

  - revert the removal in _both_ branches

  - merge with "--no-commit", add it back in, and then commit. The
    resulting commit will be a merge commit with the state you specify.

  - merge the early part of one branch, with the removal, into the other
    branch. Then "removed" becomes your basis for comparison, and then
    when you re-merge, the branch that re-adds it will be the only
    change.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic