You are not logged in.

#1 2018-06-15 10:58:36

catnap
Member
Registered: 2016-10-03
Posts: 131

[WORKAROUND] Best way to help Git's merge tool to order text

After moving from Bazaar to Git, I have been happily versioning most of my code and other text files with Git and merging conflicts with Git's native merge tool combined with VimDiff. There is no technical problem in merging because the programs that I use do their task excellently. I would only want to know if there are some merging best practices that I could use because I sometimes get confused about where to place a segment of text if the file has been heavily edited before merging.

For example, in Branch 1 I could have something like this:

Topic 1:
There's a note here.

When I clone this to Branch 2 elsewhere, I could do several additions:

Topic 1:
There's a note here.
Topic 2:
Some remarks go here.
Topic 3:
Maybe those remarks were inappropriate.

If I then change the Branch 1 to

Topic 1:
There's a note here.
But wait, another note is necessary.

and merge, the result would be something like

Topic 1:
There's a note here.
<<<<
Topic 2:
Some remarks go here.
Topic 3:
Maybe those remarks were inappropriate.
====
But wait, another note is necessary.
>>>>

As you can see, the text that originally was in Topic 1, looks on its face value like it has been removed far from its original intended position, even if it is logically still in its proper place if we ignore the text between "<<<<" and "====".

My question is, if this visual confusion can somehow be overcome or if it is possible to help Git to detect the right order of the possible additions automatically. It could, for example, already help if the user could switch the positions of the "<<<<"--"====" text and the "===="--">>>>" text back and forth to see which addition is more appropriate in the context.  I have also tried changing the first branch into something like

Topic 1:
There's a note here.
End Topic 1

so that I avoid all confusion by putting additons before the enclosing topic markers. This works but it seems to clutter the text somewhat. I wonder if it would be possible to leave some sort of virtual markers into the text file that would be visible for Git's merge tool but would not clutter the text unnecessarily.

Last edited by catnap (2018-06-17 15:26:00)

Offline

#2 2018-06-15 11:57:03

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [WORKAROUND] Best way to help Git's merge tool to order text

You could look at the diffconflicts mergetool discussed at http://vim.wikia.com/wiki/A_better_Vimd … _mergetool


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#3 2018-06-17 15:25:38

catnap
Member
Registered: 2016-10-03
Posts: 131

Re: [WORKAROUND] Best way to help Git's merge tool to order text

At the moment, it seems that writing something like

Topic 1:
There's a note here.
Topic 2 (dummy):

to the text file is the best workaround.

Offline

Board footer

Powered by FluxBB