Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Gui "No diffferences detected"

Tags:

git

git-gui

I have a repository in Git, where a large number of files are flagged as being edited by Git Gui, a dialog comes up when I click on one of them containing:

    "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."

If I click on the Ok button the application rescans and displays exactly the same results which presents and endless loop because any file with this condition presents the same dialog.

Is there any way I can remove these automatically from the scan by ignoring white space ?

like image 217
SPlatten Avatar asked Aug 19 '19 12:08

SPlatten


2 Answers

VonC's answer above fixed this very annoying bug for me. It should be the accepted solution.

One problem was I copied and pasted the "git add --renormalize -- :/", which ended up with his period at the end of the sentence, like this: "git add --renormalize -- :/." I came back after an hour to this answer and realized what I had done.

It was my fault entirely, as his code marker was obvious in hindsight.

like image 113
Ferd Avatar answered Nov 09 '22 02:11

Ferd


Check first if your git config --global core.autocrlf is set to false.

If not (or if empty), set it to false, clone again your Git repository, and check if the Git GUI persists in its assessment.


The message itself comes from "git-gui/lib/diff.tcl#handle_empty_diff", whose blame view shows 10+ years-old code.

Ironically, there is a commit named "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.

Try using this: git add --renormalize -- :/

like image 34
VonC Avatar answered Nov 09 '22 02:11

VonC