-
-
Notifications
You must be signed in to change notification settings - Fork 937
improve index mode for executable files #1254
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
eb217db
to
14dd881
Compare
Thanks a lot! If the tests remain green we could certainly merge this one right away. Otherwise it should be possible to add a unit-tests without much fuzz which tests the function in question directly. Line 111 in eae0e37
It could be fed a few modes along with the desired output. Tests can be run locally with If you don't want to try a test just yet it could be merged without it, often I have unreasonable trust in the existing test suite. |
Thanks! FWIW, I tested manually via the following:
I goofed off a bit more today than I should have and didn't leave myself time to poke around with adding proper tests. If I can make some time in the next day or two to do that, I'll push them here. If you're okay to merge this before then, that's fine with me too. And maybe I'll still get around to adding tests later (though I can be bad about getting back to things). |
Something like that could be reproduced in the test system, but it's harder than it should be since shell execution isn't natively supported there. Instead I recommend calling the function directly on plain file modes that are created as literals in python itself. Let's see if you can get to it till the weekend, which is when I will merge this PR anyway :D. If it helps, adding it would prevent regression, something my shoddy memory won't prevent for sure 😅. Would you benefit from a new release after merge? |
The fix for gitpython-developers#430 in bebc4f5 (Use correct mode for executable files, 2016-05-19) is incomplete. It fails (in most cases) when files have modes which are not exactly 0644 or 0755. Git only cares whether the executable bit is set (or not). Ensure the mode we set for the index is either 100644 or 100755 based on whether the executable bit is set for the file owner. Do this similarly to how upstream git does it in cache.h¹. Add a test covering various file modes to help catch regressions. Fixes gitpython-developers#1253 ¹ https://github.com/git/git/blob/v2.31.1/cache.h#L247
1e1280d
to
1a04c15
Compare
Indeed, the code I pasted was only to show the method I used to test things, in case someone else ended up picking up the tests later. :) I'm also a fan of tests so I spent a little time this morning working on adding some. I tested locally with nostests with and without the code change. It fails before and passes after. I had some print statements in the test while working on it to confirm that the expected modes are correct. Let me know what needs improved with the test. I won't be surprised if I've overlooked some common pattern used in the test suite. If you'd prefer to have the test added in a separate commit (before or after the code fix) that's easy enough. I'm used to the git project where tests and fixes generally go together. When they don't, they'd add a test which is marked as an expected to fail and changed to expected to pass in the following commit with the code fix. |
That's perfect, thanks so much for the test! I am feeling much safer now. When it comes to the way the test is written I really am not picky, and I absolutely trust that the test will fail without the change. Will you benefit from an immediate release or can it wait? |
Excellent, thank you! This can absolutely wait. It's just a tightening of code that's been in place for 5 years without complaint, so I don't imagine many people run into it. :) |
As noted in #1253, this area could use some tests. Any help is appreciated there.