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

Configure git to always use LF line endings in the working directory #27291

Merged
merged 1 commit into from
Jul 22, 2018

Conversation

davidanthoff
Copy link
Contributor

@davidanthoff davidanthoff commented May 28, 2018

If I understand git correctly, then this patch means that a) git will try to automatically detect whether a file is a text file (the default in any case) and then b) for all text files always use LF line endings in the working directory, even on Windows, even if there is a global setting core.eol crlf configured.

Hopefully this patch would change nothing on Mac and Linux systems. On Windows, it does mean that if I do a git clone, everything will be checked out with LF line endings, which is good, because the build fails otherwise :)

This enables the following scenario: one can clone julia and use git from a Windows environment that uses the default git configuration for line endings. And then one can compile julia in WSL. And all of that works in the /mnt/c locations. Being able to use git from the Windows environment is nice in this case because one can e.g. use the built in git in VS Code.

Someone with more git foo should carefully think this patch through, though, before it gets merged, I'm not really an expert on this.

EDIT: Oh, and I do think that this section could be removed if this patch here gets merged.

.gitattributes Outdated
@@ -1,2 +1 @@
# treat patches as files that should not be modified
*.patch -text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably there was a reason why we didn't want to do this to patch files?

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we had patch files with mixed eol characters (because we need to exactly match the source file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this removed line means that patch files were treated as binary files, so their line endings were never modified. I think making sure that they are always checked out with LF line endings (this PR) achieves the same goal. @maleadt, you introduced the line here, do you think the PR here subsumes your configuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I only saw @vtjnash's comment after I had submitted mine. I've now changed the PR here to keep the special handling for patch files, certainly no harm in that.

@davidanthoff
Copy link
Contributor Author

Bump, anything else that needs to be done here?

@StefanKarpinski
Copy link
Sponsor Member

@Keno, you approved... merge if this seems right to you.

@Keno Keno merged commit 03f0ae5 into JuliaLang:master Jul 22, 2018
@davidanthoff davidanthoff deleted the eol-windows branch July 22, 2018 16:33
@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 24, 2018

EDIT: Oh, and I do think that this section could be removed if this patch here gets merged.

I think that section is equivalent to “* -text” (That is, treat all files as binary and never alter them on checkout or checkin)

@davidanthoff
Copy link
Contributor Author

I think with the now current setting, if you edit something in your workspace and introduce a CRLF, it would store the file properly with just LF in the git repo, whereas a blanket binary treatment wouldn't?

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 24, 2018

That could make it hard to properly store files that are are expected to contain CRLF (of which I suppose #28241 (comment) is a complete list), since now git may choose to silently corrupt them. I agree that's true, I just can usually avoid using any editors that can't handle EOL correctly – even notepad.exe can finally do that.

@davidanthoff
Copy link
Contributor Author

Hm, that is weird. I have a hard time imagining that git would misdetect a png file as a text file...

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 24, 2018

According to that git commit fix, "text=auto" used to mean "interpret all files as text"

@davidanthoff
Copy link
Contributor Author

Ah, yes... so is it reasonable to ask everyone to use a git version >=2.10? If not, we would probably have to undo this commit... And maybe just go to declaring everything binary?

@ararslan
Copy link
Member

so is it reasonable to ask everyone to use a git version >=2.10?

FWIW that isn't even available for my primary system (Elementary OS, which is basically Ubuntu 16.04).

@StefanKarpinski
Copy link
Sponsor Member

I think we've got to undo this change. Insisting on a super-recent git seems impractical.

ararslan added a commit that referenced this pull request Jul 25, 2018
@ararslan
Copy link
Member

Reverted in #28280.

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

5 participants