-
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
Invalid path error during sparse checkout in versions newer than 2.24.0 #2777
Comments
This is not a bug. |
Maybe we need a note somewhere to clarify that sparse checkout will still check the validity of all filenames, and the excluding the reserved names from the checkout won't stop the error report of an invalid path. Side thought: While |
@rimrul I'm aware, but that's precisely why I chose to do a sparse checkout. To prevent git from trying to create these files. It shouldn't stop me in my tracks for something I'm not trying to do. In addition, the error message doesn't make it clear what's going on. It sounds as if it is still trying to create those files despite being excluded, and doesn't provide any guidance in case you know what you're doing. |
Honestly, I didn't read the issue carefully enough. It does indeed seem counter-intuitive to get these errors for files that shouldn't be part of the sparse checkout. |
@XXLuigiMario did you confirm that your Test with a non zip directory and file of appropriate names. (the Also, it maybe that Windows is "confusing" the zip file as being a directory for the checkout purposes. (I have not attempted to copy, clone, or test the repo..) |
@PhilipOakley Yes, I have created a test repo on a Linux machine as follows:
Cloned it on Windows and repeated the commands from the issue, replacing
Once disabled:
And the |
So, the Maybe the sparse checkout needs to be more cautious about where the protection happens. Maybe @derrickstolee has some insight on the sparse approach. |
I don't think this is a sparse-checkout issue, but instead it is just a Changing this behavior has the potential to re-introduce security problems, so it is not something I will recommend. Perhaps someone who really knows what is going on could look into it, but I doubt this is a good idea. |
Thanks for that clarification.
Worth a clarification to make sure everyone is on the same page about how the issues are handled (separate discussion) Looks like the docs need a tweak to clarify the index vs file system aspect:
Any change would also affect |
@PhilipOakley I would also suggest tweaking how this situation is presented to the user within git, currently it makes it seem like it is actually trying to create these paths (and failing) instead of a security feature. |
Maybe we could add a hint to sparse checkout if one of those 2 options is enabled, that there might be error messages about those files, even if they're excluded from checkout? |
I think this something should be done about it, even if it's just documentation. If you don't set "git config core.protectNTFS false", then you can't clone, change to a branch, or pull files from a branch that has these errors, with sparse checkout. It's fatal, it's not that there are just error messages, as @rimrul stated. |
This was indeed the case with my issue (above). I've spent about 2 days trying to resolve the issue. I whole hardheartedly suggest that something be changed to prevent this in the future. Either a warning to set core.protectNTFS when sparse-checkout is specified or similar an enhancement to remap bad filepaths. With the frequency of hit's I have seen suggesting core.sparse-checkout to fix the error, you would be well advised to re-open this issue or accept #2803. |
As @dscho went to great lengths to detail what would need to happen here without re-introducing a security issue, I would say that this is currently not meeting the bar for our effort at the moment. The best workaround is to not have these paths in your repo if you can avoid it. (I know we would have a difficult time making the case that torvalds/linux should rename their I'm investigating an area that may make this possible to work around in some cases but not 100% of the time. It just happens to be a side-effect of the much-more-important case that I'm handling. When that is ready I'll update this issue if that works to help this situation. |
* Update puppet-keystone from branch 'master' to 4d17fb5dfb39b9f0f78635ce7560ee5900d9ab8a - Merge "Remove a file which causes cloning on Windows platform to fail" - Remove a file which causes cloning on Windows platform to fail There is a known issue with git-for-windows and currently clone and pull fail with invalid path errors if the target repository has any filename containing a character prohibited in Windows. We can find below examples reporting that issue. git-for-windows/git#2777 git-for-windows/git#2803 git-for-windows/git#2849 Because it is unlikely that the issue is solved in git-for-windows shortly, this change drops one release note file currently causing the failure, as a quick workaround. Note that we can't rename existing release note files because that would make notes appear in a wrong release, and this is why this change should remove that file. Change-Id: Ib3615761b366ed849177ae79d7d105ef8b839da4
There is a known issue with git-for-windows and currently clone and pull fail with invalid path errors if the target repository has any filename containing a character prohibited in Windows. We can find below examples reporting that issue. git-for-windows/git#2777 git-for-windows/git#2803 git-for-windows/git#2849 Because it is unlikely that the issue is solved in git-for-windows shortly, this change drops one release note file currently causing the failure, as a quick workaround. Note that we can't rename existing release note files because that would make notes appear in a wrong release, and this is why this change should remove that file. Change-Id: Ib3615761b366ed849177ae79d7d105ef8b839da4
I don't know if it's the same issue, but the same error happens when the paths contain a backslash (which is normal on Windows), like this one for https://bibisect.libreoffice.org/win32-5.1
|
Unfortunately, that's the one 'special' character on the Linux/Posix side of Git. While some care is applied to try and correctly detect the 'isDir' character, it's best to avoid mixed usage if possible. |
I think there is a misunderstanding going on here. This path contains a directory whose name is This is important because on Linux, you can have such a directory, and you can have a But on Windows, directory names cannot contain backslash characters. Git is doing the right thing here to error out. |
I am very much sure that the repository was created on Windows. The files (and directories) for it were created on Windows, this is absolutely guaranteed (LibreOffice for Windows can only be built on Windows still). As such, I doubt very much that this repo contains some files/paths that are impossible on Windows. But since I'm not a git expert, I can't check what is in the metadata of this. Just sharing my thoughts :) |
But.... Git assumes Linux/Posix paths by default (it is the SCM for Linux, by design and intent), so Git for Windows is between a rock and a hard place on these issues. Sometimes you have to bite the bullet and focus on the common path 🥲 . |
@PhilipOakley :) Please note that issues are to identify and resolve problems, and I posted here to inform about a possible problem, to provide a way to check it (with the respective URL), and possibly to fix. I had workarounded it for myself using |
error: invalid path 'database/templates/forms/006-grap-money/6006a2401b055/image/bg.svg:Zone.Identifier' Receiving objects: 100% (3902/3902), 166.39 MiB | 1.17 MiB/s, done. |
@mikekaganski is it possible that the invalid path (I am talking about |
@Dheeraj-kumar1 this is indeed an invalid path. The |
Setup
defaults?
to the issue you're seeing?
Nothing special about the enviroment. Can reproduce on a fresh install.
However, the repository I'm working with contains a folder with filenames considered invalid on Windows (e.g
:
)Details
CMD
Minimal, Complete, and Verifiable example
this will help us understand the issue.
The repository would be checked out except for the folder
other.7z
, which contains filenames considered invalid on Windows.Works as expected if I downgrade to a version older than 2.25.0, such as 2.24.0 or 2.23.0.
git reports invalid path errors and doesn't check out the repository, despite the path being excluded by the sparse checkout
URL to that repository to help us with testing?
https://github.com/XXLuigiMario/gigaleak
EDIT: Found the origin of this issue, this is caused by the
core.protectNTFS
setting. Disabling it lets the checkout go through without issues. However, this is a bug because no problematic paths are involved in this checkout!The text was updated successfully, but these errors were encountered: