Git贵"No diffferences detected"

Git Gui "No diffferences detected"

我在 Git 中有一个存储库,其中大量文件被标记为正在由 Git Gui 编辑,当我单击其中一个包含以下内容时会出现一个对话框:

    "No differences detected.

     filename.h has no changes.

     The modification date of this file was updated by another
     application, but the context within the file has not changed.

     A rescan will be automatically started to find other files which
     may have the stame state."

如果我单击“确定”按钮,应用程序会重新扫描并显示完全相同的结果,因为任何具有这种情况的文件都会出现相同的对话框。

有什么方法可以通过忽略白色从扫描中自动删除这些 space 吗?

首先检查您的 git config --global core.autocrlf 是否设置为 false。

如果不是(或如果为空),将其设置为 false,再次克隆您的 Git 存储库,并检查 Git GUI 是否持续评估。


消息本身来自“git-gui/lib/diff.tcl#handle_empty_diff", whose blame view 显示 10 年以上的代码。

具有讽刺意味的是,有一个名为“git-gui: Avoid an infinite rescan loop in handle_empty_diff.”的提交 (commit 584fa9c)

If the index update machinery and git diff happen to disagree on whether a particular file is modified, it may cause git-gui to enter an infinite index rescan loop, where an empty diff starts a rescan, which finds the same set of files modified, and tries to display the diff for the first one, which happens to be the empty one.
A current example of a possible disagreement point is the autocrlf filter.

This patch breaks the loop by using a global counter to track the auto-rescans. The variable is reset whenever a non-empty diff is displayed.

Another suggested approach, which is based on giving the --exit-code argument to git diff, cannot be used, because diff-files seems to trust the timestamps in the index, and returns a non-zero code even if the file is actually unchanged, which essentially defeats the purpose of the auto-rescan logic.

试试这个:git add --renormalize -- :/

上面 VonC 的回答为我修复了这个非常烦人的错误。它应该是公认的解决方案。

一个问题是我复制并粘贴了“git add --renormalize -- :/”,在句末结束了句号,像这样:“git add --renormalize -- :/.”我一个小时后回来了到这个答案并意识到我做了什么。

这完全是我的错,因为事后看来他的代码标记很明显。