Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 4 commits into from
Feb 27, 2018
Merged

Conversation

ethomson
Copy link
Member

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).

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;
Copy link
Member Author

@ethomson ethomson Feb 24, 2018

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

@ethomson
Copy link
Member Author

Well apparently in making this work on win32, I broke this on linux. 🙄 I'll take a look at this tomorrow.

@ethomson
Copy link
Member Author

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.

@ethomson
Copy link
Member Author

ethomson commented Feb 24, 2018

1) Failure: online::clone::ssh_auth_methods [/home/travis/build/libgit2/libgit2/tests/online/clone.c:434]
   Function call failed: (git_clone(&g_repo, "ssh://github.com/libgit2/TestGitRepository", "./foo", &g_options))
   error -1 (expected -7) - failed to start SSH session: Unable to exchange encryption keys

2) Failure: online::clone::certificate_invalid [/home/travis/build/libgit2/libgit2/tests/online/clone.c:637]
  Function call failed: (GIT_ECERTIFICATE)
  error -17 (expected -1) - failed to start SSH session: Unable to exchange encryption keys

Copy link
Contributor

@tiennou tiennou left a 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 !

@ethomson
Copy link
Member Author

No need to thank me, @tiennou - you did all the investigation, I just made it work on Windows. :D

@ethomson ethomson merged commit c9d59c6 into master Feb 27, 2018
@pks-t pks-t mentioned this pull request Feb 28, 2018
@ethomson ethomson deleted the ethomson/checkout_filemode branch October 26, 2018 13:37
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 this pull request may close these issues.

2 participants