Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EGit Compare shows all lines as changed

Tags:

egit

Just installed Eclipse 4.3 (Kepler) which comes with EGit (which I updated to EGit 3.2.201312181205-r), and Git for Windows. I cloned a repository in the Git for Windows Bash shell under an existing Eclipse workspace, and then in Eclipse imported it as a project. However, if I right click a file that I haven't changed and select Compare With > HEAD Revision, it shows all lines as different.

In the Git for Windows bash shell, git diff on the file shows nothing. Running od -c on the file in Git bash shows it has Windows-style line endings.

When I go into Eclipse preferences for Compare/Patch and say to ignore whitespace, it shows no differences. But I'd like to understand why that is necessary.

What is really being compared here?

like image 735
jfklein Avatar asked Dec 30 '13 17:12

jfklein


1 Answers

This is a know bug in Egit. https://bugs.eclipse.org/bugs/show_bug.cgi?id=342372

Even in Egit 3.4 (planned for June 2014) it won't be fixed. Robin Stocker gave this suggestion in the duplicate of the above bug:

Until this is implemented, I recommend this setup:

  1. For each Eclipse project, go to Properties > Resource and change "New text file line delimiter" to Other: Unix. Commit the resulting .settings/org.eclipse.core.runtime.prefs files.

  2. Don't configure any .gitattributes or "core.autocrlf" for Git. This means that files will have the same line endings in the working directory as in the repository. Git and EGit will not convert any file contents.

With 1., all new files that are created in Eclipse will have correct (LF) line endings, even when created by a user on Windows.

For files that are already in your repository with CRLF, you can fix them and commit the result. I recommend using dos2unix or fromdos on the command line.

However it's been reported that Egit ignores these settings when importing a project. https://bugs.eclipse.org/bugs/show_bug.cgi?id=421364

So it looks like all developers need to check the line endings themselves. But least you don't need any other tools to fix this. Under the File menu in Eclipse there's a: "Convert Line Delimiters To". Also note there are line ending settings for both individual projects and in the workspace settings.

For projects: right-click -> properities -> Resource

For Workspace: Window -> preferences -> General -> Workspace

like image 63
mike Avatar answered Oct 21 '22 01:10

mike