-
Notifications
You must be signed in to change notification settings - Fork 133
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
Teach git apply
to respect core.fileMode
#1555
Comments
Hey @dscho, I was trying to work on this issue but I couldn't find any instance in git/apply.c where file modes are explicitly changed/assigned except for when dealing with a new patch. Am I missing something or am I completely off? |
As mentioned in the description, adding a file is precisely the scenario we're talking about, yes. |
So, is the fix doing something like:
in all those places where where a new file mode is explicitly assigned? |
@Chand-ra in case |
So would doing something like this in the code snippet above suffice?
I am unsure of what exactly is it that we need to do here. Do we assert that the patch's new mode matches the file mode in the git index? |
That is exactly what I tried to say by "then ensuring that the file mode is unchanged in the Git index"
You can answer that question yourself by implementing a test case that only succeeds if the desired behavior is achieved. |
Hey @dscho I was trying to trigger the warning you mentioned in your original comment but couldn't do it. I initialized an empty Git folder on my (Windows) desktop -> added a What did seem to work though, was to create a folder with the same |
I came up with this script: #!/bin/sh
{ test ! -d apply-and-filemode || rm -rf apply-and-filemode; } &&
git init apply-and-filemode &&
cd apply-and-filemode &&
git commit -m initial --allow-empty &&
git config core.fileMode false &&
echo true >script.sh &&
git add --chmod=+x script.sh &&
git commit -m "Add script" &&
echo true >>script.sh &&
git commit -m "Modify script" script.sh &&
git format-patch -1 --stdout >patch &&
git switch -c branch HEAD^ &&
git apply patch Both on Windows and on Linux, running the script will show this line as last one in its output:
|
Hey @dscho, the patch corresponding to this issue was recently committed to the 'seen' branch so this issue can now be closed. |
I typically leave the tickets open until the patch entered |
@dscho the patch for this issue landed in |
Yes, indeed, thank you for keeping an eye on things @Chand-ra ! |
When applying a patch that adds an executable file,
git apply
ignores thecore.fileMode
setting. On Windows, where Git's idea of file mode bits makes no sense, it therefore spits out warnings like:This ticket, should you choose to accept it, is about teaching
git apply
to respect thecore.fileMode
setting and not even attempt tochmod()
any added files (or modified, if the diff wants to change the file mode).The text was updated successfully, but these errors were encountered: