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

Rationale for specifying line endings in .gitattributes generally, and specifically for *.ps1 files. #174

Open
blakeNaccarato opened this issue Dec 29, 2022 · 1 comment

Comments

@blakeNaccarato
Copy link

blakeNaccarato commented Dec 29, 2022

I initially stumbled upon this when seeing *.ps1 has eol=crlf. Merged PR #125 assumes that PowerShell is cross-platform and therefore shouldn't have CRLF specified, while the merged PR #129 overrides the previous one and assumes it is Windows-specific. I think that *.ps1 files shouldn't have CRLF specified by default, since teams can use PowerShell as their terminal on both Windows and Unix-like systems.

The general question of whether line endings should be coerced at all in .gitattributes is worth asking. This guide suggests that .gitattributes overrides the core.autocrlf setting, which could be surprising for the uninitiated. I personally prefer using core.autocrlf to standardize across platforms, and line ending overrides in .gitattributes are surprising to me, at least.

I'm curious as to your rationale for specifying line endings in .gitattributes. I think it's fine whatever you decide! But maybe a disclaimer is warranted in the readme, as to the philosophy behind this decision. If it's signposted, then users with a different mindset can remove those EOL specifications. I know it's hard to devise a single "source of truth" for anything, let alone the esoteric details behind .gitattributes, so to attempt to standardize on anything at all is an admirable effort.

@jozefizso
Copy link
Member

There are cases when this is realy needed. Especially for .cmd, .bat and .sh files.

As the PowerShell Core is cross platform, I don't think the CRLF should be enforced for .ps1 files anymore.

On the otherhand the .sh files really must be LF only. This is required when working with .sh on Windows and running them using MinGW or WSL in case the repository was checked-out on Windows.

Simillary when I checkout repository inside WSL but I need to run some scripts which are .cmd or .bat files on the Windows side, they must be 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

No branches or pull requests

2 participants