summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-11-18 09:23:58 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-11-18 09:23:58 (GMT)
commitc56aa1d2809b3aa160b2ee010508ccd0c52589c3 (patch)
treec64c2ac1b33a569f4a3e470ed6613d69c1dd750b /compat
parent744fad66c933ad5740e5f974a841d15c65d0246d (diff)
parent1e1a876bb2c895d59db8b7c8c4eb49ceef454bd3 (diff)
downloadgit-c56aa1d2809b3aa160b2ee010508ccd0c52589c3.zip
git-c56aa1d2809b3aa160b2ee010508ccd0c52589c3.tar.gz
git-c56aa1d2809b3aa160b2ee010508ccd0c52589c3.tar.bz2
Merge branch 'js/mingw-create-hard-link'
Windows update. * js/mingw-create-hard-link: mingw: use `CreateHardLink()` directly
Diffstat (limited to 'compat')
-rw-r--r--compat/mingw.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
index d2f4fab..14ef818 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -2211,24 +2211,12 @@ int mingw_raise(int sig)
int link(const char *oldpath, const char *newpath)
{
- typedef BOOL (WINAPI *T)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
- static T create_hard_link = NULL;
wchar_t woldpath[MAX_PATH], wnewpath[MAX_PATH];
if (xutftowcs_path(woldpath, oldpath) < 0 ||
xutftowcs_path(wnewpath, newpath) < 0)
return -1;
- if (!create_hard_link) {
- create_hard_link = (T) GetProcAddress(
- GetModuleHandle("kernel32.dll"), "CreateHardLinkW");
- if (!create_hard_link)
- create_hard_link = (T)-1;
- }
- if (create_hard_link == (T)-1) {
- errno = ENOSYS;
- return -1;
- }
- if (!create_hard_link(wnewpath, woldpath, NULL)) {
+ if (!CreateHardLinkW(wnewpath, woldpath, NULL)) {
errno = err_win_to_posix(GetLastError());
return -1;
}