{"thread":{"id":"49818","subject":"[PATCH 0/1] mingw: use CreateHardLink() directly","startedAt":"2018-11-13T14:37:04Z","lastAt":"2018-11-13T14:37:05Z","messageCount":2,"participants":["Johannes Schindelin via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"363155","messageId":"pull.77.git.gitgitgadget@gmail.com","threadId":"49818","inReplyTo":null,"subject":"[PATCH 0/1] mingw: use CreateHardLink() directly","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-13T14:37:01Z","receivedAt":"2018-11-13T14:37:04Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"This is another tidbit from the stash of Git for Windows' patches: it avoids\nloading the function address of CreateHardLink() at runtime. This was done\nin case we were running on a Windows version that does not support that\nfunction, but we no longer support any of these Windows versions.\n\nJohannes Schindelin (1):\n  mingw: use `CreateHardLink()` directly\n\n compat/mingw.c | 14 +-------------\n 1 file changed, 1 insertion(+), 13 deletions(-)\n\n\nbase-commit: 8858448bb49332d353febc078ce4a3abcc962efe\nPublished-As: https://github.com/gitgitgadget/git/releases/tags/pr-77%2Fdscho%2Fmingw-CreateHardLink-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-77/dscho/mingw-CreateHardLink-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/77\n-- \ngitgitgadget\n"},{"id":"363156","messageId":"b1fdce037c66b0dcfc36f7a8b0e231880962ccf4.1542119819.git.gitgitgadget@gmail.com","threadId":"49818","inReplyTo":"pull.77.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] mingw: use `CreateHardLink()` directly","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-13T14:37:02Z","receivedAt":"2018-11-13T14:37:05Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThe function `CreateHardLink()` is available in all supported Windows\nversions (even since Windows XP), so there is no more need to resolve it\nat runtime.\n\nHelped-by: Max Kirillov <max@max630.net>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c | 14 +-------------\n 1 file changed, 1 insertion(+), 13 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 3b44dd99d7..fdcf946275 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2084,24 +2084,12 @@ int mingw_raise(int sig)\n \n int link(const char *oldpath, const char *newpath)\n {\n-\ttypedef BOOL (WINAPI *T)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);\n-\tstatic T create_hard_link = NULL;\n \twchar_t woldpath[MAX_PATH], wnewpath[MAX_PATH];\n \tif (xutftowcs_path(woldpath, oldpath) < 0 ||\n \t\txutftowcs_path(wnewpath, newpath) < 0)\n \t\treturn -1;\n \n-\tif (!create_hard_link) {\n-\t\tcreate_hard_link = (T) GetProcAddress(\n-\t\t\tGetModuleHandle(\"kernel32.dll\"), \"CreateHardLinkW\");\n-\t\tif (!create_hard_link)\n-\t\t\tcreate_hard_link = (T)-1;\n-\t}\n-\tif (create_hard_link == (T)-1) {\n-\t\terrno = ENOSYS;\n-\t\treturn -1;\n-\t}\n-\tif (!create_hard_link(wnewpath, woldpath, NULL)) {\n+\tif (!CreateHardLinkW(wnewpath, woldpath, NULL)) {\n \t\terrno = err_win_to_posix(GetLastError());\n \t\treturn -1;\n \t}\n-- \ngitgitgadget\n"}]}