I'm trying to do union merge to a file which contains simple javascript objects. However, I noticed that git merge seems to be "combining" multiple merge conflicts into a single merge conflict if it results into same or lower amount of rows. This basically ruins the possibility for auto-merging with merge=union.
I have a file with the following content:
1: {
main: '1',
},
2: {
main: '2',
},
3: {
main: '3',
},
Lets imagine two branches, which both add content to the end of each object, for example:
1: {
main: '1',
branch1: 'x',
},
2: {
main: '2',
branch1: 'y',
},
3: {
main: '3',
branch1: 'z',
},
If we merge these branches, it produces following merge conflict:
1: {
main: '1',
<<<<<<< HEAD
branch1: 'x',
},
2: {
main: '2',
branch1: 'y',
},
3: {
main: '3',
branch1: 'z',
=======
branch2: 'q',
},
2: {
main: '2',
branch2: 'w',
},
3: {
main: '3',
branch2: 'e',
>>>>>>> branch2
},
while I would expect to see something like this:
1: {
main: '1',
<<<<<<< HEAD
branch1: 'x',
=======
branch2: 'q',
>>>>>>> branch2
},
2: {
main: '2',
<<<<<<< HEAD
branch1: 'y',
=======
branch2: 'w',
>>>>>>> branch2
},
3: {
main: '3',
<<<<<<< HEAD
branch1: 'z',
=======
branch2: 'e',
>>>>>>> branch2
},
Diff shows correctly the lines which have been changed between branches, and a workaround would be to add blank lines between the values. Why git decides to combine those merge conflicts into one bigger merge conflict, while git clearly knows that the lines between each object are not changed? Is it possible to turn that feature off, without writing complicated merge adapter?