Skip to content

Commit 9ac5f33

Browse files
committed
mingw: use CreateHardLink directly
It was observed that the current implementation of of get_proc_addr() fails to load the kernel32.dll with code ERROR_INVALID_PARAMETER. Probably the reason is that kernel32.dll is already loaded. The behavior was seen at Windows SP1, both 32bit and 64bit. Probably it would behave same way in some or all other Windows versions. This breaks all usages of "clone --local", including the automatic tests where they call it. The function CreateHardLink is available in all supported Windows versions (since Windows XP), so there is no more need to resolve it in runtime.
1 parent dbc8d81 commit 9ac5f33

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

compat/mingw.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "win32.h"
33
#include <conio.h>
44
#include <wchar.h>
5+
#include <windows.h>
56
#include <winioctl.h>
67
#include "../strbuf.h"
78
#include "../run-command.h"
@@ -2698,13 +2699,8 @@ int mingw_raise(int sig)
26982699

26992700
int link(const char *oldpath, const char *newpath)
27002701
{
2701-
DECLARE_PROC_ADDR(kernel32.dll, BOOL, CreateHardLinkW,
2702-
LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
27032702
wchar_t woldpath[MAX_LONG_PATH], wnewpath[MAX_LONG_PATH];
27042703

2705-
if (!INIT_PROC_ADDR(CreateHardLinkW))
2706-
return -1;
2707-
27082704
if (xutftowcs_long_path(woldpath, oldpath) < 0 ||
27092705
xutftowcs_long_path(wnewpath, newpath) < 0)
27102706
return -1;

0 commit comments

Comments
 (0)