-
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
Recusive Directory Junctions causes git clean -fd
to return a warning
#3358
Comments
This warning comes from the part of the code that enumerates which files are there, and what their respective status is (tracked, ignored, untracked). The underlying problem is that the reparse point cannot be resolved due to an infinite recursion. I have this tentative diff locally: diff --git a/compat/mingw.c b/compat/mingw.c
index cd046da97af..c9843fece4e 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -144,6 +144,7 @@ int err_win_to_posix(DWORD winerr)
case ERROR_WAIT_NO_CHILDREN: error = ECHILD; break;
case ERROR_WRITE_FAULT: error = EIO; break;
case ERROR_WRITE_PROTECT: error = EROFS; break;
+ case ERROR_CANT_RESOLVE_FILENAME: error = ELOOP; break;
}
return error;
} The problem is that
I am not quite sure how best to proceed from here. Currently, my favorite solution would involve introducing platform-specific |
BTW the problem has very little to do with the |
Honestly, the whole concept of mappping |
Agreed. Introducing an abstraction layer that does not assume that everything has a POSIX $ git grep 'errno = ' | wc -l
257 |
I have a similar issue when using pnpm (a nodejs package manager) with workspaces - which may be completely different. Can open another issue if needed. pnpm creates a symlinked structure (junctions on Windows) inside node_modules.
I'm not sure, whether the folder might look like "recursive" - directory enumeration above is not. However, most notably, "node_modules" is in .gitignore - |
That almost looks like a symlink loop, but then it ends in:
In any case, it is an awfully long path. I am just surprised that the error message suggests Now, it would be really interesting if you could build Git for Windows, patch You could also see whether my tentative |
I'm working on converting a big monorepo to pnpm and I have intentionally introduced cyclic symlinks (kinda like the above), and now hit this problem with Is there anything I can try here? Are the diffs provided above still accurate? |
Testing the "tentative diff" (#3358 (comment)), I get:
As expected, it seems. But, why does git walk down the entire loop? It doesn't behave like this on the same structure in Linux/macOS; the clean properly deletes the directory without recursing. It seems like this patch is just intending to change the error, but as noted in previous replies, it seems like it shouldn't be recursing at all. |
Also, going via WSL2 into the same dir behaves properly; so the symlink information and not recursing seems to work, but not in the windows version of git, it seems. |
I've been digging, and I think I've gotten to the root. I am not an expert in these syscalls, though, but just this fixes the problem for me: diff --git a/compat/win32/dirent.c b/compat/win32/dirent.c
index 87063101f5..3e543b51ef 100644
--- a/compat/win32/dirent.c
+++ b/compat/win32/dirent.c
@@ -19,7 +19,7 @@ static inline void finddata2dirent(struct dirent *ent, WIN32_FIND_DATAW *fdata)
/* Set file type, based on WIN32_FIND_DATA */
if ((fdata->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
- && fdata->dwReserved0 == IO_REPARSE_TAG_SYMLINK)
+ && fdata->dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)
ent->d_type = DT_LNK;
else if (fdata->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
ent->d_type = DT_DIR; |
I've sent #4383 with a test which shows the behavior change. I'm definitely interested in some expert opinions here. |
Setup
defaults?
to the issue you're seeing?
Not that I'm aware of
Details
Bash and CMD
Minimal, Complete, and Verifiable example
this will help us understand the issue.
Just the following output:
A warning appeared beforehand:
URL to that repository to help us with testing?
N/A
The text was updated successfully, but these errors were encountered: