On Thu, Feb 9, 2017 at 11:58 AM, Stephen Morton <stephen.c.mor...@gmail.com>
wrote:

>  Thu, Feb 9, 2017 at 11:53 AM, Stephen Morton <stephen.c.mor...@gmail.com>
> wrote:
>
>>
>>
>> On Thu, Feb 9, 2017 at 10:48 AM, Igor Djordjevic <
>> igor.d.djordje...@gmail.com> wrote:
>>
>>> On Thursday, February 9, 2017 at 3:47:09 PM UTC+1, Stephen Morton wrote:
>>>>
>>>> On Thu, Feb 9, 2017 at 9:16 AM, Igor Djordjevic <igor.d.d...@gmail.com>
>>>> wrote:
>>>>
>>>>> For example, single (resolved) merge commit (M):
>>>>>
>>>>> 1) A---B---C---D branchA
>>>>>     \       \
>>>>>      V---W---*M*---E branchB
>>>>>
>>>>> ... and conflicting merge commit (M) with multiple merge resolution
>>>>> commits (X, Y and Z):
>>>>>
>>>>> 2) A---B---C---D branchA
>>>>>     \       \
>>>>>      V---W---*M*---*X*---*Y*---*Z*---E branchB
>>>>>
>>>>> Commits D and E are new commits on the two branches, representing the
>>>>> same code state/content in both cases. Commit Z in case (2) has the same
>>>>> code state/content as (squash) commit M in case (1).
>>>>>
>>>>>
>>>> I think that after the situation in 2), if you do a  `git checkout
>>>> branchA ; git merge branchB`, it will try to merge X,Y,Z,E when you only
>>>> want it to merge E. You might say "but they'll be no-ops because they're
>>>> already in A", but this is just not necessarily true.
>>>>
>>>
>>> I think you`re wrong here, here`s what the git-merge[1] documentation
>>> states (emphasis mine, pay attention to that part):
>>>
>>> "With the strategies that use 3-way merge (including the default,
>>> recursive), if a change is made on both branches, but later reverted on one
>>> of the branches, that change will be present in the merged result; some
>>> people find this behavior confusing. It occurs because **only the heads
>>> and the merge base are considered when performing a merge, not the
>>> individual commits**. The merge algorithm therefore considers the
>>> reverted change as no change at all, and substitutes the changed version
>>> instead."
>>>
>>> So in both case (1) and (2) above, all that subsequent merge with 'git
>>> checkout branchA; git merge branchB' considers/sees are branch head
>>> commits D and E, and common base commit C -- only these three, and they`re
>>> the same in both cases, thus the merge result is the same, no matter the
>>> different individual commits in between.
>>>
>>
>> *(Oops, hit [send] to early.)*
>
> *No.*
>
> Think about what the files in the repo looks like at state M and what
> commits X,Y,Z look like. M has lots of *committed conflict markers in it*.
> Commit X will 100% definitely involve removing committed conflict markers
> (and probably removing one of the "ours" or "theirs" sections). Commit X
> might also involve code refactoring.  So `git diff M E` that you are
> applying to A will also 100% definitely involve removing a bunch of
> conflict markers. This is independent of considering each of the individual
> commits, to specifically address the point above. What happens if you try
> to apply that diff to branchA? Chaos is what happens, on the scale of
> hundreds of files, and that's what I'm talking about.
>
> I had tried to avoid just this kind of wild goose chase with various
> disclaimers in my question. Apparently not. I appreciate that in you think
> you are trying to help. But you are not. Perhaps after this email you will
> finally get your "aha moment" and finally get to the point of understanding
> where I was when I first wrote my first post, I do not know. But I am not
> going to reply further.
>
> Steve
>

Igor is right and I am wrong.

I tried a Minimal, Complete, and Verifiable example and discovered that
indeed git "does the right thing" with respect to merge tracking.

That is interesting because it means the whole premise for my question and
concern was not correct. You can indeed just commit the merge conflicts and
resolve them later in separate commits and everything will be ok. It's not
pretty and there are probably many reasons not to do it, but if you have to
it won't further mess up your future.

I guess where I got confused was that, in my diagram above, I was not
taking into account the changes introduced by the merge commit. I was
imagining that a final 'git merge branchB' would merge 'git diff M E' into
branch A rather than actually it would merge 'git diff C E' which will
indeed produce the correct result. (This is probably an oversimplification,
but you get the general idea.)



Stephen

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to