Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: renormalize line endings in gradlew.bat #180

Merged
merged 1 commit into from Feb 19, 2023
Merged

chore: renormalize line endings in gradlew.bat #180

merged 1 commit into from Feb 19, 2023

Conversation

vlsi
Copy link
Contributor

@vlsi vlsi commented Feb 19, 2023

This is a result of running git add . --renormalize: https://stackoverflow.com/a/47580886/1261287

Without this PR, macOS shows gradlew.bat as always modified

@szpak
Copy link
Contributor

szpak commented Feb 19, 2023

I wonder why it affects only Mac, not Linux 🤔 . But maybe it's right ahead of me ;-).

@vlsi
Copy link
Contributor Author

vlsi commented Feb 19, 2023

renormalize is sensitive to the "first git clone".
Have you tried making a fresh clone?
I guess you'll reproduce it then.

@vlsi
Copy link
Contributor Author

vlsi commented Feb 19, 2023

In any case, the flow is the same: one needs to add .gitattributes, and it should go together with renormalize.
I've done that multiple times, and it resolves LF/CRLF issues.

@TWiStErRob
Copy link
Collaborator

But then this PR shows that you've changed all CRLF to LF in the repository, how is it going to work on Windows where Batch interpreter cannot handle LF?

@TWiStErRob
Copy link
Collaborator

TWiStErRob commented Feb 19, 2023

Ok, other than being extremely confused, this is actually necessary. It affects me as well, just didn't see it. When I add the remote and checkout vlsi's branch it works fine, and when re-cloning his fork it also works fine. (I'm on Windows btw.)

@TWiStErRob
Copy link
Collaborator

Note: if you download https://raw.githubusercontent.com/vlsi/publish-plugin/renormalize/gradlew.bat, it has LF characters in it.

If you download https://github.com/vlsi/publish-plugin/archive/refs/heads/renormalize.zip, it has CRLF characters correctly.

Is this a bug with the raw endpoint then?

@vlsi
Copy link
Contributor Author

vlsi commented Feb 19, 2023

how is it going to work on Windows where Batch interpreter cannot handle LF?

TLDR: Git converts EOL on checkout. They recommend using core.autocrlf=true with Windows.

Git stores text files in LF format, and it converts them on checkout.
I guess the file was previously stored as "binary" (==CRLF line endings).
As .gitattributes is added, Git understands the file should be stored as LF (in its internal storage) while the file is CRLF, so git shows the diff.

@szpak
Copy link
Contributor

szpak commented Feb 19, 2023

I my other projects, I also use gradlew.bat text eol=crlf with gradlew.bat converted with unix2dos to the crlf format (I didn't know about --normalize) and it works fine. Most likely, importing this project, we missed that step which could cause the aforementioned result.

@szpak szpak added this pull request to the merge queue Feb 19, 2023
Merged via the queue into gradle-nexus:master with commit 3dae00e Feb 19, 2023
@TWiStErRob
Copy link
Collaborator

Thanks for the info, really helpful!

They recommend using core.autocrlf=true with Windows.

I just had way too many problems with this, some files would be committed with LF some with CRLF, depending on which tool created them. So I just turned it off and rely on whatever is in the repo. IDEA also nicely warns me when I (accidentally) commit CRLF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants