-
Notifications
You must be signed in to change notification settings - Fork 316
.git subdirectory is created in the wrong place on checkout when using relative directory #359
Comments
I also tested it better, it's reproducible in Windows 7 with the same criterias |
I spotted the cause: mingw_chdir("S:/") fails in mingw.c I'm not sure how to do a patch without messing-up everything, anyway in 1.9.5 it worked correctly. |
@QbProg could you install the Git SDK -- unless you have it already -- and try out this patch? diff --git a/compat/mingw.c b/compat/mingw.c
index 8e1993f..d1baaeb 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -316,7 +316,7 @@ static void process_phantom_symlinks(void)
}
/* Normalizes NT paths as returned by some low-level APIs. */
-static wchar_t *normalize_ntpath(wchar_t *wbuf)
+static wchar_t *normalize_ntpath(wchar_t *wbuf, int keep_trailing_slashes)
{
int i;
/* fix absolute path prefixes */
@@ -338,8 +338,9 @@ static wchar_t *normalize_ntpath(wchar_t *wbuf)
if (wbuf[i] == '\\')
wbuf[i] = '/';
/* remove potential trailing slashes */
- while (i && wbuf[i - 1] == '/')
- wbuf[--i] = 0;
+ if (!keep_trailing_slashes)
+ while (i && wbuf[i - 1] == '/')
+ wbuf[--i] = 0;
return wbuf;
}
@@ -621,7 +622,7 @@ int mingw_chdir(const char *dirname)
CloseHandle(hnd);
}
- result = _wchdir(normalize_ntpath(wdirname));
+ result = _wchdir(normalize_ntpath(wdirname, 0));
current_directory_len = GetCurrentDirectoryW(0, NULL);
return result;
}
@@ -2290,7 +2291,7 @@ int readlink(const char *path, char *buf, size_t bufsiz)
* so convert to a (hopefully large enough) temporary buffer, then memcpy
* the requested number of bytes (including '\0' for robustness).
*/
- if ((len = xwcstoutf(tmpbuf, normalize_ntpath(wbuf), MAX_LONG_PATH)) < 0)
+ if ((len = xwcstoutf(tmpbuf, normalize_ntpath(wbuf, 1), MAX_LONG_PATH)) < 0)
return -1;
memcpy(buf, tmpbuf, min(bufsiz, len + 1));
return min(bufsiz, len); |
it seems not working. I don't know if it's correct but you could automatically avoid the trailing slash deletion only if the path is a root. You could check this using Win32 "PathIsRoot" (requires shlwapi) or else just check if |
This patch should solve the issue , but I didn't run the tests
|
I actually would really prefer to have a solution that does not depend on testing for the root directory. Are you sure that |
_wchdir("C:") fails, while _wchdir("C:") succeed. This is windows related I think. |
What about |
they work. Also _wchdir(L"C:/Windows") works because is not root the problem is exactly that normalize_ntpath removes the trailing slash. |
@QbProg yep, so I just mixed up my 0s and 1s, right? Could you please test my patch again (which would maybe also handle cases such as |
@dscho the patch with the 0 and 1 switched works! |
Thanks for testing! As to the network share, I will test that once I am done releasing 2.4.4.1. |
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@QbProg I am busy working toward a 3rd release candidate of Git for Windows 2.x which will include this fix. |
@QbProg could you please test the new Git for Windows 2.4.4.2? |
tested rc3 (git version 2.4.4.windows.2), it's fixed! thank you! |
Excellent! |
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes git-for-windows#210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is needed so that `_wchdir()` can be used with drive root directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory to the root directory). This fixes msysgit#359 (in Git for Windows 2.x only, though). Likewise, `readlink()`'s semantics require a trailing slash for symbolic links pointing to directories. Otherwise all checked out symbolic links pointing to directories would be marked as modified even directly after a fresh clone. This fixes #210 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Testing git for windows 2.4.3 2nd release candidate. I can reproduce it using Windows 8.1 64bit (on 2 pcs) , but not using Windows 7 64bit. Reproducing it only when calling from command prompt (not bash), and also using the eclipse debugger.
When calling a clone command like this
the .git directory is created inside local_dir\local_dir.git instead of local_dir.git
this happens only if local_dir is passed as a relative path AND if the current directory is the root of a drive. Using an absolute path it works:
since it was not easily reproducible I set-up the sdk and debugged the exe with eclipse. On a first glipse it seems that the current directory is not correctly restored in one of the intermediate clone steps. I hope to find the exact failure during next week.
probably chdir doesn't works correctly if you try to set back the directory to root ?
abspath.c:145 <--- maybe here?
The text was updated successfully, but these errors were encountered: