Is it possible to configure git diff to respect indentation and syntax? I am not talking about ignoring indentation and spaces, but rather to use blank lines, indentation levels and possibly brackets, to help matching the old lines to new lines.
E.g. git diff often cuts through functions and their docblock, like this:
class C {
/**
+ * Goes to the bar.
+ */
+ function bar() {
+ return 'bar';
+ }
+
+ /**
* Gets your foo up to date.
*/
function foo() {
When I would prefer
class C {
+
+ /**
+ * Goes to the bar.
+ */
+ function bar() {
+ return 'bar';
+ }
/**
* Gets your foo up to date.
*/
function foo() {
In this example it is still quite harmless, but there are examples where functions and their docblock are really ripped apart due to the greedy and naive diff implementation.
Note: I already configured *.php diff=php
in ~/.gitattributes
.
EDIT: Another example: Here git diff mixes a property docblock with a method docblock:
/**
- * @var int
+ * @param string $str
*/
--patience
option, but it doesn't work in this case (--patience
will sometimes work, but not always). – Predetermine