git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Merge behavior with merge.conflictStyle diff3
@ 2018-12-18 17:34 Adilson de Almeida Junior
  2018-12-18 18:01 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: Adilson de Almeida Junior @ 2018-12-18 17:34 UTC (permalink / raw)
  To: git

Hi,

I´m not sure if this is a bug or not.

These are the steps to reproduce it (git 2.17 at least):
- In a repo, with default settings (merge strategy, conflict style,
merge drivers, etc);
- Create a file 'test.xml', and add the following content to it:

[div]
  A
[/div]

- Perform a git add and git commit, then, create a branch named branch1;
- Next, on branch1, edit the xml file and add a new div:

[div]
  A
[/div]
[div]
  B
[/div]

- Then, comit the changes, and after that return to branch master;
- So, perform a similar but slightly different change:

[div]
  A
[/div]
[div]
  C
[/div]

- Then commit it;
- Now, do a merge (git merge branch1);

When my conflictStyle is default (merge), the merged file becames:
[div]
[[[[[[[ HEAD
  C
=======
  B
]]]]]]] branch1
[/div]

But when the merge.conflictStyle is set to diff3, I get:
[[[[[[[ HEAD
[div]
  C
[/div]
||||||| merged common ancestors
=======
[div]
  B
[/div]
]]]]]]] branch1

I guess, most times the second behavior is the expected: two conflict
hunks, not only the divvergent pieces (this case, the second line) of
them. By the doc:

merge.conflictStyle

    Specify the style in which conflicted hunks are written out to
working tree files upon merge. The default is "merge", which shows a
[[[[[[[ conflict marker, changes made by one side, a ======= marker,
changes made by the other side, and then a ]]]]]]] marker. An
alternate style, "diff3", adds a ||||||| marker and the original text
before the ======= marker.

I replaced the 'lower than' and 'greater than' symbols by 'open n
close square brackets' to avoid antivirus.

Is this a bug, or something I missunderstood from git docs?

Thanks,
Adilson de Almeida Jr

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

* Re: Merge behavior with merge.conflictStyle diff3
  2018-12-18 17:34 Merge behavior with merge.conflictStyle diff3 Adilson de Almeida Junior
@ 2018-12-18 18:01 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2018-12-18 18:01 UTC (permalink / raw)
  To: Adilson de Almeida Junior; +Cc: git

On Tue, Dec 18, 2018 at 03:34:20PM -0200, Adilson de Almeida Junior wrote:

> I guess, most times the second behavior is the expected: two conflict
> hunks, not only the divvergent pieces (this case, the second line) of
> them. By the doc:
> 
> merge.conflictStyle
> 
>     Specify the style in which conflicted hunks are written out to
> working tree files upon merge. The default is "merge", which shows a
> [[[[[[[ conflict marker, changes made by one side, a ======= marker,
> changes made by the other side, and then a ]]]]]]] marker. An
> alternate style, "diff3", adds a ||||||| marker and the original text
> before the ======= marker.
> 
> I replaced the 'lower than' and 'greater than' symbols by 'open n
> close square brackets' to avoid antivirus.
> 
> Is this a bug, or something I missunderstood from git docs?

This is the expected behavior. There's some philosophical discussion
about the correct thing to do here in this thread (that message and its
replies, but the whole thread is an interesting read):

  https://public-inbox.org/git/7vvc94p8hb.fsf@alter.siamese.dyndns.org/

Note that there is a patch in that thread to implement "zdiff3", which
does what you want. I've been rebasing it and running with it for
several years now. You can get my rebased version by fetching:

  https://github.com/peff/git ukk/zdiff3

But note that I think it may have a subtle bug, as I have once or twice
over the years seen it cause a segfault.

-Peff

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

end of thread, other threads:[~2018-12-18 18:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-18 17:34 Merge behavior with merge.conflictStyle diff3 Adilson de Almeida Junior
2018-12-18 18:01 ` Jeff King

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).