Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » File diffs always show whitespace changes
File diffs always show whitespace changes [message #895758] Sun, 15 July 2012 19:43 Go to next message
Derek Battams is currently offline Derek BattamsFriend
Messages: 2
Registered: July 2012
Junior Member
Running EGit 2.0.0.201206130900-r/Eclipse 4.2 on Win7.

Anytime I diff a file within Eclipse against any version from my Git repository, the comparison always shows whitespace changes, even if I compare a freshly committed file against HEAD (which shouldn't show any differences). Yet, if I go to the command line and do a git-diff of my working copy against my repo then the diffs look as I'd expect (i.e. the tonnes of whitespace diffs aren't present). So it appears the diff being done by EGit is causing the issue. These whitespace diffs make it almost impossible to view file diffs as needed before committing. Is there some way to correct this?

Help appreciated.

index.php/fa/10712/0/

This screen is comparing a file to HEAD immediately after committing the file to my repo. I'd expect zero differences to be reported and if I run git-diff from the command line I do indeed get zero differences, but EGit is showing all of these whitespace differences.

[Updated on: Sun, 15 July 2012 19:48]

Report message to a moderator

Re: File diffs always show whitespace changes [message #895766 is a reply to message #895758] Sun, 15 July 2012 21:03 Go to previous messageGo to next message
Robin Rosenberg is currently offline Robin RosenbergFriend
Messages: 332
Registered: July 2009
Senior Member
Derek Battams skrev 2012-07-15 21.43:
> Running EGit 2.0.0.201206130900-r/Eclipse 4.2 on Win7.
>
> Anytime I diff a file within Eclipse against any version from my Git repository, the comparison always shows whitespace changes, even if I compare a freshly committed file against HEAD (which shouldn't show any differences). Yet, if I go to the command line and do a git-diff of my working copy against my repo then the diffs look as I'd expect (i.e. the tonnes of whitespace diffs aren't present). So it appears the diff being done by EGit is causing the issue. Is there some way to correct this?

For now you can ignore whitespace differences with Eclipse settings under Compare/Patch.

-- robin
Re: File diffs always show whitespace changes [message #895775 is a reply to message #895766] Mon, 16 July 2012 00:03 Go to previous messageGo to next message
Derek Battams is currently offline Derek BattamsFriend
Messages: 2
Registered: July 2012
Junior Member
That did it. Thanks! Is there a reason why that setting change is required with Git, but wasn't when I was using SVN?
Re: File diffs always show whitespace changes [message #895797 is a reply to message #895775] Mon, 16 July 2012 06:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
My impression is that EGit, despite line-ending conversion being a
fundamental long standing issue for which there remain open bug reports,
continues to mishandle the autocrlf setting. In particular, my
impression is that on Windows when you modify a file, the copy that's
stored in the index is changed to use Unix-style line endings while the
workspace copy keeps the line settings the resource already has. It's
endless frustrating. As far as I understand, the platform team mostly
avoids the issue by changing the workspace preferences to use Unix-style
line endings.

The question remains: How can something as fundamental to version
management as the proper handling of different line feed conventions on
different platforms remain an issue for years?


On 16/07/2012 2:03 AM, Derek Battams wrote:
> That did it. Thanks! Is there a reason why that setting change is
> required with Git, but wasn't when I was using SVN?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: File diffs always show whitespace changes [message #899896 is a reply to message #895797] Thu, 02 August 2012 18:00 Go to previous messageGo to next message
Mark Mikofski is currently offline Mark MikofskiFriend
Messages: 3
Registered: August 2012
Junior Member
I came to the same conclusion as Ed Merks. It took me a while to realize that it wasn't just showing me whitespace, but it was showing the entire file as one be change, and what would do that? Well the obvious answer was line-endings. I was able to confirm it by comparing my local version with the "local history" - correctly shows changes, then compare two commits, also works correctly, but anytime you compare a local file to a git file, you get one giant change, which is a unfortunately useless. This is evidently addressed in Bug 361503 which, I believe, is the right approach - just include an option to ignore line-endings in diffs in the comparison editor. My suggestion to everyone in this post is to follow the link to this "bug" and vote for it so that this option gets changed. You will need to login.
Re: File diffs always show whitespace changes [message #899902 is a reply to message #899896] Thu, 02 August 2012 18:28 Go to previous messageGo to next message
Mark Mikofski is currently offline Mark MikofskiFriend
Messages: 3
Registered: August 2012
Junior Member
FYI: There is a workaround, as suggested in message #895766. Unless you absolutely mustsee the whitespace, checking Ignore white space in under windows | preferences | General | Compare/Patch also ignores line-endings, therefore fixing the problem!

[Updated on: Thu, 02 August 2012 18:28]

Report message to a moderator

Re: File diffs always show whitespace changes [message #1727544 is a reply to message #895758] Wed, 23 March 2016 16:45 Go to previous messageGo to next message
Eric Woestman is currently offline Eric WoestmanFriend
Messages: 2
Registered: January 2016
Junior Member
Just in case anyone does a Google search for this issue and finds this forum post, I've had the same problem and was finally able to fix it. I did not like the recommendation to simply tell Eclipse to ignore whitespace changes during the text diff because when I performed the commit using Eclipse, it would create a commit where the entire file was changed. This became very frustrating when working with other developers on different operating systems.

Credit for the solution goes to this Stack Overflow question: http://stackoverflow.com/questions/8227233/there-is-nothing-changed-but-eclipse-egit-marks-the-file-as-changed

The problem for me was due to being on Windows and EGit not respecting the "core.autocrlf" configuration setting. When I run "git config --list" from the command line I can see that "core.autocrlf" is set to "true". But when I open Eclipse Preferences / Team / Git / Configuration, that setting is not listed in any of the tabs. There are 2 ways to solve this. The first way is to manually add the "core.autocrlf" setting to "true" in the Eclipse preferences which will solve the problem for Eclipse. However, I think the better solution is to run "git config --global core.autocrlf true" to explicitly set it to true in the global configuration file which Eclipse will then read. Somehow this setting was set for Git command line but was not stored in any of the 3 config files that Eclipse would read.

I hope this helps any future visitors.
Re: File diffs always show whitespace changes [message #1739002 is a reply to message #1727544] Tue, 26 July 2016 16:52 Go to previous messageGo to next message
Daniel Harvey is currently offline Daniel HarveyFriend
Messages: 1
Registered: July 2016
Junior Member
Thanks very much for posting this reply: explicitly setting autocrlf via "git config --global core.autocrlf true" made EGit pick up the setting and more importantly, fixed the issue.

I added my vote for the bug recommended by Mark Mikofski above because it makes sense to me for EGit to proactively address this by looking more broadly at autocrlf settings and providing relevant options , but I think part of the responsibility for this issue is in the Windows version of GIT.

When you install Git for Windows and select the autocrlf=true option, it behaves everywhere as though the setting is global, though in fact it is not apparently in the global config file. This is very misleading, and makes issues like these hard to find.
Re: File diffs always show whitespace changes [message #1749420 is a reply to message #1727544] Tue, 06 December 2016 14:35 Go to previous message
Scott Moore is currently offline Scott MooreFriend
Messages: 2
Registered: December 2016
Junior Member
Thanks for the git config solution, that did the trick for me as well.
Previous Topic:Will egit create a "generic" local branch name if the remote branch name is very long?
Next Topic:Subtree or subrepo support in egit
Goto Forum:
  


Current Time: Thu Mar 28 17:10:57 GMT 2024

Powered by FUDForum. Page generated in 0.03549 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top