Description
Apache NetBeans version
Apache NetBeans 26 latest release candidate
What happened
NetBeans' Git integration seems to not perform any EOL conversion on text files when core.autocrlf is set to false (or the default setting).
Language / Project Type / NetBeans Component
VCS/Git
How to reproduce
- In your global .gitconfig, set:
The core.eol = crlf should force the default Windows behavior, even on Unix. The autocrlf = false is merely making the default explicit, it can also be left out.
[core] eol = crlf autocrlf = false # this is the default
- Prepare a Git repository containing at least one non-empty text file containing line breaks, for example Test.java, and a .gitattributes file containing:
* text=auto
*.java text
# just to be sure - Clone the repository using NetBeans
- In the terminal, check the line endings using
git ls-files --eol
. The result is:("i" are the line endings in the index/repository, "w" in the working directory.)i/lf w/lf attr/text=auto .gitattributes i/lf w/lf attr/text Test.java
=> The files have been checked out as LF although according to the core.eol setting they should have been checked out as CRLF. - In the working directory, convert Test.java to CRLF using
unix2dos
or similar. - Make a dummy edit to Test.java so that NetBeans recognizes it as modified.
- Commit the modification of Test.java using NetBeans (Team > Commit...)
- Check again the line endings using
git ls-files --eol
. The result is:=> The file was committed with CRLF as-is, instead of being converted to LF.i/lf w/lf attr/text=auto .gitattributes i/crlf w/crlf attr/text Test.java
The observed behavior is as if NetBeans/JGit is treating the files as binary files instead of text files.
Doing the checkouts/commits using command-line Git (specifically, version 2.39.0) does apply the expected EOL conversions.
Did this work correctly in an earlier version?
No / Don't know
Operating System
Windows 10
JDK
JDK 21
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
For context, Git is supposed to work as follows, for files that are identified as text files (via .gitattributes or similar):
- The repository is expected to never contain CRLF line endings in text files.
- On check-in, CRLF line endings in text files are always converted to LF, regardless of core.eol or other settings.
- On checkout, LF line endings in text files are converted to CRLF iff core.eol = crlf (or equivalent settings in .gitattributes, or by means of core.autocrlf).
More details about the standard Git behavior here: https://dev.to/matthies/comment/2jeik
I don't know if this is a NetBeans issue or a JGit issue. However, it is an issue for cross-platform development with NetBeans.
Are you willing to submit a pull request?
No