democracyworks / dog-catcher

Scrapes data for great democracy win
MIT License
2 stars 0 forks source link

Normalizing Line-Endings for Cross-Platform Collaboration #10

Closed erikogan closed 10 years ago

erikogan commented 10 years ago

[I really didn’t want to start with this as a pull request, but rather as a suggestion via email. However my following pull requests all kept getting fouled up because my git configuration would not let me commit changes to text files with DOS line-endings, no matter how I tweaked the configuration. So I am forced to start here, and I hate that this is your first impression.]

Git was originally designed to manage the source for the Linux kernel. At first it made no assumptions about line-endings and did no translation, because everyone was working on Linux, and they all matched.

As time went on, and Git was ported to other systems, this became a problem. Various solutions have been proposed and adopted, with varying degrees of success. GitHub’s own Suggestions recommend users set the core.autocrlf configuration option, but this requires all users to do so. A more consistent option is to add a .gitattributes file to the repository, which overrides the line-ending handling in the client configuration.

I have added a .gitattributes file to the repository, however because the files were originally checked in with CRLF endings, that wreaks havoc with the files in my local repository, and requires normalizing the line endings on GitHub, which changes every line of every text file in the repository.

I have separated the two changes so that you can cherry-pick just the .gitattributes file if merging this pull request conflicts with local changes of your own. I’m happy to do the leg work of reconciling those with my later pull requests, as necessary. Hopefully this will go smoothly.

Thanks for your hard work on this repo!

cap10morgan commented 10 years ago

Thanks for the PR and the background info, @erikogan. One question: Is a .sln a Visual Studio solution file? Any reason that can't just go in your global .gitignore file (rather than being checked into the repo, which is presumably the only time the .gitattributes setting would come into play)?

erikogan commented 10 years ago

Nope, it’s even simpler than that: I copied the .gitattributes file from an existing project (or an example file, I can‘t remember), and modified it. I left in the *.sln directive in as an example for how to handle files that are “text,” yet the programs that use them assume CRLF line-feeds (especially if they get ornery if it changes).

You can just remove that line, it’s not relevant to this project. …Though it is also harmless.