fix: Probe executable bits by checking if we can change them #2284
+18
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After resolving jj-vcs/jj#3949 via jj-vcs/jj#7484, I realized that
jj git initdiffers fromgit initand still causes issues with executable bits.The problem is that
jj git initsets up the.git/configfile withcore.filemode = true, despite file modes not being modifiable. Following the code, the reason is thatjjuses the default file capabilities from gitoxide when initializing the repo, and gitoxide sets the capabilities by probing the filesystem. However, the probe for executable bits only tests whether the executable bit can be set when a file is created, but not whether it can be modified.This PR changes the filemode probe to also verify that the executable bit can be modified. I tried to do so by changing as little surrounding code as possible.
The equivalent test by git itself for
git initis here:https://github.com/git/git/blob/f0ef5b6d9bcc258e4cbef93839d1b7465d5212b9/setup.c#L2367-L2379