-
-
Notifications
You must be signed in to change notification settings - Fork 934
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
Conversation
It would be much easier to contribute if using |
There was a problem hiding this 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.
42a7249
to
6bccc36
Compare
a4f6f93
to
e1e873d
Compare
i.e. replce CRLF with LF if `core.autocrlf` is True
Thanks for taking the time of applying black. I rebased everything on top of the latest commit and now the changes should more clear :) |
Thanks for the contribution and the intention to fix a shortcoming. 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! :) |
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
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
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 inadd()
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.