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

Windows newlines in diff --cached after git add with nbstripout #110

Closed
tgandor opened this issue Nov 28, 2019 · 10 comments
Closed

Windows newlines in diff --cached after git add with nbstripout #110

tgandor opened this issue Nov 28, 2019 · 10 comments

Comments

@tgandor
Copy link

tgandor commented Nov 28, 2019

I installed nbstripout without arguments (locally) in the repository.

Then I added a "dirty" notebook, say with git add myNb.ipynb.

Ok, doing a check with git diff --cached - I don't see outputs or metadata (OK!), but all the inserted lines have a "^M" (carriage return) in the diff view.

I ran nbstripout myNb.ipynb and git status showed no changes. Even so, I re-ran git add myNb.ipynb and then git diff --cached showed a lot of newlines.

I also have nbdime installed, so I saw that the [diff ipynb] (or sth like that) section in .git/config and deleted it. The ugly JSON diffs with ^M disappeared, and the structured nbdime diff shows no appended newlines (but - it may actually mask the problem).

I can't be sure what is at fault here:

  • stripping while adding (adds newlines)?
  • the diff configuration (or underlying command) gives spurious output?
  • core.autocrlf=true doesn't work after configuring nbstripout?

I'd like to know, if this is a false alarm, or actual whitespace pollution to the repository.

@kynan
Copy link
Owner

kynan commented Jan 5, 2020

Can you please confirm your platform, Python and nbstripout version?

@kynan kynan added state:waiting Waiting for response for reporter type:bug help wanted labels Jan 5, 2020
@tgandor
Copy link
Author

tgandor commented Jan 27, 2020

I'm sorry but I've been working in a setup where I wanted to commit the cell outputs together with the notebooks recently. In the next few days I'll set up nbstripout again and try to reproduce this.

@amard33p
Copy link

Windows10 == 1809
Python == 3.8.1
nbstripout == 0.3.7

--- a/arrays_strings/rotation/rotation_challenge.ipynb
+++ b/arrays_strings/rotation/rotation_challenge.ipynb
@@ -165,9 +165,9 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.5.0"
+   "version": "3.8.1"^M
   }
  },
  "nbformat": 4,
- "nbformat_minor": 0
+ "nbformat_minor": 1^M
 }

@kynan
Copy link
Owner

kynan commented May 9, 2020

What is your Git config setting for core.autocrlf and core.safecrlf?

@amard33p
Copy link

amard33p commented May 9, 2020

What is your Git config setting for core.autocrlf and core.safecrlf?

$ git config core.autocrlf
input

$ git config core.safecrlf
<no output>

@kynan
Copy link
Owner

kynan commented May 10, 2020

I don't have access to a Windows system to reproduce this and I don't have a good idea what might cause this behaviour and if it's working as intended or not.

Does nbstripout change this behavious i.e. when you change a notebook without having nbstripout installed and then git add it, does git diff --cached show the ^M?

@kynan
Copy link
Owner

kynan commented Jun 28, 2020

@amard33p any update on this?

@amard33p
Copy link

amard33p commented Jun 29, 2020

@amard33p any update on this?

@kynan Sorry this was quite a while back. I have since switched Google Colab for Jupyter notebooks. It serves my purpose.
#126 looks promising though...can't verify it.

@kynan
Copy link
Owner

kynan commented Jun 30, 2020

@ooiM has this been addressed by #126? Can we close this?

@ooiM
Copy link
Contributor

ooiM commented Jun 30, 2020

@kynan Yes, I think the problem was solved.

@kynan kynan closed this as completed Jun 30, 2020
@kynan kynan added resolution:fixed and removed help wanted state:waiting Waiting for response for reporter labels Jun 30, 2020
@kynan kynan added this to the 0.3.8 milestone Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants