Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Git's patience diff algorithm for interactive add

Tags:

I'd like to use Git's patience diff algorithm (the one you get if you invoke git diff with the --patience argument) with git add -p. How can I do this?

Background: I'm working with some XML files, and git diff's normal algorithm produces pretty poor diffs due to "misaligned" entry/exit tags. If I run git diff --patience, I get much more useful diffs, but there's no obvious way to use these diffs in git add -p.

like image 648
me_and Avatar asked Sep 14 '12 13:09

me_and


People also ask

What is patience diff algorithm?

The first thing to note is that patience diff is not a diff algorithm in and of itself. What it really is is a method of matching up lines in two versions of a document in order to break them into smaller pieces, before using an actual diff algorithm like Myers on those pieces.

What algorithm does git diff use?

Myers Algorithm – human readable diffs This is used by tools such as Git Diff and GNU Diff.

What is the diff algorithm?

The essence of diff algorithms is in contrasting the two sequences and to receive insight of the transformation from the first into the second by a series of operations using the ordered deletion and insertion. The subsequence can be flagged as a change if a delete and an insert concur on the same scope.


1 Answers

git add -p currently rejects diff flags, but you can use the diff.algorithm config option:

git config --global diff.algorithm patience 

New in Git 1.8.2.

like image 177
Tobu Avatar answered Oct 10 '22 15:10

Tobu