-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
The stat() method should not be dependent on the core.symlinks config entry #220
Conversation
If symlink support is disabled, stat() should behave the same way as it did in previous versions. That's why we need this extra check (and use lstat() instead). |
In addition to the above: Look at the code of the 2.4.0.1 tag:
In 2.4.0.1: The contract for stat() and lstat() was absolutely correct! In master this is no longer the case! I know that making git symlink work was a pain in the butt, but that doesn't mean there aren't any issues. The problem is that mingw functions shouldn't be affected by the fact that git is configured to use symlinks or not. Now, stat() behaves differently if core.symlinks is set or not. |
@kblees When I read this, at first it made complete sense. But then I checked the documentation:
In other words, Git's documentation promises to change behavior based on And indeed, on Linux the behavior of Based on these observations, I tend to agree that it would be a good idea to change @kblees do you agree with this line of reasoning? |
I might have found this issue if it had been referenced by this PR.
That Following the symlink is implemented by opening the file with |
This couldn't have worked before because If |
@kblees, sorry for being harsh on this one, my apologies. For me, do_stat_internal has always worked. That might be because I'm always working with admin-rights. I never checked if it worked without them. |
The contract for the stat() and lstat() function is: > stat(): stats the file pointed to by path and fills in buf. > lstat(): is identical to stat(), except that if path is a symbolic link, > then the link itself is stat-ed, not the file that it refers to. stat() should always return the statistics of the file or directory a symbolic link is pointing to. The lstat() function is used to get the stats for the symlink. Hence the check should not be there. Signed-off-by: Loris Chiocca <loris@chiocca.ch>
@lchiocca could you check without admin rights? That would be truly helpful. As to v2.4.0.1: as pointed out by @kblees, |
@dscho, @kblees: Double-checked. It works without admin rights in my case. But just as a reminder, I'm not using symlinks in the workspace, but within the .git folder. I've got multiple branches (i.e. folders) of the same repo that share the same git repo (using the git-new-workdir). That was the original issue. stat() wasn't working because of symlinks inside the .git folder. |
@kblees how about using |
It didn't...it just returned symlinks as regular files or directories, with |
MSDN docs for CreateFile say this: "Appropriate security checks still apply when this flag is used without SE_BACKUP_NAME and SE_RESTORE_NAME privileges." This could mean that it works without the privileges if the user's permissions match the requested permissions (the CreateFile call here uses dwDesiredAccess == 0, to require absolute minimum permissions). However, I'm not really sure if my interpretation of the docs is correct (thus the extra code that tries to mimic the old behaviour). If you can confirm that opening the file works with end user permissions and on all platforms (including XP), and the test-suite passes with this, your change should be fine. ...and sorry for closing the issue so rashly, I didn't realize that this was in response to an existing issue. |
@kblees, no problems with closing the issue; I was kind of impolite to assume too much - "assumptions are the mothers of all f**kups" ;) I'll try my best to test it in different conditions, but I honestly don't think I'll be able to test winXP... I'm not even sure if I kept those iso. Maybe I can find some floppy images with the installation disks ;) |
@lchiocca no worries, I have VMs for XP 32-bit and 64-bit. I can test. We should make those tests part of the test suite anyway. |
@kblees are you referring to https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx ? If so, maybe you can help me understand it. The only mention of
I do not quite understand what that means, as I am usually not working with |
@dscho, that flag is really weird to understand. The best explanation I found is:
|
@lchiocca that's really useful, I think even I get it now. Thanks. |
@kblees with the successful testing of this PR by @rburgstaler, do you have any remaining objections against merging this? I would like to include it in Git for Windows 2.4.6. |
No, not at all. As I said, the extra code was just an (obviously unsuccessful) attempt to mimic old behaviour, in case the new variant causes problems. If we can fix bugs by removing code, so much the better. |
Perfect. Thanks, all! |
The stat() method should not be dependent on the core.symlinks config entry
…elper-2.24 test-gvfs-prococol, t5799: tests for gvfs-helper
…elper-2.24 test-gvfs-prococol, t5799: tests for gvfs-helper
…elper-2.24 test-gvfs-prococol, t5799: tests for gvfs-helper
Includes commits from these pull requests: git-for-windows#191 git-for-windows#205 git-for-windows#206 git-for-windows#207 git-for-windows#208 git-for-windows#215 git-for-windows#220 git-for-windows#221 Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Includes commits from these pull requests: git-for-windows#191 git-for-windows#205 git-for-windows#206 git-for-windows#207 git-for-windows#208 git-for-windows#215 git-for-windows#220 git-for-windows#221 Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Includes commits from these pull requests: git-for-windows#191 git-for-windows#205 git-for-windows#206 git-for-windows#207 git-for-windows#208 git-for-windows#215 git-for-windows#220 git-for-windows#221 Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Includes commits from these pull requests: git-for-windows#191 git-for-windows#205 git-for-windows#206 git-for-windows#207 git-for-windows#208 git-for-windows#215 git-for-windows#220 git-for-windows#221 Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Includes commits from these pull requests: git-for-windows#191 git-for-windows#205 git-for-windows#206 git-for-windows#207 git-for-windows#208 git-for-windows#215 git-for-windows#220 git-for-windows#221 Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Includes commits from these pull requests: git-for-windows#191 git-for-windows#205 git-for-windows#206 git-for-windows#207 git-for-windows#208 git-for-windows#215 git-for-windows#220 git-for-windows#221 Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
The contact for the stat() and lstat() function is:
stat() should always return the statistics of the file or directory a symbolic link is pointing to. The lstat() function is used to get the stats for the symlink. Hence the check should not be there.