checkout tests: don't use GetFinalPathNameByHandle To determine the canonical filename for a given path, we previously looked at the directory entries on POSIX systems and used GetFinalPathNameByHandle on Windows. However, GetFinalPathNameByHandle requires a HANDLE - the results of CreateFile - and you cannot CreateFile on a symbolic link. To support finding the canonical path of a symbolic link, simply use the existing POSIX code to look at the directory entries.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
diff --git a/tests/checkout/icase.c b/tests/checkout/icase.c
index 560c1ad..d804d08 100644
--- a/tests/checkout/icase.c
+++ b/tests/checkout/icase.c
@@ -44,29 +44,6 @@ void test_checkout_icase__cleanup(void)
static char *get_filename(const char *in)
{
-#ifdef GIT_WIN32
- HANDLE fh;
- HMODULE kerneldll;
- char *filename;
-
- typedef DWORD (__stdcall *getfinalpathname)(HANDLE, LPSTR, DWORD, DWORD);
- getfinalpathname getfinalpathfn;
-
- cl_assert(filename = malloc(MAX_PATH));
- cl_assert(kerneldll = LoadLibrary("kernel32.dll"));
- cl_assert(getfinalpathfn = (getfinalpathname)GetProcAddress(kerneldll, "GetFinalPathNameByHandleA"));
-
- cl_assert(fh = CreateFileA(in, FILE_READ_ATTRIBUTES | STANDARD_RIGHTS_READ, FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL));
-
- cl_win32_pass(getfinalpathfn(fh, filename, MAX_PATH, VOLUME_NAME_DOS));
-
- CloseHandle(fh);
-
- git_path_mkposix(filename);
-
- return filename;
-#else
char *search_dirname, *search_filename, *filename = NULL;
git_buf out = GIT_BUF_INIT;
DIR *dir;
@@ -92,7 +69,6 @@ static char *get_filename(const char *in)
git_buf_dispose(&out);
return filename;
-#endif
}
static void assert_name_is(const char *expected)