Git diff 显示没有更改的文件。

3

我正在尝试使用以下命令来区分本地和远程Git分支:

git diff --ignore-space-at-eol -b -w --minimal remotes/branch/master > diff.patch

除了我在补丁文件输出中看到的内容之外,一切都正常。

diff --git a/src/game/AccountMgr.cpp b/src/game/AccountMgr.cpp
index a271c8a..6f363c6 100644
--- a/src/game/AccountMgr.cpp
+++ b/src/game/AccountMgr.cpp
diff --git a/src/game/AccountMgr.h b/src/game/AccountMgr.h
index d406496..405fa32 100644
--- a/src/game/AccountMgr.h
+++ b/src/game/AccountMgr.h
...

看起来这些文件没有任何变化。我该如何从差异中删除这些文件?

2个回答

1
请注意,相同的git diff --ignore-space-at-eol可能存在反向错误:显示没有更改的地方却有更改。请参见Johannes Schindelin(dscho)于2016年7月9日提交的commit 044fb19commit a5229cc(由Junio C Hamano -- gitster --在2016年7月25日合并至commit f2cfb8f
git version
git version 2.9.2.windows.1

printf "a\nb\nc\n" >pre
printf "a\nbX\nc\n" >post
git diff --no-index --patience --ignore-space-at-eol pre post
(empty!?)

Git 2.10+ (Q3 2016)将修复这个问题:

diff:修复了--ignore-space-at-eol的双重偏移

当比较两行时,忽略任何空格到末尾,我们首先尝试匹配尽可能多的字节,并在不匹配时退出循环,让剩余部分由与其他whitespace-ignoring代码路径共享的代码处理。

然而,在比较字节时,我们总是增加计数器,即使字节不匹配也是如此。
并且因为此时我们跌落到了space-at-eol处理中,就好像那个不匹配从未发生过一样。

请参阅 "xdiff/xutils.c"


0

看起来是旧版的msys git中存在一个bug。更新到最新版本可以解决这个问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接