eclipse-egit / egit

EGit, the git integration of Eclipse IDE
https://www.eclipse.org/egit/
Eclipse Public License 2.0
18 stars 7 forks source link

File comparison launch from "Git Staging" part or "History" part, shows different EOL (CRLF) for ancestor #45

Open JeanGarf opened 4 months ago

JeanGarf commented 4 months ago

Version

6.10.0

Operating System

Windows

Eclipse version

2024-06

Bug description

I have a .gitattibutes with : .githooks/** text eol=lf

I have a file named .githooks/commit-msg. I check icon to "Show whitespace characters". My file has only LF.

I perform a change in this file and save it. It appears in "Unstaged Changes" in "Git Staging" part.

When I double click on it in "Git Staging" part, the comparison editor show the git ancestor with CRLF instead of LF (but LF for my local file), and therefore find false white space changes on each line.

But if in History part, I double click on a commit, the comparison editor show the git ancestor with LF, which is correct.

Actual behavior

When I double click on it in "Git Staging" part, the comparison editor show the git ancestor with CRLF instead of LF (but LF for my local file), and therefore find false white space changes on each line.

Expected behavior

When I double click on it in "Git Staging" part, the comparison editor should show the git ancestor with LF due to my .gitattribute and should be coherent with a double clic on a commit in the History part.

Relevant log output

No response

Other information

No response

msohn commented 2 months ago

How did you configure line ending related git options ? Check global configuration in ~/.gitconfig and repo specific configuration in .git/config

creckord commented 1 month ago

I am facing the same issue, also on Windows.

.gitattributes:

* text=auto

*.java text
*.yaml text
*.yml text
*.xml text
*.json text
*.md text
*.txt text
*.properties text eol=crlf

*.tar text=false
*.zip text=false
*.gpg text=false
*.gz  text=false
*.jpg text=false
*.png text=false
*.tgz text=false

/src/test/resources/**/* text=false

.git/config:

[core]
        ...
        eol = lf
        autocrlf = true
        safecrlf = false

I can confirm that the repository does contain the files with LF only, as does my working copy, and as far as I can trust my local git command line, so does the index with my staged changes.

Yet in EGit all the files always show up like this if Ignore Whitespace is off, with CRLF on the staged end, when comparing working copy and index:

image

When comparing index and upstream, both show as CRLF, which at least makes the diff view more usable.