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

Re: unexpected git-merge result

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 19, 2010, 22:27 UTC
Message-ID
<7vaav4amjj.fsf@alter.siamese.dyndns.org>
In-Reply-To
<loom.20100219T202452-35@post.gmane.org>
Dale Rowley <ddrowley3@juno.com> writes:
Show 15 quoted lines
> Our branch history looked something like the following:
>
>   B---C
>  /     \
> A---D---E---H
>      \     /
>       F---G
>
> In commit D a few lines were added to a file, and then in commit G the same
> lines were removed. When branches E and G were merged, those lines unexpectedly
> re-appeared in the merge commit (H), even though no other commits had touched
> that file.
>
> I think I understand why this happened: git-merge-base reports that the
> common ancestor for E and G is A.
Do you?  I don't.

D is the merge base between E and G. A and D are both common ancestor between E and G, but because D is a descendant of A, A is not a merge base (the definition of merge-base is "common ancestors none of whose children is common ancestor"). A is not.

Are you sure you really have ancestry relationship between D and G? If the history were like this:

   B---C
  /     \
 A---D---E---H
  \         /
   F-------G

and both D and F add the same set of "few lines", and G removes it, then I can understand how you would get these "removed by G" lines appear in H, as the side branch F--G didn't have no net effect on these lines and D is the only one that added them.

It can happen if F is a cherry-pick of D and G is a revert of F, for example.

Previous: Dale RowleyNext: Dale Rowley
Message 2 of 5 in “unexpected git-merge result”
  1. Dale RowleyFeb 19, 2010
  2. Junio C HamanoFeb 19, 2010
  3. Dale RowleyFeb 20, 2010
  4. Dmitry PotapovFeb 22, 2010
  5. Dale RowleyFeb 22, 2010

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.