None of the built-in diff algorithms will behave this way.
I am interested in what you would like to see, for example, the change was to add one line and replace the other two so that (to capture your example) you would have something like this:
-t1 = "Christmas 2013" +t1 = "Christmas 2014" +t2 = "Easter 2014" -t3 = "Thanksgiving 2013" +t3 = "Thanksgiving 2014"
Here for t2 do not delete anything.
In any case, I believe your best result is likely to handle the output of git diff -U0 .
If you are using a Unix-ish system, you can also use an original, non-unified diff, for example:
$ diff --git a/like_min.py b/like_min.py index 05b9a4d..1c90084 100644 --- a/like_min.py +++ b/like_min.py @@ -1 +1 @@ -def like_min(iterable, key=None): +def like_min(iterable, key=None): # comment @@ -9 +9 @@ def like_min(iterable, key=None): - for candidate in it: + for candidate in it: # another comment $ git show HEAD:like_min.py | diff - like_min.py 1c1 < def like_min(iterable, key=None): --- > def like_min(iterable, key=None): # comment 9c9 < for candidate in it: --- > for candidate in it: # another comment
which may be easier for further processing (depending on many details). In particular, each change begins with a line number and an alphabetic code ( a dd, c hange, d elete), so there is no need to find out if something is a pure addition or pure deletion, as well as changes you would like to split into one line in that time. You still have to turn the “change” into the “change followed by the addition or removal” if the new number of rows does not match:
$ git show HEAD:like_min.py | diff - like_min.py 1c1,2 < def like_min(iterable, key=None): --- > def like_min(iterable, key=None):
In addition, the “old diff” may have different (and not desired) space parameters ignored by the space.
Collapsing with --break-rewrites orthogonal to what you want: it just changes the point at which git considers the file to be “completely rewritten”, and thus shows a change like “delete all contents of the previous file, new contents”.
According to the documentation, the default breakpoint is -B50%/60% , which indicates that no more than 60% of the file can be "overwritten" or, equivalently, "at least 40% of the file still matches." You may want to reduce this, but you probably do not want to increase it. (By the way, I cannot set this to 0%, setting it to 1% , so that most changes become a complete rewrite, but small changes, such as changing only one line of the file, still appear as small changes, not the final -file -rewrites. This is probably due to the fact that the similarity index is not based solely on time changes, but also includes inline matches.)
(This first number - 50% at -B50%/60% - is the similarity index value used to determine rename, provided that rename detection is enabled. Think of the two numbers as “similarity and difference” values: the similarity index is “how much file 1 is close to file 2 ", and the unconsciousness is only 100% minus the similarity.)