EGit Compare shows all rows as changed

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 a Git shell for Windows Bash in an existing Eclipse workspace, and then imported it into Eclipse as a project. However, if I right-click on a file that I have not changed and select Compare s> HEAD Revision, it will display all the lines as different.

In the Git shell for Windows Bash Git diff, nothing is displayed in the file. Running od -c on a file in Git Bash shows that it has a Windows-style line ending.

When I go into the Eclipse settings for Compare / Patch and say to ignore spaces, it shows no differences. But I would like to understand why this is necessary.

What really compares here?

+6
source share
1 answer

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

Even in Egit 3.4 (planned for June 2014) it will not be fixed. Robin Stocker gave this suggestion in a duplicate of the above error:

Until this is implemented, I recommend this setting:

  • For each Eclipse project, go to Properties> Resource and change New Text Line Separator to Other: Unix. Commit the result .settings / org.eclipse.core.runtime.prefs.

  • Do not configure any .gitattributes or "core.autocrlf" for Git. This means that the files will have the same line endings in the working as in the repository. Git and EGit do not convert file contents.

From 1. all new files created in Eclipse will have the correct (LF), even if they are created by the user in Windows.

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

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

So it seems that all developers need to check the end of the line themselves. But last but not least, you don't need any other tools to fix this. The File menu in Eclipse has: "Convert line breaks to." Also note that for individual projects and workspace settings, there are line termination options.

For projects: right click -> Properties -> Resource

For the workspace: Window โ†’ Preferences โ†’ General โ†’ Workspace

+5
source

All Articles