Skip to content

Commit 7b6875f

Browse files
committed
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 parent 3077126 commit 7b6875f

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

tests/checkout/icase.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,6 @@ void test_checkout_icase__cleanup(void)
4444

4545
static char *get_filename(const char *in)
4646
{
47-
#ifdef GIT_WIN32
48-
HANDLE fh;
49-
HMODULE kerneldll;
50-
char *filename;
51-
52-
typedef DWORD (__stdcall *getfinalpathname)(HANDLE, LPSTR, DWORD, DWORD);
53-
getfinalpathname getfinalpathfn;
54-
55-
cl_assert(filename = malloc(MAX_PATH));
56-
cl_assert(kerneldll = LoadLibrary("kernel32.dll"));
57-
cl_assert(getfinalpathfn = (getfinalpathname)GetProcAddress(kerneldll, "GetFinalPathNameByHandleA"));
58-
59-
cl_assert(fh = CreateFileA(in, FILE_READ_ATTRIBUTES | STANDARD_RIGHTS_READ, FILE_SHARE_READ,
60-
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL));
61-
62-
cl_win32_pass(getfinalpathfn(fh, filename, MAX_PATH, VOLUME_NAME_DOS));
63-
64-
CloseHandle(fh);
65-
66-
git_path_mkposix(filename);
67-
68-
return filename;
69-
#else
7047
char *search_dirname, *search_filename, *filename = NULL;
7148
git_buf out = GIT_BUF_INIT;
7249
DIR *dir;
@@ -92,7 +69,6 @@ static char *get_filename(const char *in)
9269
git_buf_dispose(&out);
9370

9471
return filename;
95-
#endif
9672
}
9773

9874
static void assert_name_is(const char *expected)

0 commit comments

Comments
 (0)