是否可以配置git diff来尊重缩进和语法?我不是在谈论忽略缩进和空格,而是使用空行,缩进级别和可能的括号,以帮助将旧行与新行匹配.
例如,git diff经常切换函数及其docblock,如下所示:
class C {
/**
+ * Goes to the bar.
+ */
+ function bar() {
+ return 'bar';
+ }
+
+ /**
* Gets your foo up to date.
*/
function foo() {
Run Code Online (Sandbox Code Playgroud)
当我愿意的时候
class C {
+
+ /**
+ * Goes to the bar.
+ */
+ function bar() {
+ return 'bar';
+ }
/**
* Gets your foo up to date.
*/
function foo() {
Run Code Online (Sandbox Code Playgroud)
在这个例子中它仍然是非常无害的,但是有些例子中函数及其docblock由于贪婪和天真的diff实现而被撕裂.
注意:我已经配置*.php diff=php了 …