Skip to content

feat: If core.autocrlf is enabled, replace CRLF with LF when adding to index #1441

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

Closed
wants to merge 2 commits into from

Conversation

rdbisme
Copy link

@rdbisme rdbisme commented May 17, 2022

This is to mimic the same behaviour the standard git command has.

Apart for the blackification, relevant lines are the definition of the class _FileStore, the addition of the method _autocrlf, and the adaptations in add() to use the _FileStore contextmanager.

The logic here is to replace \r\n with \n when adding to the index, then reset the local file to the original content.

@rdbisme
Copy link
Author

rdbisme commented May 17, 2022

It would be much easier to contribute if using black for style autolinting

Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

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

May I ask to adjust the commits to not do code formatting? I am happy to run it through black to unify the style and if it doesn't make it (too much) worse, but that should be a separate step.

All these changes are like noise to the signal making a review harder than it has to be. Thanks.

@rdbisme rdbisme force-pushed the autocrlf branch 5 times, most recently from 42a7249 to 6bccc36 Compare May 18, 2022 10:56
@rdbisme rdbisme force-pushed the autocrlf branch 4 times, most recently from a4f6f93 to e1e873d Compare May 18, 2022 11:06
i.e. replce CRLF with LF if `core.autocrlf` is True
@rdbisme
Copy link
Author

rdbisme commented May 18, 2022

Thanks for taking the time of applying black. I rebased everything on top of the latest commit and now the changes should more clear :)

@Byron
Copy link
Member

Byron commented May 19, 2022

Thanks for the contribution and the intention to fix a shortcoming.
However, I don't feel comfortable to add 'a very special filter' that will inadvertently affect current users that build upon the existing, very limited behaviour. It has a huge potential to cause breakage and thus I see no way to add it in its current form.

GitPython has been done very much in that fashion - implement something to mimic the actual behaviour of git - which has caused an incredible amount of problems and surprises down the road. It's just not a paradigm that should be continued.

I am sorry, but I see no way forward for this PR, and thank you for your understanding.

@rdbisme
Copy link
Author

rdbisme commented May 19, 2022

Thanks for the contribution and the intention to fix a shortcoming. However, I don't feel comfortable to add 'a very special filter' that will inadvertently affect current users that build upon the existing, very limited behaviour. It has a huge potential to cause breakage and thus I see no way to add it in its current form.

GitPython has been done very much in that fashion - implement something to mimic the actual behaviour of git - which has caused an incredible amount of problems and surprises down the road. It's just not a paradigm that should be continued.

I am sorry, but I see no way forward for this PR, and thank you for your understanding.

Ok, no problem. Thanks for reviewing! :)

@rdbisme rdbisme closed this May 19, 2022
suvayu added a commit to spine-tools/spine-conductor that referenced this pull request Oct 11, 2023
when adding files on Windows, sometimes it was changing line-endings.
This was because GitPython doesn't respect autocrlf (unfortunately
this is a WONTFIX upstream, see gitpython-developers/GitPython#1441).

Workaround: use git directly
suvayu added a commit to spine-tools/spine-conductor that referenced this pull request Oct 11, 2023
when adding files on Windows, sometimes it was changing line-endings.
This was because GitPython doesn't respect autocrlf (unfortunately
this is a WONTFIX upstream, see gitpython-developers/GitPython#1441).

Workaround: use git directly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants