git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* conflict markers on recursive strategy with diff3 enabled
@ 2019-10-25  0:13 Edmundo Carmona Antoranz
  2019-10-28 21:58 ` Elijah Newren
  2019-10-28 22:13 ` Philip Oakley
  0 siblings, 2 replies; 4+ messages in thread
From: Edmundo Carmona Antoranz @ 2019-10-25  0:13 UTC (permalink / raw)
  To: Git List

Hi!

I'm sitting down hunting for conflict examples and while looking
through past conflicts in git I found one that has a format that I
hadn't seen before. When merging the parents of 8b79343fc0 we get
this:

<<<<<<< HEAD

/*
* Unlink the .pack and associated extension files.
* Does not unlink if 'force_delete' is false and the pack-file is
* marked as ".keep".
*/
extern void unlink_pack_path(const char *pack_name, int force_delete);
||||||| merged common ancestors
>>>>>>>>> Temporary merge branch 2
=======
>>>>>>> 8b79343fc0^2

That is with merge.conflictStyle set to diff3. What I would like to
know is if the details about how the additional information that is
not normally seen on a conflict has to be interpreted (to be read as
"the part about the temporary branches"). I see some explanation about
it in [1] but when checking inside "git help merge" all I see is that
when you are using diff3 you will get the content of the parent but
there's more stuff than just that. Is it documented somewhere?

Thanks!

[1]https://stackoverflow.com/questions/31392513/git-diff3-conflict-style-temporary-merge-branch

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: conflict markers on recursive strategy with diff3 enabled
  2019-10-25  0:13 conflict markers on recursive strategy with diff3 enabled Edmundo Carmona Antoranz
@ 2019-10-28 21:58 ` Elijah Newren
  2019-10-28 22:13 ` Philip Oakley
  1 sibling, 0 replies; 4+ messages in thread
From: Elijah Newren @ 2019-10-28 21:58 UTC (permalink / raw)
  To: Edmundo Carmona Antoranz; +Cc: Git List

Hi Edmundo,

On Fri, Oct 25, 2019 at 12:19 PM Edmundo Carmona Antoranz
<eantoranz@gmail.com> wrote:
>
> Hi!
>
> I'm sitting down hunting for conflict examples and while looking
> through past conflicts in git I found one that has a format that I
> hadn't seen before. When merging the parents of 8b79343fc0 we get
> this:
>
> <<<<<<< HEAD
>
> /*
> * Unlink the .pack and associated extension files.
> * Does not unlink if 'force_delete' is false and the pack-file is
> * marked as ".keep".
> */
> extern void unlink_pack_path(const char *pack_name, int force_delete);
> ||||||| merged common ancestors
> >>>>>>>>> Temporary merge branch 2
> =======
> >>>>>>> 8b79343fc0^2
>
> That is with merge.conflictStyle set to diff3. What I would like to
> know is if the details about how the additional information that is
> not normally seen on a conflict has to be interpreted (to be read as
> "the part about the temporary branches"). I see some explanation about
> it in [1] but when checking inside "git help merge" all I see is that
> when you are using diff3 you will get the content of the parent but
> there's more stuff than just that. Is it documented somewhere?

The "||||||| merged common ancestors" section shows the content of the
merge base, which itself contained conflict markers.

The way the merge base can itself have conflict markers is as follows:
when you go to merge your two branches, git finds that there isn't a
unique merge base for doing the three-way merge.  You, in fact, have
more than one merge base.  And so, it first merges those (and if those
don't have a unique merge base, then their merge bases must first be
merged...and so on -- thus the name of "recursive" for the merge
algorithm).  When the algorithm runs into conflicts while merging the
merge bases, it simply accepts the version of the file with the
conflict markers as the correct resolution (because it has to pick
something, and that is unlikely to erroneously match the outer
contents on either side).

Thus when using diff3 conflict style, you can sometimes see nested
conflict markers.  And technically you can construct weird histories
where you have arbitrarily deeply nested conflict markers as well, but
it certainly isn't very common.


Hope that helps,
Elijah

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: conflict markers on recursive strategy with diff3 enabled
  2019-10-25  0:13 conflict markers on recursive strategy with diff3 enabled Edmundo Carmona Antoranz
  2019-10-28 21:58 ` Elijah Newren
@ 2019-10-28 22:13 ` Philip Oakley
  2019-10-29  1:31   ` Junio C Hamano
  1 sibling, 1 reply; 4+ messages in thread
From: Philip Oakley @ 2019-10-28 22:13 UTC (permalink / raw)
  To: Edmundo Carmona Antoranz, Git List

Hi Edmundo ,

On 25/10/2019 01:13, Edmundo Carmona Antoranz wrote:
> Hi!
>
> I'm sitting down hunting for conflict examples and while looking
> through past conflicts in git I found one that has a format that I
> hadn't seen before. When merging the parents of 8b79343fc0 we get
> this:
>
> <<<<<<< HEAD
>
> /*
> * Unlink the .pack and associated extension files.
> * Does not unlink if 'force_delete' is false and the pack-file is
> * marked as ".keep".
> */
> extern void unlink_pack_path(const char *pack_name, int force_delete);
> ||||||| merged common ancestors
>>>>>>>>>> Temporary merge branch 2
> =======
>>>>>>>> 8b79343fc0^2
> That is with merge.conflictStyle set to diff3. What I would like to
> know is if the details about how the additional information that is
> not normally seen on a conflict has to be interpreted (to be read as
> "the part about the temporary branches").
- "Temporary merge branch"

I believe this happens when no merge-base is found between the two lines 
of development that are being merged, so a fake merge-base is created to 
allow the regular 3-way merge to occur.

It may be described in the technical section of the Documentation.

>   I see some explanation about
> it in [1] but when checking inside "git help merge" all I see is that
> when you are using diff3 you will get the content of the parent but
> there's more stuff than just that. Is it documented somewhere?
>
> Thanks!
>
> [1]https://stackoverflow.com/questions/31392513/git-diff3-conflict-style-temporary-merge-branch

Philip

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: conflict markers on recursive strategy with diff3 enabled
  2019-10-28 22:13 ` Philip Oakley
@ 2019-10-29  1:31   ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2019-10-29  1:31 UTC (permalink / raw)
  To: Philip Oakley; +Cc: Edmundo Carmona Antoranz, Git List

Philip Oakley <philipoakley@iee.email> writes:

> I believe this happens when no merge-base is found between the two
> lines of development that are being merged, so a fake merge-base is
> created to allow the regular 3-way merge to occur.

s/no merge-base is/more than one merge-base are/; then a synthetic
merge base is computed in order to perform the merge the end-user
requested first, and the computation of that synthetic merge base
may involve merge conflicts.  After that, the merge logic pretends
that the two versions being merged both derived from such a common
ancestor version _with_ conflict markers in it, and may conflict
with each other around that existing (inner) conflict markers to
leave a rather messy result.  It is particularly bad when both
branches did the same thing only on one side the inner merge
conflicted but not on the other side---one side of inner conflict
marker (say "<<<<<<<<") may disappear when the merged branches made
the same change (so "both side changed identically, resolve to their
same result" 3-way merge rule would apply) and around that area the
result will not have the conflict marker from the inner merge, and
the other side will say "one side made into this shape, the other
side made into that shape, from this common ancestor version" in the
diff3 format, which would mean that we would see conflict marker
lines from the inner merge between "|||||" and "=====" lines in the
outer merge (i.e. the common ancestor version).  The conflict
markers of the inner merge are longer than those of the outermost
merge, so you could sift them by careful eyeballing, but it is
rather hard to read.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-29  1:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25  0:13 conflict markers on recursive strategy with diff3 enabled Edmundo Carmona Antoranz
2019-10-28 21:58 ` Elijah Newren
2019-10-28 22:13 ` Philip Oakley
2019-10-29  1:31   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).