Skip to content

Conversation

bethmaloney
Copy link
Contributor

Update gitattributes as per https://stackoverflow.com/a/52996849

Old gitattributes used the .gitconfig syntax which is different to .gitattributes

Not sure why we need to disable autocrlf though? The repo has a few files with inconsistent line endings that VS complains about. Could we normalize the line endings and then enable autocrlf? This would be a more standard configuration and stop VS from complaining about mixed line endings. Happy to open a PR for this.

@oskarb
Copy link
Member

oskarb commented Feb 25, 2024

Yeah, I don't understand this setting at all.

In my experience, what seems to work best is:

# Set the default behavior, to avoid relying one everyone setting core.autocrlf themselves
* text=auto
# VS solution files are always CRLF
*.sln text eol=crlf
# Resharper DotSettings files are always LF Unix format
*.DotSettings text eol=lf
# Add other well-known extentions if you like...
*.cs text
*.png binary
# ...

I've used this setup for many years in different projects that are used in both Linux and Windows. It's also essentially what nhibernate-core does since many years. Mind you - the main NHibernate code base used to have a lot of inconsistencies many years ago, and there was a constant stream of mixed-ending pull requests coming in until I did a massive cleanup to make sure everything was stored in LF format in the repo and applied the these gitattributes.

The nhibernate project actually did use this * -text setting, but that is what did not work reliably until I changed it:
https://github.com/nhibernate/nhibernate-core/commits/master/.gitattributes
nhibernate/nhibernate-core@c85d038

Yes, that was a massive commit to normalize all line endings. The choice was between doing that once or continue to suffer line ending issues over and over again in almost every pull request.

@bethmaloney
Copy link
Contributor Author

@oskarb That all makes sense to me and I think it's the best approach. I've opened a new PR #642 which normalises the line endings and updates the gitattributes file so it's the same as the main NHibernate project. I'll leave both PRs open for now until one approach is selected and then I'll close the other.

@hazzik hazzik closed this Feb 26, 2024
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.

3 participants