The definition of the default algorithm does not translate into the default merge algorithm (patience)

advertisements

I've seen many blog posts and stack overflow posts say that git config --global diff.algorithm patience will allow both diffs and merges to use the patience strategy option with the default recursive algorithm.

I have found this to not be the case, and I pose the following demo to show why not.

git config --global diff.algorithm patience   //mythical config statement  

git clone https://github.com/kjlubick/PracticingGit.git
cd PracticingGit
git checkout origin/patience-merge-1 -t

git checkout -b merge_test           //temp branch for merging
git diff origin/patience-merge-2

This diff (image courtesy of meld looks pretty good. Let's try to merge it in.

git merge origin/patience-merge-2

Huh? That merge looks ugly. Despite lines 9-19 not actually changing, they are marked as conflicted/changed in completely different way than with the diff.

If we force the merge to use the patience strategy option:

git merge --abort
git merge origin/patience-merge-2 -X patience

That's much better. The conflicts match up with the diff we made earlier and are semantically correct.

How can I make merging actually use the patience setting, not just diffs?

Additional shots in the dark I tried (unsuccessfully):

git config --global merge.algorithm patience
git config --global merge.diff.algorithm patience

System info:
Windows 8.1
git version 1.8.4.msysgit.0 (via GitHub for Windows 2.0)


Patching git, like Appleman1234 is not ideal. I hope this feature comes in future versions.

For now, I think I'll have to settle for the alias

git config --global alias.pmerge "merge -X patience --"

which allows me to do

git pmerge origin/patience-merge-2

instead of

git merge origin/patience-merge-2 -X patience

in the example I gave earlier.