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

space chars at start of .gitignore #878

Closed
gtors opened this issue May 30, 2021 · 3 comments · Fixed by #880
Closed

space chars at start of .gitignore #878

gtors opened this issue May 30, 2021 · 3 comments · Fixed by #880

Comments

@gtors
Copy link
Contributor

gtors commented May 30, 2021

If .gitignore starts with 20 20 0a (in hex), then dulwich will read it as Pattern(b"", False)

image

So, this cause some strange bug for me, for example my dir app/web become ignorable, but in reality it is not.

In my case, dulwich was used as dependency of DVC tool (https://github.com/iterative/dvc/blob/7700d555296e52564dd27d767406104c994e42c1/dvc/scm/git/backend/dulwich.py#L281)

Seems, that function doesn't handle situation than line contains only space chars https://github.com/dulwich/dulwich/blob/76dd8356f9d8870f44226e4232c24fbc1e573e93/dulwich/ignore.py#L114-L140

@gtors
Copy link
Contributor Author

gtors commented May 30, 2021

line = b"  \n"
line.rstrip(b"\r\n") 

line will be b" " here

@jelmer
Copy link
Owner

jelmer commented Jun 4, 2021

Any chance you can add a test case for this to dulwich/tests/test_ignore.py ? that should be fairly straightforward to do; a proper fix would also be great, but I'm also happy to take it from there.

@gtors
Copy link
Contributor Author

gtors commented Jun 8, 2021

Ok, I will try.

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 a pull request may close this issue.

2 participants