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

Merge behavior with merge.conflictStyle diff3

From
AJAdilson de Almeida Junior <adilson.smem@gmail.com>
Date
Dec 18, 2018, 17:34 UTC
Message-ID
<CAKmxmfosaExDYNyoaNg2teHMzsu3JJ3bqiLhrAaUt0Jt473Phw@mail.gmail.com>
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

Next: Jeff King
Message 1 of 2 in “Merge behavior with merge.conflictStyle diff3”
  1. Adilson de Almeida JuniorDec 18, 2018
  2. Jeff KingDec 18, 2018

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.