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.