Update
This is solved now, thanks to @torek answer
I needed to have more lines above the new addition so that Git could move around the difference block, and I mean:
+a +b +c + +["foo", "bar", "baz"].map do |i| + i +end + ["foo", "bar", "baz"].map do |i| i.upcase end
Note. I tried with one line break instead of a\nb\nc\n , and also worked
The original question ...
I am using Git 2.9 on Mac OSX
The following is a validation example:
$ mkdir git-highlight && cd git-highlight $ touch foo.rb
I add and commit the following content:
["foo", "bar", "baz"].map do |i| i.upcase end
Now I am modifying the file to have the following content:
["foo", "bar", "baz"].map do |i| i end ["foo", "bar", "baz"].map do |i| i.upcase end
If I were to run either git diff or git diff --compaction-heuristic , then I get the following unexpected output:
diff --git a/foo.rb b/foo.rb index 9056b22..f0d289a 100644 --- a/foo.rb +++ b/foo.rb @@ -1,3 +1,7 @@ ["foo", "bar", "baz"].map do |i| + i +end + +["foo", "bar", "baz"].map do |i| i.upcase end
If you read this blog post from GitHub https://github.com/blog/2188-git-2-9-has-been-released , I am convinced that my output should look something like this:
+["foo", "bar", "baz"].map do |i| + i +end + ["foo", "bar", "baz"].map do |i| i.upcase end
The idea, which is a Git diffing algorithm, is more intelligent and able to identify a block change.
I also tried adding the following to my ~/.gitconfig , but it has no meaning for the result, I still get unexpected output:
[diff] compactionHeuristic = true
Any ideas on what I'm missing here?