-
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
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes #3753
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
แก้ไขข้อผิดพลาด "ร้ายแรง: ไม่สามารถล็อคการอ้างอิง ... ไม่ใช่ไดเรกทอรี"
(English: Fixes "Serious: References cannot be locked ... not directories" error. )
I amended the commit to add signed-off. |
Hmm. There seem to be a couple of problems:
That's the breakages from the |
b7095f3
to
7d8a8f8
Compare
Hello @dscho , |
From https://github.com/git-for-windows/git/runs/5883049437?check_suite_focus=true#step:5:1163:
I guess that there is code that actually relies on Do you have access to a WSL setup? You could debug this issue in there, as it obviously does not reproduce on Windows itself. |
@pgrmega do you? |
Hello, sorry, no, I hadn't have the time to search how to debug in a linux environment. |
I finally got around to spend some time on this, and it turns out that you found the right spot to fix this, but there was another spot, too. The way I debugged this was with one of the more tedious tools in my debugging toolbox: int x = 0;
fprintf(stderr, "current pid: %d\n", (int)getpid());
while (!x) {
sleep(1);
} I inserted this at the code site you had touched, ran the test script The |
FWIW I just submitted this patch to the Git mailing list for review: gitgitgadget#1291 |
@pgrmega could you test something for me? Could you apply this patch and tell me what it outputs when trying to tag? diff --git a/compat/mingw.c b/compat/mingw.c
index 2607de93af5..5bac330e56e 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -768,6 +768,7 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
wfilename[n] = L'\0';
attributes = GetFileAttributesW(wfilename);
wfilename[n] = c;
+error("attributes for '%ls': %ld, last error: %ld", wfilename, attributes, GetLastError());
if (attributes == FILE_ATTRIBUTE_DIRECTORY ||
attributes == FILE_ATTRIBUTE_DEVICE)
return 1; The problem I am trying to figure out is why we run into this code path, where Git thinks that there is a non-directory in the way, but there actually isn't. |
@pgrmega while I am still very interested in the output I asked for, I now have a hunch that I might have found the real fix. Could you also test this patch (replacing the one adding the diff --git a/compat/mingw.c b/compat/mingw.c
index 2607de93af5..2678302c6a9 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -768,8 +768,8 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
wfilename[n] = L'\0';
attributes = GetFileAttributesW(wfilename);
wfilename[n] = c;
- if (attributes == FILE_ATTRIBUTE_DIRECTORY ||
- attributes == FILE_ATTRIBUTE_DEVICE)
+ if (attributes & (FILE_ATTRIBUTE_DIRECTORY |
+ attributes == FILE_ATTRIBUTE_DEVICE))
return 1;
if (attributes == INVALID_FILE_ATTRIBUTES)
switch (GetLastError()) { |
This feels a little weird. Should this perhaps be something like this? if (attributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) |
D'oh. Of course! You're absolutely right, that's what I meant but failed to re-read properly when I tried to write it down. |
@dscho, is this still usefull that I test your patch ?
|
|
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
Fix when lazy caching of network shares tags directories were just created with previously-unhandled attributes
This fix for the issue : #3727
Use case :
Creation of a tag in the form "parent/child".
Exemple :
Context :
$ git --version --build-options
git version 2.35.1.windows.2
cpu: x86_64
built from commit: 5437f0f
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
$ cmd.exe /c ver
Microsoft Windows [Version 10.0.17763.2565]
Error :
fatal: cannot lock ref 'refs/tags/tagdir/mytag': unable to resolve reference 'refs/tags/tagdir/mytag': Not a directory
Problem analysis:
GetFileAttributesExW used in mingw_lstat function in git/compat/mingw.c can raise an error ERROR_PATH_NOT_FOUND.
In this case, the has_valid_directory_prefix is used to check if the parent directory exists.
So that, when the parent directory exists, mingw_lstat returns ENOTDIR.
ENOTDIR is not managed by the caller code (files_read_raw_ref in git/refs/files-backend.c).
It probably should.
Conclusion
This commit enables to take into account the case when ENOTDIR is returned by mingw_lstat.