-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Respect core.filemode in checkout #4545
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
Add a new branch to the `testrepo` repository, where the `README` file has changed to executable. This branch enables typechange tests between the new `executable` branch and `master`.
Add two tests for filemode. The first ensures that `core.filemode=true` is honored: if we have changed the filemode such that a file that _was_ executable (mode 0755) is now executable (mode 0644) and we go to check out a branch that has otherwise changed the contents of the file, then we should raise a checkout conflict for that file. The second ensures that `core.filemode=false` is honored: in the same situation, we set a file that was executable to be non-executable, and check out the branch that changes the contents of the file. However, since `core.filemode` is false, we do not detect the filemode change. We run these tests on both operating systems that obey `core.filemode` (eg, POSIX) and those that have no conception of filemode (eg, Win32). This ensures that `core.filemode` is always honored, as it is a cache of the underlying filesystem's settings. This ensures that we do not make assumptions based on the operating system, and honor the configuration setting even if it were misconfigured.
Ensure that when examining the working directory for checkout that the mode is correctly simplified. Git only pays attention to whether a file is executable or not. When examining a working directory, we should coalesce modes in the working directory to either `0755` (indicating that a file is executable) or `0644` (indicating that it is not). Test this by giving the file an exotic mode, and ensuring that when checkout out a branch that changes the file's contents, that we do not have a checkout conflict.
if (a == S_IFLNK) | ||
a = GIT_FILEMODE_BLOB; | ||
if (b == S_IFLNK) | ||
b = GIT_FILEMODE_BLOB; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I anticipate these moving into a check for symlink functionality... But that's not ready yet
Well apparently in making this work on win32, I broke this on linux. 🙄 I'll take a look at this tomorrow. |
lololol, nope, it turns out GitHub's deprecation of TLS 1.2 broke our test suite, since we run on old Linux and old OpenSSL. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks for tackling it !
No need to thank me, @tiennou - you did all the investigation, I just made it work on Windows. :D |
I took #4506 and ran down some of the errors on Windows.
Ultimately, I tried to simplify it: first, I removed the arithmetic tests and replaced them with integration tests. The tests in #4506 are unlikely to fail unless there's a compiler problem... tests that validate our checkout functionality are more useful.
Instead, we investigate checking out files with changing modes on both systems that understand
core.filemode
(pretty much everybody) and those that do not (Windows).