git diff - 在特定情况下可以改变它的行为吗?

时间:2012-06-08 13:33:35

标签: git diff

假设我有this file(简短),在开发过程中我将其编辑为this file。 然后,git diff的输出如下:

...
@@ -7,6 +7,12 @@ int main() {
     // some code here, implementing section 1

     /***************************************************************************
+     ** New section header 2, with short description
+     **************************************************************************/
+
+    // some code here that goes between the old sections 1 and 2
+
+    /***************************************************************************
      ** Section header 2, with another short description
      **************************************************************************/

这对我来说似乎是不受欢迎的,因为它打破了这一部分被添加的逻辑变化'进入'此部分插入到其他部分的标题中间。我期待这样的事情:

...
@@ -7,6 +7,12 @@ int main() {
     // some code here, implementing section 1

+    /***************************************************************************
+     ** New section header 2, with short description
+     **************************************************************************/
+
+    // some code here that goes between the old sections 1 and 2
+
     /***************************************************************************
      ** Section header 2, with another short description
      **************************************************************************/

diff中是否有可以纠正此问题的选项(即如果我正在修补补丁,那么不必手动完成修正)?我尝试了git diff手册页中列出的其他一些算法,但它们都产生了相同的结果。

我知道Git会在提交时存储源树的全部快照(并且diff是动态生成的),所以最终它不会影响实际内容,但是这可能是这样的例如,在合并期间导致问题?我认为在某种程度上让我感到困扰的是,我所做的逻辑改变并没有完全反映在它产生的diff中。

0 个答案:

没有答案
相关问题