-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Windows Longpath support does not fully work? Error: "fatal: '$GIT_DIR' too big" #3372
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
Comments
That sounds like a catch-22: now, when Git wants to read the config, it has to open a long path. But it does not yet know whether it is supposed to support long paths. So it doesn't (which is the default). And therefore it can never read the config that tells it that it should turn on the long path support. |
Hmm, I think this is a general issue with paths > 260. Or am I doing something wrong? In the first example, the path is 230 chars long. Regardless of the passed parameters to the clone command, it is not possible to clone the repo:
Hint: The longpath setting is also set in my system git core settings. I think the define PATH_MAX is set for windows by limit.h to 260 and thus the longpath feature is prohibited As mentioned, the first example is something to show the general issue, the second example (nested submodules) is the real issue at our side. |
Okay, maybe now I got your point. I have removed some of the chars in the path of the first example and the clone is fine. I thought by setting the system git core settings, the default behavior for longpaths should have changed? How can I change the behavior otherwise? Anyhow, I still don't get how this is connected to the mentioned error message and the define? Is the function "setup_explicit_git_dir" not called when longpath is activated? |
Maybe my issue is a duplication of: #2075 |
The solution is probably a bit more involved than a casual contributor is prepared for. Currently, the way things are handled look like this: 5eb8d3a The strategy chosen is to have a platform-specific Before the config is read, the The way things should be done is via a function similar to I say similar to because we cannot use it. You see, if you call So what we would need is something akin to However, calling such a function would be wasteful because Git already calls So: the most appropriate solution to this would be to:
One particular complication with this entire plan is that As you probably suspect by now, this requires a lot more care and effort than you might originally have thought. Having said that, if you are interested, I can help you implement it. |
Thank you for your reply. |
…th on Windows with core.longpaths = true. This is a fix for issue: git-for-windows#3372 Use case: Allow git to checkout a repository or submodule in a directory with a long path when core.longpaths = true. Example: > ./git.exe config --global core.longpaths true > ./git.exe clone https://github.com/git/git.git --recurse-submodules \ /c/eval/git_test/loooooooooooooooooooooooooooooooooooooooooooooooooooooooo\ oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\ oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\ oooooooong Context: $ sh --version GNU bash, version 4.4.23(1)-release (x86_64-pc-msys) $ ./git.exe --version --build-options git version 2.36.1.windows.1 cpu: x86_64 built from commit: e2ff68a sizeof-long: 4 sizeof-size_t: 8 shell-path: /bin/sh feature: fsmonitor--daemon Error: fatal: '$GIT_DIR' too big. Problem analysis: setup_explicit_git_dir in setup.c uses PATH_MAX to check if the git dir is to long. On Windows PATH_MAX is set by limit.h to 260 and setup_explicit_git_dir ignores core.longpaths. Solution: The implementation is based on the solution proposed by Johannes Schindelin, see: git-for-windows#3372 (comment) * Refactor the part of trace2_initialize() that reads the config. * Make tr2_sysenv_cb() a public function. * No longer calling it from trace2_initialize(), but from a static callback function in common-main.c. * Calling read_very_early_config() explicitly in main(), with that static callback function that calls into tr2_sysenv_cb(). * Extend the static callback function for Windows, and parse core.longPaths in that function. * Extend startup_info struct in cache.h with 'int max_long_path' so we can use it in setup_explicit_git_dir instead of PATH_MAX. Signed-off-by: Kevin Worm <[email protected]>
…th on Windows with core.longpaths = true. This is a fix for issue: git-for-windows#3372 Use case: Allow git to checkout a repository or submodule in a directory with a long path when core.longpaths = true. Example: > ./git.exe config --global core.longpaths true > ./git.exe clone https://github.com/git/git.git --recurse-submodules \ /c/eval/git_test/loooooooooooooooooooooooooooooooooooooooooooooooooooooooo\ oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\ oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\ oooooooong Context: $ sh --version GNU bash, version 4.4.23(1)-release (x86_64-pc-msys) $ ./git.exe --version --build-options git version 2.36.1.windows.1 cpu: x86_64 built from commit: e2ff68a sizeof-long: 4 sizeof-size_t: 8 shell-path: /bin/sh feature: fsmonitor--daemon Error: fatal: '$GIT_DIR' too big. Problem analysis: setup_explicit_git_dir in setup.c uses PATH_MAX to check if the git dir is to long. On Windows PATH_MAX is set by limit.h to 260 and setup_explicit_git_dir ignores core.longpaths. Solution: The implementation is based on the solution proposed by Johannes Schindelin, see: git-for-windows#3372 (comment) * Refactor the part of trace2_initialize() that reads the config. * Make tr2_sysenv_cb() a public function. * No longer calling it from trace2_initialize(), but from a static callback function in common-main.c. * Calling read_very_early_config() explicitly in main(), with that static callback function that calls into tr2_sysenv_cb(). * Extend the static callback function for Windows, and parse core.longPaths in that function. * Extend startup_info struct in cache.h with 'int max_long_path' so we can use it in setup_explicit_git_dir instead of PATH_MAX. Signed-off-by: Kevin Worm <[email protected]>
Use case: Allow git to checkout a repository or submodule in a directory with a long path when core.longpaths = true. Example: > ./git.exe config --global core.longpaths true > ./git.exe clone https://github.com/git/git.git --recurse-submodules \ /c/eval/git_test/loooooooooooooooooooooooooooooooooooooooooooooooooooooooo\ oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\ oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\ oooooooong Context: $ sh --version GNU bash, version 4.4.23(1)-release (x86_64-pc-msys) $ ./git.exe --version --build-options git version 2.36.1.windows.1 cpu: x86_64 built from commit: e2ff68a sizeof-long: 4 sizeof-size_t: 8 shell-path: /bin/sh feature: fsmonitor--daemon Error: fatal: '$GIT_DIR' too big. Problem analysis: setup_explicit_git_dir in setup.c uses PATH_MAX to check if the git dir is to long. On Windows PATH_MAX is set by limit.h to 260 and setup_explicit_git_dir ignores core.longpaths. Solution: The implementation is based on the solution proposed by Johannes Schindelin, see: git-for-windows#3372 (comment) * Refactor the part of trace2_initialize() that reads the config. * Make tr2_sysenv_cb() a public function. * No longer calling it from trace2_initialize(), but from a static callback function in common-main.c. * Calling read_very_early_config() explicitly in main(), with that static callback function that calls into tr2_sysenv_cb(). * Extend the static callback function for Windows, and parse core.longPaths in that function. * Extend startup_info struct in cache.h with 'int max_long_path' so we can use it in setup_explicit_git_dir instead of PATH_MAX. This fixes git-for-windows#3372 Signed-off-by: Kevin Worm <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
Closing as stale. |
Setup
$ cmd.exe /c ver
Microsoft Windows [Version 10.0.18363.1679]
defaults?
** insert your commands here **
git clone -c core.longpaths=true https://github.com/git/git.git --recurse-submodules //?/D:/eval/Git_Test/looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
git clone -c core.longpaths=true --recurse-submodules //?/
All Repos with submodules are fetched recursively.
Error message: fatal: '$GIT_DIR' too big.
The error seems to point to a define (PATH_MAX) in setup.c code (https://github.com/git/git/blob/54e85e7af1ac9e9a92888060d6811ae767fea1bc/setup.c#L812)
Thus I am afraid the PATH_MAX is set to 260 for the installation already?
URL to that repository to help us with testing?
e.g. https://github.com/git/git.git
The text was updated successfully, but these errors were encountered: