{"thread":{"id":"51332","subject":"[PATCH 00/17] Fix MSVC support, at long last","startedAt":"2019-06-18T12:23:59Z","lastAt":"2019-06-25T17:51:00Z","messageCount":83,"participants":["Johannes Schindelin via GitGitGadget","Jeff Hostetler via GitGitGadget","Philip Oakley via GitGitGadget","Eric Sunshine","Carlo Arenas","Johannes Sixt","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":17},"messages":[{"id":"377389","messageId":"pull.149.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":null,"subject":"[PATCH 00/17] Fix MSVC support, at long last","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:23:55Z","receivedAt":"2019-06-18T12:23:59Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Philip Oakley and Jeff Hostetler worked quite a bit on getting Git to\ncompile with MS Visual C again, and this patch series is the culmination of\nthose efforts. With these patches, it is as easy as\n\nmake MSVC=1\n\nNote: the patches went through quite the number of iterations. For example,\nfor a long time we targeted Visual Studio 2015, and used NuGet packages for\nthe dependencies (such as OpenSSL, cURL, etc), while the current iteration\ntargets Visual Studio 2017 and uses vcpkg\n[https://docs.microsoft.com/en-us/cpp/vcpkg?view=vs-2017] for dependencies.\nHopefully I did not forget to remove any remnants of those previous\nversions.\n\nPlease also note that this patch series is part 1 of 3 in a bigger story:\nthe next patch series will add support to build Git in Microsoft Visual\nStudio, and the third patch series will add Continuous Testing by adding an\nMSVC build and a corresponding parallelized test job to our Azure Pipeline.\n\nJeff Hostetler (8):\n  cache-tree.c: avoid reusing the DEBUG constant\n  msvc: mark a variable as non-const\n  msvc: do not re-declare the timespec struct\n  msvc: define ftello()\n  msvc: fix detect_msys_tty()\n  msvc: support building Git using MS Visual C++\n  msvc: do not pretend to support all signals\n  msvc: ignore .dll and incremental compile output\n\nJohannes Schindelin (6):\n  Mark .bat files as requiring CR/LF endings\n  t0001 (mingw): do not expect a specific order of stdout/stderr\n  obstack: fix compiler warning\n  mingw: replace mingw_startup() hack\n  msvc: fix dependencies of compat/msvc.c\n  msvc: avoid debug assertion windows in Debug Mode\n\nPhilip Oakley (3):\n  msvc: include sigset_t definition\n  msvc: define O_ACCMODE\n  msvc: add pragmas for common warnings\n\n .gitattributes                     |   1 +\n .gitignore                         |   5 +\n Makefile                           |  42 ++++++-\n cache-tree.c                       |  14 +--\n compat/mingw.c                     | 100 +++++++++++++----\n compat/mingw.h                     |  24 ++--\n compat/msvc.h                      |  10 ++\n compat/obstack.h                   |   2 +-\n compat/vcbuild/.gitignore          |   3 +\n compat/vcbuild/README              |  51 +++++++++\n compat/vcbuild/find_vs_env.bat     | 169 +++++++++++++++++++++++++++++\n compat/vcbuild/scripts/clink.pl    |  41 ++++++-\n compat/vcbuild/vcpkg_copy_dlls.bat |  39 +++++++\n compat/vcbuild/vcpkg_install.bat   |  80 ++++++++++++++\n compat/winansi.c                   |  13 +++\n config.mak.uname                   |  79 ++++++++++++--\n git-compat-util.h                  |   9 ++\n t/t0001-init.sh                    |   3 +-\n 18 files changed, 628 insertions(+), 57 deletions(-)\n create mode 100644 compat/vcbuild/.gitignore\n create mode 100644 compat/vcbuild/find_vs_env.bat\n create mode 100644 compat/vcbuild/vcpkg_copy_dlls.bat\n create mode 100644 compat/vcbuild/vcpkg_install.bat\n\n\nbase-commit: b697d92f56511e804b8ba20ccbe7bdc85dc66810\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-149%2Fdscho%2Fmsvc-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-149/dscho/msvc-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/149\n-- \ngitgitgadget\n"},{"id":"377390","messageId":"b30429e0a498a7311701a9d7e40f4eccbc671c33.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 01/17] Mark .bat files as requiring CR/LF endings","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:23:56Z","receivedAt":"2019-06-18T12:24:00Z","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\nJust like the natural line ending for Unix shell scripts consist of a\nsingle Line Feed, the natural line ending for (DOS) Batch scripts\nconsists of a Carriage Return followed by a Line Feed.\n\nIt seems that both Unix shell script interpreters and the interpreter\nfor Batch scripts (`cmd.exe`) are keen on seeing the \"right\" line\nendings.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .gitattributes | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/.gitattributes b/.gitattributes\nindex 9fa72ad450..b08a1416d8 100644\n--- a/.gitattributes\n+++ b/.gitattributes\n@@ -5,6 +5,7 @@\n *.pl eof=lf diff=perl\n *.pm eol=lf diff=perl\n *.py eol=lf diff=python\n+*.bat eol=crlf\n /Documentation/**/*.txt eol=lf\n /command-list.txt eol=lf\n /GIT-VERSION-GEN eol=lf\n-- \ngitgitgadget\n\n"},{"id":"377391","messageId":"47105b63503b84be2769186db95be2d45d81577d.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 05/17] mingw: replace mingw_startup() hack","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:23:59Z","receivedAt":"2019-06-18T12:24:03Z","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\nGit for Windows has special code to retrieve the command-line parameters\n(and even the environment) in UTF-16 encoding, so that they can be\nconverted to UTF-8. This is necessary because Git for Windows wants to\nuse UTF-8 encoded strings throughout its code, and the main() function\ndoes not get the parameters in that encoding.\n\nTo do that, we used the __wgetmainargs() function, which is not even a\nWin32 API function, but provided by the MINGW \"runtime\" instead.\n\nObviously, this method would not work with any compiler other than GCC,\nand in preparation for compiling with Visual C++, we would like to avoid\nprecisely that.\n\nLucky us, there is a much more elegant way: we can simply implement the\nUTF-16 variant of `main()`: `wmain()`.\n\nTo make that work, we need to link with -municode. The command-line\nparameters are passed to `wmain()` encoded in UTF-16, as desired, and\nthis method also works with GCC, and also with Visual C++ after\nadjusting the MSVC linker flags to force it to use `wmain()`.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c   | 53 +++++++++++++++++++++++++++++++-----------------\n compat/mingw.h   | 22 ++++++++++----------\n config.mak.uname |  3 ++-\n 3 files changed, 47 insertions(+), 31 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 9b6d2400e1..0d8713e515 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2301,18 +2301,13 @@ static void setup_windows_environment(void)\n \t\tsetenv(\"TERM\", \"cygwin\", 1);\n }\n \n+#if !defined(_MSC_VER)\n /*\n  * Disable MSVCRT command line wildcard expansion (__getmainargs called from\n  * mingw startup code, see init.c in mingw runtime).\n  */\n int _CRT_glob = 0;\n-\n-typedef struct {\n-\tint newmode;\n-} _startupinfo;\n-\n-extern int __wgetmainargs(int *argc, wchar_t ***argv, wchar_t ***env, int glob,\n-\t\t_startupinfo *si);\n+#endif\n \n static NORETURN void die_startup(void)\n {\n@@ -2390,22 +2385,25 @@ static void maybe_redirect_std_handles(void)\n \t\t\t\t  GENERIC_WRITE, FILE_FLAG_NO_BUFFERING);\n }\n \n-void mingw_startup(void)\n+/*\n+ * We implement wmain() and compile with -municode, which would\n+ * normally ignore main(), but we call the latter from the former\n+ * so that we can handle non-ASCII command-line parameters\n+ * appropriately.\n+ *\n+ * To be more compatible with the core git code, we convert\n+ * argv into UTF8 and pass them directly to main().\n+ */\n+int wmain(int argc, const wchar_t **wargv)\n {\n-\tint i, maxlen, argc;\n-\tchar *buffer;\n-\twchar_t **wenv, **wargv;\n-\t_startupinfo si;\n+\tint i, maxlen, exit_status;\n+\tchar *buffer, **save;\n+\tconst char **argv;\n \n \ttrace2_initialize_clock();\n \n \tmaybe_redirect_std_handles();\n \n-\t/* get wide char arguments and environment */\n-\tsi.newmode = 0;\n-\tif (__wgetmainargs(&argc, &wargv, &wenv, _CRT_glob, &si) < 0)\n-\t\tdie_startup();\n-\n \t/* determine size of argv and environ conversion buffer */\n \tmaxlen = wcslen(wargv[0]);\n \tfor (i = 1; i < argc; i++)\n@@ -2415,9 +2413,16 @@ void mingw_startup(void)\n \tmaxlen = 3 * maxlen + 1;\n \tbuffer = malloc_startup(maxlen);\n \n-\t/* convert command line arguments and environment to UTF-8 */\n+\t/*\n+\t * Create a UTF-8 version of w_argv. Also create a \"save\" copy\n+\t * to remember all the string pointers because parse_options()\n+\t * will remove claimed items from the argv that we pass down.\n+\t */\n+\tALLOC_ARRAY(argv, argc + 1);\n+\tALLOC_ARRAY(save, argc + 1);\n \tfor (i = 0; i < argc; i++)\n-\t\t__argv[i] = wcstoutfdup_startup(buffer, wargv[i], maxlen);\n+\t\targv[i] = save[i] = wcstoutfdup_startup(buffer, wargv[i], maxlen);\n+\targv[i] = save[i] = NULL;\n \tfree(buffer);\n \n \t/* fix Windows specific environment settings */\n@@ -2436,6 +2441,16 @@ void mingw_startup(void)\n \n \t/* initialize Unicode console */\n \twinansi_init();\n+\n+\t/* invoke the real main() using our utf8 version of argv. */\n+\texit_status = main(argc, argv);\n+\n+\tfor (i = 0; i < argc; i++)\n+\t\tfree(save[i]);\n+\tfree(save);\n+\tfree(argv);\n+\n+\treturn exit_status;\n }\n \n int uname(struct utsname *buf)\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 593bdbffe6..210f1b01a8 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -562,18 +562,18 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen);\n extern CRITICAL_SECTION pinfo_cs;\n \n /*\n- * A replacement of main() that adds win32 specific initialization.\n+ * Git, like most portable C applications, implements a main() function. On\n+ * Windows, this main() function would receive parameters encoded in the\n+ * current locale, but Git for Windows would prefer UTF-8 encoded  parameters.\n+ *\n+ * To make that happen, we still declare main() here, and then declare and\n+ * implement wmain() (which is the Unicode variant of main()) and compile with\n+ * -municode. This wmain() function reencodes the parameters from UTF-16 to\n+ * UTF-8 format, sets up a couple of other things as required on Windows, and\n+ * then hands off to the main() function.\n  */\n-\n-void mingw_startup(void);\n-#define main(c,v) dummy_decl_mingw_main(void); \\\n-static int mingw_main(c,v); \\\n-int main(int argc, const char **argv) \\\n-{ \\\n-\tmingw_startup(); \\\n-\treturn mingw_main(__argc, (void *)__argv); \\\n-} \\\n-static int mingw_main(c,v)\n+int wmain(int argc, const wchar_t **w_argv);\n+int main(int argc, const char **argv);\n \n /*\n  * Used by Pthread API implementation for Windows\ndiff --git a/config.mak.uname b/config.mak.uname\nindex b71688eeb7..bf5d160ef4 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -401,7 +401,7 @@ ifeq ($(uname_S),Windows)\n \t\tcompat/win32/trace2_win32_process_info.o \\\n \t\tcompat/win32/dirent.o\n \tCOMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\\\".exe\\\"\n-\tBASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE\n+\tBASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE\n \tEXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj\n \tPTHREAD_LIBS =\n \tlib =\n@@ -548,6 +548,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tETAGS_TARGET = ETAGS\n \tNO_POSIX_GOODIES = UnfortunatelyYes\n \tDEFAULT_HELP_FORMAT = html\n+\tBASIC_LDFLAGS += -municode\n \tCOMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32\n \tCOMPAT_CFLAGS += -DSTRIP_EXTENSION=\\\".exe\\\"\n \tCOMPAT_OBJS += compat/mingw.o compat/winansi.o \\\n-- \ngitgitgadget\n\n"},{"id":"377392","messageId":"486297ec8c146e0ed47cd1dd8fe8f6496c2b54c2.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 03/17] cache-tree.c: avoid reusing the DEBUG constant","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:23:57Z","receivedAt":"2019-06-18T12:24:05Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nIn MSVC, the DEBUG constant is set automatically whenever compiling with\ndebug information.\n\nThis is clearly not what was intended in cache-tree.c, so let's use a less\nambiguous constant there.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n cache-tree.c | 14 +++++++-------\n 1 file changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/cache-tree.c b/cache-tree.c\nindex b13bfaf71e..706ffcf188 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -6,8 +6,8 @@\n #include \"object-store.h\"\n #include \"replace-object.h\"\n \n-#ifndef DEBUG\n-#define DEBUG 0\n+#ifndef DEBUG_CACHE_TREE\n+#define DEBUG_CACHE_TREE 0\n #endif\n \n struct cache_tree *cache_tree(void)\n@@ -111,7 +111,7 @@ static int do_invalidate_path(struct cache_tree *it, const char *path)\n \tint namelen;\n \tstruct cache_tree_sub *down;\n \n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \tfprintf(stderr, \"cache-tree invalidate <%s>\\n\", path);\n #endif\n \n@@ -398,7 +398,7 @@ static int update_one(struct cache_tree *it,\n \t\tstrbuf_addf(&buffer, \"%o %.*s%c\", mode, entlen, path + baselen, '\\0');\n \t\tstrbuf_add(&buffer, oid->hash, the_hash_algo->rawsz);\n \n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \t\tfprintf(stderr, \"cache-tree update-one %o %.*s\\n\",\n \t\t\tmode, entlen, path + baselen);\n #endif\n@@ -421,7 +421,7 @@ static int update_one(struct cache_tree *it,\n \n \tstrbuf_release(&buffer);\n \tit->entry_count = to_invalidate ? -1 : i - *skip_count;\n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \tfprintf(stderr, \"cache-tree update-one (%d ent, %d subtree) %s\\n\",\n \t\tit->entry_count, it->subtree_nr,\n \t\toid_to_hex(&it->oid));\n@@ -462,7 +462,7 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,\n \tstrbuf_add(buffer, path, pathlen);\n \tstrbuf_addf(buffer, \"%c%d %d\\n\", 0, it->entry_count, it->subtree_nr);\n \n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \tif (0 <= it->entry_count)\n \t\tfprintf(stderr, \"cache-tree <%.*s> (%d ent, %d subtree) %s\\n\",\n \t\t\tpathlen, path, it->entry_count, it->subtree_nr,\n@@ -536,7 +536,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)\n \t\tsize -= rawsz;\n \t}\n \n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \tif (0 <= it->entry_count)\n \t\tfprintf(stderr, \"cache-tree <%s> (%d ent, %d subtree) %s\\n\",\n \t\t\t*buffer, it->entry_count, subtree_nr,\n-- \ngitgitgadget\n\n"},{"id":"377393","messageId":"d551cdeafbf2953ba340aa16554fbd5ac6194a6e.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 02/17] t0001 (mingw): do not expect a specific order of stdout/stderr","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:23:57Z","receivedAt":"2019-06-18T12:24: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\nWhen redirecting stdout/stderr to the same file, we cannot guarantee\nthat stdout will come first.\n\nIn fact, in this test case, it seems that an MSVC build always prints\nstderr first.\n\nIn any case, this test case does not want to verify the *order* but\nthe *presence* of both outputs, so let's relax the test a little.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/t0001-init.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 77a224aafb..c7ab18f40f 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -474,7 +474,8 @@ test_expect_success MINGW 'redirect std handles' '\n \t\tGIT_REDIRECT_STDERR=\"2>&1\" \\\n \t\tgit rev-parse --git-dir --verify refs/invalid &&\n \tprintf \".git\\nfatal: Needed a single revision\\n\" >expect &&\n-\ttest_cmp expect output.txt\n+\tsort <output.txt >output.sorted &&\n+\ttest_cmp expect output.sorted\n '\n \n test_done\n-- \ngitgitgadget\n\n"},{"id":"377394","messageId":"e813075ade89380848bc7a9cb711cb52642ae4d5.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 09/17] msvc: mark a variable as non-const","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:24:01Z","receivedAt":"2019-06-18T12:24:06Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nVS2015 complains when using a const pointer in memcpy()/free().\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c | 5 ++++-\n 1 file changed, 4 insertions(+), 1 deletion(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 0d8713e515..d14d33308d 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1553,7 +1553,10 @@ static int try_shell_exec(const char *cmd, char *const *argv)\n \tif (prog) {\n \t\tint exec_id;\n \t\tint argc = 0;\n-\t\tconst char **argv2;\n+#ifndef _MSC_VER\n+\t\tconst\n+#endif\n+\t\tchar **argv2;\n \t\twhile (argv[argc]) argc++;\n \t\tALLOC_ARRAY(argv2, argc + 1);\n \t\targv2[0] = (char *)cmd;\t/* full path to the script file */\n-- \ngitgitgadget\n\n"},{"id":"377395","messageId":"2ed60dfffc26445cb3ee876bbde90916c24234c8.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 10/17] msvc: do not re-declare the timespec struct","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:24:02Z","receivedAt":"2019-06-18T12:24:08Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nVS2015's headers already declare that struct.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 210f1b01a8..a03e40e6e2 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -352,11 +352,13 @@ static inline int getrlimit(int resource, struct rlimit *rlp)\n #ifndef __MINGW64_VERSION_MAJOR\n #define off_t off64_t\n #define lseek _lseeki64\n+#ifndef _MSC_VER\n struct timespec {\n \ttime_t tv_sec;\n \tlong tv_nsec;\n };\n #endif\n+#endif\n \n struct mingw_stat {\n     _dev_t st_dev;\n-- \ngitgitgadget\n\n"},{"id":"377396","messageId":"250385d7a339c7fc6d1ee7183f44a7ab940bb194.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 06/17] msvc: fix dependencies of compat/msvc.c","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:23:59Z","receivedAt":"2019-06-18T12:24:08Z","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 file compat/msvc.c includes compat/mingw.c, which means that we have\nto recompile compat/msvc.o if compat/mingw.c changes.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n config.mak.uname | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex bf5d160ef4..3310f6284c 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -414,6 +414,8 @@ else\n \tBASIC_CFLAGS += -Zi -MDd\n endif\n \tX = .exe\n+\n+compat/msvc.o: compat/msvc.c compat/mingw.c GIT-CFLAGS\n endif\n ifeq ($(uname_S),Interix)\n \tNO_INITGROUPS = YesPlease\n-- \ngitgitgadget\n\n"},{"id":"377397","messageId":"037fbed117328dc89a0a7595c44f0c03acc78496.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 07/17] msvc: include sigset_t definition","fromName":"Philip Oakley via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:24:00Z","receivedAt":"2019-06-18T12:24:09Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: Philip Oakley <philipoakley@iee.org>\n\nOn MSVC (VS2008) sigset_t is not defined.\n\nSigned-off-by: Philip Oakley <philipoakley@iee.org>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/msvc.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/compat/msvc.h b/compat/msvc.h\nindex 29a8ce8204..04b4750b87 100644\n--- a/compat/msvc.h\n+++ b/compat/msvc.h\n@@ -18,6 +18,8 @@\n \n #undef ERROR\n \n+typedef int sigset_t;\n+\n #include \"compat/mingw.h\"\n \n #endif\n-- \ngitgitgadget\n\n"},{"id":"377398","messageId":"b23651a357db822aabb0b2e65dc962829a117645.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 08/17] msvc: define O_ACCMODE","fromName":"Philip Oakley via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:24:01Z","receivedAt":"2019-06-18T12:24:10Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: Philip Oakley <philipoakley@iee.org>\n\nThis constant is not defined in MSVC's headers.\n\nIn UCRT's fcntl.h, _O_RDONLY, _O_WRONLY and _O_RDWR are defined as 0, 1\nand 2, respectively. Yes, that means that UCRT breaks with the tradition\nthat O_RDWR == O_RDONLY | O_WRONLY.\n\nIt is a perfectly legal way to define those constants, though, therefore\nwe need to take care of defining O_ACCMODE accordingly.\n\nThis is particularly important in order to keep our \"open() can set\nerrno to EISDIR\" emulation working: it tests that (flags & O_ACCMODE) is\nnot identical to O_RDONLY before going on to test specifically whether\nthe file for which open() reported EACCES is, in fact, a directory.\n\nSigned-off-by: Philip Oakley <philipoakley@iee.org>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/msvc.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/compat/msvc.h b/compat/msvc.h\nindex 04b4750b87..d336d80670 100644\n--- a/compat/msvc.h\n+++ b/compat/msvc.h\n@@ -19,6 +19,8 @@\n #undef ERROR\n \n typedef int sigset_t;\n+/* open for reading, writing, or both (not in fcntl.h) */\n+#define O_ACCMODE     (_O_RDONLY | _O_WRONLY | _O_RDWR)\n \n #include \"compat/mingw.h\"\n \n-- \ngitgitgadget\n\n"},{"id":"377399","messageId":"bda1c270c1248fe947183bbb04cb7c55f3a74941.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 04/17] obstack: fix compiler warning","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:23:58Z","receivedAt":"2019-06-18T12:24:11Z","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\nMS Visual C suggests that the construct\n\n\tcondition ? (int) i : (ptrdiff_t) d\n\nis incorrect. Let's fix this by casting to ptrdiff_t also for the\npositive arm of the conditional.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/obstack.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/obstack.h b/compat/obstack.h\nindex ced94d0118..ae36ed6a66 100644\n--- a/compat/obstack.h\n+++ b/compat/obstack.h\n@@ -496,7 +496,7 @@ __extension__\t\t\t\t\t\t\t\t\\\n ( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk,\t\t\\\n   ((((h)->temp.tempint > 0\t\t\t\t\t\t\\\n     && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk))\t\\\n-   ? (int) ((h)->next_free = (h)->object_base\t\t\t\t\\\n+   ? (ptrdiff_t) ((h)->next_free = (h)->object_base\t\t\t\t\\\n \t    = (h)->temp.tempint + (char *) (h)->chunk)\t\t\t\\\n    : (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))\n \n-- \ngitgitgadget\n\n"},{"id":"377400","messageId":"1491ea4140518d76d4619fa2da7ec20250da1404.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 15/17] msvc: do not pretend to support all signals","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:24:05Z","receivedAt":"2019-06-18T12:24:13Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nThis special-cases various signals that are not supported on Windows,\nsuch as SIGPIPE. These cause the UCRT to throw asserts (at least in\ndebug mode).\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c | 26 ++++++++++++++++++++++++++\n 1 file changed, 26 insertions(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 667285887a..8b56aa5773 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2119,8 +2119,34 @@ int mingw_raise(int sig)\n \t\t\tsigint_fn(SIGINT);\n \t\treturn 0;\n \n+#if defined(_MSC_VER)\n+\t\t/*\n+\t\t * <signal.h> in the CRT defines 8 signals as being\n+\t\t * supported on the platform.  Anything else causes\n+\t\t * an \"Invalid signal or error\" (which in DEBUG builds\n+\t\t * causes the Abort/Retry/Ignore dialog).  We by-pass\n+\t\t * the CRT for things we already know will fail.\n+\t\t */\n+\t\t/*case SIGINT:*/\n+\tcase SIGILL:\n+\tcase SIGFPE:\n+\tcase SIGSEGV:\n+\tcase SIGTERM:\n+\tcase SIGBREAK:\n+\tcase SIGABRT:\n+\tcase SIGABRT_COMPAT:\n+\t\treturn raise(sig);\n+\tdefault:\n+\t\terrno = EINVAL;\n+\t\treturn -1;\n+\n+#else\n+\n \tdefault:\n \t\treturn raise(sig);\n+\n+#endif\n+\n \t}\n }\n \n-- \ngitgitgadget\n\n"},{"id":"377401","messageId":"831d603e2518894fe66b70089a296b5d11a9870f.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 16/17] msvc: avoid debug assertion windows in Debug Mode","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:24:06Z","receivedAt":"2019-06-18T12:24:14Z","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\nFor regular debugging, it is pretty helpful when a debug assertion in a\nrunning application triggers a window that offers to start the debugger.\n\nHowever, when running the test suite, it is not so helpful, in\nparticular when the debug assertions are then suppressed anyway because\nwe disable the invalid parameter checking (via invalidcontinue.obj, see\nthe comment in config.mak.uname about that object for more information).\n\nSo let's simply disable that window in Debug Mode (it is already\ndisabled in Release Mode).\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 8b56aa5773..cdb99b940e 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2438,6 +2438,10 @@ int wmain(int argc, const wchar_t **wargv)\n \ttrace2_initialize_clock();\n \n #ifdef _MSC_VER\n+#ifdef _DEBUG\n+\t_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);\n+#endif\n+\n #ifdef USE_MSVC_CRTDBG\n \t_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);\n #endif\n-- \ngitgitgadget\n\n"},{"id":"377402","messageId":"587cbcf61903693139ad4a02b32727bddd6d116d.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 13/17] msvc: support building Git using MS Visual C++","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:24:04Z","receivedAt":"2019-06-18T12:24:15Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nWith this patch, Git can be built using the Microsoft toolchain, via:\n\n\tmake MSVC=1 [DEBUG=1]\n\nThird party libraries are built from source using the open source\n\"vcpkg\" tool set. See https://github.com/Microsoft/vcpkg\n\nOn a first build, the vcpkg tools and the third party libraries are\nautomatically downloaded and built. DLLs for the third party libraries\nare copied to the top-level (and t/helper) directory to facilitate\ndebugging. See compat/vcbuild/README.\n\nA series of .bat files are invoked by the Makefile to find the location\nof the installed version of Visual Studio and the associated compiler\ntools (essentially replicating the environment setup performed by a\n\"Developer Command Prompt\"). This should find the most recent VS2015 or\nVS2017 installation. Output from these scripts are used by the Makefile\nto define compiler and linker pathnames and -I and -L arguments.\n\nThe build produces .pdb files for both debug and release builds.\n\nNote: This commit was squashed from an organic series of commits\ndeveloped between 2016 and 2018 in Git for Windows' `master` branch.\nThis combined commit eliminates the obsolete commits related to fetching\nNuGet packages for third party libraries. It is difficult to use NuGet\npackages for C/C++ sources because they may be built by earlier versions\nof the MSVC compiler and have CRT version and linking issues.\n\nAdditionally, the C/C++ NuGet packages that we were using tended to not\nbe updated concurrently with the sources.  And in the case of cURL and\nOpenSSL, this could expose us to security issues.\n\nHelped-by: Yue Lin Ho <b8732003@student.nsysu.edu.tw>\nHelped-by: Philip Oakley <philipoakley@iee.org>\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Makefile                           |  42 ++++++-\n compat/mingw.c                     |  12 ++\n compat/vcbuild/.gitignore          |   3 +\n compat/vcbuild/README              |  51 +++++++++\n compat/vcbuild/find_vs_env.bat     | 169 +++++++++++++++++++++++++++++\n compat/vcbuild/scripts/clink.pl    |  41 ++++++-\n compat/vcbuild/vcpkg_copy_dlls.bat |  39 +++++++\n compat/vcbuild/vcpkg_install.bat   |  80 ++++++++++++++\n config.mak.uname                   |  74 +++++++++++--\n git-compat-util.h                  |   9 ++\n 10 files changed, 504 insertions(+), 16 deletions(-)\n create mode 100644 compat/vcbuild/.gitignore\n create mode 100644 compat/vcbuild/find_vs_env.bat\n create mode 100644 compat/vcbuild/vcpkg_copy_dlls.bat\n create mode 100644 compat/vcbuild/vcpkg_install.bat\n\ndiff --git a/Makefile b/Makefile\nindex 8a7e235352..7777af7d0e 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1240,7 +1240,7 @@ endif\n \n ifdef SANE_TOOL_PATH\n SANE_TOOL_PATH_SQ = $(subst ','\\'',$(SANE_TOOL_PATH))\n-BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'\n+BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix \"$(SANE_TOOL_PATH_SQ)\"|'\n PATH := $(SANE_TOOL_PATH):${PATH}\n else\n BROKEN_PATH_FIX = '/^\\# @@BROKEN_PATH_FIX@@$$/d'\n@@ -2873,6 +2873,33 @@ install: all\n \t$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n \t$(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n \t$(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'\n+ifdef MSVC\n+\t# We DO NOT install the individual foo.o.pdb files because they\n+\t# have already been rolled up into the exe's pdb file.\n+\t# We DO NOT have pdb files for the builtin commands (like git-status.exe)\n+\t# because it is just a copy/hardlink of git.exe, rather than a unique binary.\n+\t$(INSTALL) git.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) git-shell.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) git-upload-pack.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) git-credential-store.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-daemon.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-fast-import.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-http-backend.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-http-fetch.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-http-push.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-imap-send.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-remote-http.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-remote-testsvn.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-sh-i18n--envsubst.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-show-index.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+ifndef DEBUG\n+\t$(INSTALL) $(vcpkg_rel_bin)/*.dll '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) $(vcpkg_rel_bin)/*.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+else\n+\t$(INSTALL) $(vcpkg_dbg_bin)/*.dll '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) $(vcpkg_dbg_bin)/*.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+endif\n+endif\n \t$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'\n \t$(INSTALL) -m 644 mergetools/* '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'\n@@ -3085,6 +3112,19 @@ endif\n \t$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS\n \t$(RM) GIT-USER-AGENT GIT-PREFIX\n \t$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT-PYTHON-VARS\n+ifdef MSVC\n+\t$(RM) $(patsubst %.o,%.o.pdb,$(OBJECTS))\n+\t$(RM) $(patsubst %.exe,%.pdb,$(OTHER_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.iobj,$(OTHER_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.ipdb,$(OTHER_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.pdb,$(PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.iobj,$(PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.ipdb,$(PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.pdb,$(TEST_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.iobj,$(TEST_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.ipdb,$(TEST_PROGRAMS))\n+\t$(RM) compat/vcbuild/MSVC-DEFS-GEN\n+endif\n \n .PHONY: all install profile-clean cocciclean clean strip\n .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex d14d33308d..667285887a 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2388,6 +2388,12 @@ static void maybe_redirect_std_handles(void)\n \t\t\t\t  GENERIC_WRITE, FILE_FLAG_NO_BUFFERING);\n }\n \n+#ifdef _MSC_VER\n+#ifdef _DEBUG\n+#include <crtdbg.h>\n+#endif\n+#endif\n+\n /*\n  * We implement wmain() and compile with -municode, which would\n  * normally ignore main(), but we call the latter from the former\n@@ -2405,6 +2411,12 @@ int wmain(int argc, const wchar_t **wargv)\n \n \ttrace2_initialize_clock();\n \n+#ifdef _MSC_VER\n+#ifdef USE_MSVC_CRTDBG\n+\t_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);\n+#endif\n+#endif\n+\n \tmaybe_redirect_std_handles();\n \n \t/* determine size of argv and environ conversion buffer */\ndiff --git a/compat/vcbuild/.gitignore b/compat/vcbuild/.gitignore\nnew file mode 100644\nindex 0000000000..8f8b794ef3\n--- /dev/null\n+++ b/compat/vcbuild/.gitignore\n@@ -0,0 +1,3 @@\n+/vcpkg/\n+/MSVC-DEFS-GEN\n+/VCPKG-DEFS\ndiff --git a/compat/vcbuild/README b/compat/vcbuild/README\nindex 60fd873fe8..81da36a93b 100644\n--- a/compat/vcbuild/README\n+++ b/compat/vcbuild/README\n@@ -1,3 +1,54 @@\n+The Steps to Build Git with VS2015 or VS2017 from the command line.\n+\n+1. Install the \"vcpkg\" open source package manager and build essential\n+   third-party libraries.  The steps for this have been captured in a\n+   set of convenience scripts.  These can be run from a stock Command\n+   Prompt or from an SDK bash window:\n+\n+   $ cd <repo_root>\n+   $ ./compat/vcbuild/vcpkg_install.bat\n+\n+   The vcpkg tools and all of the third-party sources will be installed\n+   in this folder:\n+      <repo_root>/compat/vcbuild/vcpkg/\n+\n+   A file will be created with a set of Makefile macros pointing to a\n+   unified \"include\", \"lib\", and \"bin\" directory (release and debug) for\n+   all of the required packages.  This file will be included by the main\n+   Makefile:\n+      <repo_root>/compat/vcbuild/MSVC-DEFS-GEN\n+\n+2. OPTIONALLY copy the third-party *.dll and *.pdb files into the repo\n+   root to make it easier to run and debug git.exe without having to\n+   manipulate your PATH.  This is especially true for debug sessions in\n+   Visual Studio.\n+\n+   Use ONE of the following forms which should match how you want to\n+   compile git.exe.\n+\n+   $ ./compat/vcbuild/vcpkg_copy_packages.bat debug\n+   $ ./compat/vcbuild/vcpkg_copy_packages.bat release\n+\n+3. Build git using MSVC from an SDK bash window using one of the\n+   following commands:\n+\n+   $ make MSVC=1\n+   $ make MSVC=1 DEBUG=1\n+\n+================================================================\n+\n+Alternatively, run `make MSVC=1 vcxproj` and then load the generated\n+git.sln in Visual Studio. The initial build will install the vcpkg\n+system and build the dependencies automatically. This will take a while.\n+\n+Note that this will automatically add and commit the generated\n+.sln and .vcxproj files to the repo.  You may want to drop this\n+commit before submitting a Pull Request....\n+\n+Or maybe we should put the .sln/.vcxproj files in the .gitignore file\n+and not do this.  I'm not sure.\n+\n+================================================================\n The Steps of Build Git with VS2008\n \n 1. You need the build environment, which contains the Git dependencies\ndiff --git a/compat/vcbuild/find_vs_env.bat b/compat/vcbuild/find_vs_env.bat\nnew file mode 100644\nindex 0000000000..1232f200f7\n--- /dev/null\n+++ b/compat/vcbuild/find_vs_env.bat\n@@ -0,0 +1,169 @@\n+@ECHO OFF\n+REM ================================================================\n+REM You can use either GCC (the default) or MSVC to build git\n+REM using the GIT-SDK command line tools.\n+REM        $ make\n+REM        $ make MSVC=1\n+REM\n+REM GIT-SDK BASH windows inherit environment variables with all of\n+REM the bin/lib/include paths for GCC.  It DOES NOT inherit values\n+REM for the corresponding MSVC tools.\n+REM\n+REM During normal (non-git) Windows development, you launch one\n+REM of the provided \"developer command prompts\" to set environment\n+REM variables for the MSVC tools.\n+REM\n+REM Therefore, to allow MSVC command line builds of git from BASH\n+REM and MAKE, we must blend these two different worlds.  This script\n+REM attempts to do that.\n+REM ================================================================\n+REM This BAT file starts in a plain (non-developer) command prompt,\n+REM searches for the \"best\" commmand prompt setup script, installs\n+REM it into the current CMD process, and exports the various MSVC\n+REM environment variables for use by MAKE.\n+REM\n+REM The output of this script should be written to a make \"include\n+REM file\" and referenced by the top-level Makefile.\n+REM\n+REM See \"config.mak.uname\" (look for compat/vcbuild/MSVC-DEFS-GEN).\n+REM ================================================================\n+REM The provided command prompts are custom to each VS release and\n+REM filled with lots of internal knowledge (such as Registry settings);\n+REM even their names vary by release, so it is not appropriate for us\n+REM to look inside them.  Rather, just run them in a subordinate\n+REM process and extract the settings we need.\n+REM ================================================================\n+REM\n+REM Current (VS2017 and beyond)\n+REM -------------------\n+REM Visual Studio 2017 introduced a new installation layout and\n+REM support for side-by-side installation of multiple versions of\n+REM VS2017.  Furthermore, these can all coexist with installations\n+REM of previous versions of VS (which have a completely different\n+REM layout on disk).\n+REM\n+REM VS2017 Update 2 introduced a \"vswhere.exe\" command:\n+REM https://github.com/Microsoft/vswhere\n+REM https://blogs.msdn.microsoft.com/heaths/2017/02/25/vswhere-available/\n+REM https://blogs.msdn.microsoft.com/vcblog/2017/03/06/finding-the-visual-c-compiler-tools-in-visual-studio-2017/\n+REM\n+REM VS2015\n+REM ------\n+REM Visual Studio 2015 uses the traditional VcVarsAll.\n+REM\n+REM Earlier Versions\n+REM ----------------\n+REM TODO\n+REM\n+REM ================================================================\n+REM Note: Throughout this script we use \"dir <path> && <cmd>\" rather\n+REM than \"if exist <path>\" because of script problems with pathnames\n+REM containing spaces.\n+REM ================================================================\n+\n+REM Sanitize PATH to prevent git-sdk paths from confusing \"wmic.exe\"\n+REM (called internally in some of the system BAT files).\n+SET PATH=%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;\n+\n+REM ================================================================\n+\n+:current\n+   SET vs_where=C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe\n+   dir \"%vs_where%\" >nul 2>nul && GOTO have_vs_where\n+   GOTO not_2017\n+\n+:have_vs_where\n+   REM Try to use VsWhere to get the location of VsDevCmd.\n+\n+   REM Keep VsDevCmd from cd'ing away.\n+   SET VSCMD_START_DIR=.\n+\n+   REM Get the root of the VS product installation.\n+   FOR /F \"usebackq tokens=*\" %%i IN (`\"%vs_where%\" -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath`) DO @SET vs_ip=%%i\n+\n+   SET vs_devcmd=%vs_ip%\\Common7\\Tools\\VsDevCmd.bat\n+   dir \"%vs_devcmd%\" >nul 2>nul && GOTO have_vs_devcmd\n+   GOTO not_2017\n+\n+:have_vs_devcmd\n+   REM Use VsDevCmd to setup the environment of this process.\n+   REM Setup CL for building 64-bit apps using 64-bit tools.\n+   @call \"%vs_devcmd%\" -no_logo -arch=x64 -host_arch=x64\n+\n+   SET tgt=%VSCMD_ARG_TGT_ARCH%\n+\n+   SET mn=%VCToolsInstallDir%\n+   SET msvc_includes=-I\"%mn%INCLUDE\"\n+   SET msvc_libs=-L\"%mn%lib\\%tgt%\"\n+   SET msvc_bin_dir=%mn%bin\\Host%VSCMD_ARG_HOST_ARCH%\\%tgt%\n+\n+   SET sdk_dir=%WindowsSdkDir%\n+   SET sdk_ver=%WindowsSDKVersion%\n+   SET si=%sdk_dir%Include\\%sdk_ver%\n+   SET sdk_includes=-I\"%si%ucrt\" -I\"%si%um\" -I\"%si%shared\"\n+   SET sl=%sdk_dir%lib\\%sdk_ver%\n+   SET sdk_libs=-L\"%sl%ucrt\\%tgt%\" -L\"%sl%um\\%tgt%\"\n+\n+   SET vs_ver=%VisualStudioVersion%\n+\n+   GOTO print_vars\n+\n+REM ================================================================\n+\n+:not_2017\n+   REM See if VS2015 is installed.\n+\n+   SET vs_2015_bat=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat\n+   dir \"%vs_2015_bat%\" >nul 2>nul && GOTO have_vs_2015\n+   GOTO not_2015\n+\n+:have_vs_2015\n+   REM Use VcVarsAll like the \"x64 Native\" command prompt.\n+   REM Setup CL for building 64-bit apps using 64-bit tools.\n+   @call \"%vs_2015_bat%\" amd64\n+\n+   REM Note that in VS2015 they use \"x64\" in some contexts and \"amd64\" in others.\n+   SET mn=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\\n+   SET msvc_includes=-I\"%mn%INCLUDE\"\n+   SET msvc_libs=-L\"%mn%lib\\amd64\"\n+   SET msvc_bin_dir=%mn%bin\\amd64\n+\n+   SET sdk_dir=%WindowsSdkDir%\n+   SET sdk_ver=%WindowsSDKVersion%\n+   SET si=%sdk_dir%Include\\%sdk_ver%\n+   SET sdk_includes=-I\"%si%ucrt\" -I\"%si%um\" -I\"%si%shared\" -I\"%si%winrt\"\n+   SET sl=%sdk_dir%lib\\%sdk_ver%\n+   SET sdk_libs=-L\"%sl%ucrt\\x64\" -L\"%sl%um\\x64\"\n+\n+   SET vs_ver=%VisualStudioVersion%\n+\n+   GOTO print_vars\n+\n+REM ================================================================\n+\n+:not_2015\n+   REM TODO....\n+   echo TODO support older versions of VS. >&2\n+   EXIT /B 1\n+\n+REM ================================================================\n+\n+:print_vars\n+   REM Dump the essential vars to stdout to allow the main\n+   REM Makefile to include it.  See config.mak.uname.\n+   REM Include DOS-style and BASH-style path for bin dir.\n+\n+   echo msvc_bin_dir=%msvc_bin_dir%\n+   SET X1=%msvc_bin_dir:C:=/C%\n+   SET X2=%X1:\\=/%\n+   echo msvc_bin_dir_msys=%X2%\n+\n+   echo msvc_includes=%msvc_includes%\n+   echo msvc_libs=%msvc_libs%\n+\n+   echo sdk_includes=%sdk_includes%\n+   echo sdk_libs=%sdk_libs%\n+\n+   echo vs_ver=%vs_ver%\n+\n+   EXIT /B 0\ndiff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl\nindex a87d0da512..c7b021bfac 100755\n--- a/compat/vcbuild/scripts/clink.pl\n+++ b/compat/vcbuild/scripts/clink.pl\n@@ -12,32 +12,62 @@\n use strict;\n my @args = ();\n my @cflags = ();\n+my @lflags = ();\n my $is_linking = 0;\n+my $is_debug = 0;\n while (@ARGV) {\n \tmy $arg = shift @ARGV;\n-\tif (\"$arg\" =~ /^-[DIMGO]/) {\n+\tif (\"$arg\" eq \"-DDEBUG\") {\n+\t    # Some vcpkg-based libraries have different names for release\n+\t    # and debug versions.  This hack assumes that -DDEBUG comes\n+\t    # before any \"-l*\" flags.\n+\t    $is_debug = 1;\n+\t}\n+\tif (\"$arg\" =~ /^-[DIMGOZ]/) {\n \t\tpush(@cflags, $arg);\n \t} elsif (\"$arg\" eq \"-o\") {\n \t\tmy $file_out = shift @ARGV;\n \t\tif (\"$file_out\" =~ /exe$/) {\n \t\t\t$is_linking = 1;\n+\t\t\t# Create foo.exe and foo.pdb\n \t\t\tpush(@args, \"-OUT:$file_out\");\n \t\t} else {\n+\t\t\t# Create foo.o and foo.o.pdb\n \t\t\tpush(@args, \"-Fo$file_out\");\n+\t\t\tpush(@args, \"-Fd$file_out.pdb\");\n \t\t}\n \t} elsif (\"$arg\" eq \"-lz\") {\n+\t    if ($is_debug) {\n+\t\tpush(@args, \"zlibd.lib\");\n+\t    } else{\n \t\tpush(@args, \"zlib.lib\");\n+\t    }\n \t} elsif (\"$arg\" eq \"-liconv\") {\n-\t\tpush(@args, \"iconv.lib\");\n+\t\tpush(@args, \"libiconv.lib\");\n \t} elsif (\"$arg\" eq \"-lcrypto\") {\n \t\tpush(@args, \"libeay32.lib\");\n \t} elsif (\"$arg\" eq \"-lssl\") {\n \t\tpush(@args, \"ssleay32.lib\");\n \t} elsif (\"$arg\" eq \"-lcurl\") {\n-\t\tpush(@args, \"libcurl.lib\");\n+\t\tmy $lib = \"\";\n+\t\t# Newer vcpkg definitions call this libcurl_imp.lib; Do we\n+\t\t# need to use that instead?\n+\t\tforeach my $flag (@lflags) {\n+\t\t\tif ($flag =~ /^-LIBPATH:(.*)/) {\n+\t\t\t\tforeach my $l (\"libcurl_imp.lib\", \"libcurl.lib\") {\n+\t\t\t\t\tif (-f \"$1/$l\") {\n+\t\t\t\t\t\t$lib = $l;\n+\t\t\t\t\t\tlast;\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t\tpush(@args, $lib);\n+\t} elsif (\"$arg\" eq \"-lexpat\") {\n+\t\tpush(@args, \"expat.lib\");\n \t} elsif (\"$arg\" =~ /^-L/ && \"$arg\" ne \"-LTCG\") {\n \t\t$arg =~ s/^-L/-LIBPATH:/;\n-\t\tpush(@args, $arg);\n+\t\tpush(@lflags, $arg);\n \t} elsif (\"$arg\" =~ /^-R/) {\n \t\t# eat\n \t} else {\n@@ -45,10 +75,11 @@\n \t}\n }\n if ($is_linking) {\n+\tpush(@args, @lflags);\n \tunshift(@args, \"link.exe\");\n } else {\n \tunshift(@args, \"cl.exe\");\n \tpush(@args, @cflags);\n }\n-#printf(\"**** @args\\n\");\n+printf(STDERR \"**** @args\\n\\n\\n\") if (!defined($ENV{'QUIET_GEN'}));\n exit (system(@args) != 0);\ndiff --git a/compat/vcbuild/vcpkg_copy_dlls.bat b/compat/vcbuild/vcpkg_copy_dlls.bat\nnew file mode 100644\nindex 0000000000..13661c14f8\n--- /dev/null\n+++ b/compat/vcbuild/vcpkg_copy_dlls.bat\n@@ -0,0 +1,39 @@\n+@ECHO OFF\n+REM ================================================================\n+REM This script is an optional step. It copies the *.dll and *.pdb\n+REM files (created by vcpkg_install.bat) into the top-level directory\n+REM of the repo so that you can type \"./git.exe\" and find them without\n+REM having to fixup your PATH.\n+REM\n+REM NOTE: Because the names of some DLL files change between DEBUG and\n+REM NOTE: RELEASE builds when built using \"vcpkg.exe\", you will need\n+REM NOTE: to copy up the corresponding version.\n+REM ================================================================\n+\n+\tSETLOCAL EnableDelayedExpansion\n+\n+\t@FOR /F \"delims=\" %%D IN (\"%~dp0\") DO @SET cwd=%%~fD\n+\tcd %cwd%\n+\n+\tSET arch=x64-windows\n+\tSET inst=%cwd%vcpkg\\installed\\%arch%\n+\n+\tIF [%1]==[release] (\n+\t\techo Copying RELEASE mode DLLs to repo root...\n+\t) ELSE IF [%1]==[debug] (\n+\t\tSET inst=%inst%\\debug\n+\t\techo Copying DEBUG mode DLLs to repo root...\n+\t) ELSE (\n+\t\techo ERROR: Invalid argument.\n+\t\techo Usage: %~0 release\n+\t\techo Usage: %~0 debug\n+\t\tEXIT /B 1\n+\t)\n+\n+\txcopy /e/s/v/y %inst%\\bin\\*.dll ..\\..\\\n+\txcopy /e/s/v/y %inst%\\bin\\*.pdb ..\\..\\\n+\n+\txcopy /e/s/v/y %inst%\\bin\\*.dll ..\\..\\t\\helper\\\n+\txcopy /e/s/v/y %inst%\\bin\\*.pdb ..\\..\\t\\helper\\\n+\n+\tEXIT /B 0\ndiff --git a/compat/vcbuild/vcpkg_install.bat b/compat/vcbuild/vcpkg_install.bat\nnew file mode 100644\nindex 0000000000..ebd0bad242\n--- /dev/null\n+++ b/compat/vcbuild/vcpkg_install.bat\n@@ -0,0 +1,80 @@\n+@ECHO OFF\n+REM ================================================================\n+REM This script installs the \"vcpkg\" source package manager and uses\n+REM it to build the third-party libraries that git requires when it\n+REM is built using MSVC.\n+REM\n+REM [1] Install VCPKG.\n+REM     [a] Create <root>/compat/vcbuild/vcpkg/\n+REM     [b] Download \"vcpkg\".\n+REM     [c] Compile using the currently installed version of VS.\n+REM     [d] Create <root>/compat/vcbuild/vcpkg/vcpkg.exe\n+REM\n+REM [2] Install third-party libraries.\n+REM     [a] Download each (which may also install CMAKE).\n+REM     [b] Compile in RELEASE mode and install in:\n+REM         vcpkg/installed/<arch>/{bin,lib}\n+REM     [c] Compile in DEBUG mode and install in:\n+REM         vcpkg/installed/<arch>/debug/{bin,lib}\n+REM     [d] Install headers in:\n+REM         vcpkg/installed/<arch>/include\n+REM\n+REM [3] Create a set of MAKE definitions for the top-level\n+REM     Makefile to allow \"make MSVC=1\" to find the above\n+REM     third-party libraries.\n+REM     [a] Write vcpkg/VCPGK-DEFS\n+REM\n+REM https://blogs.msdn.microsoft.com/vcblog/2016/09/19/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows/\n+REM https://github.com/Microsoft/vcpkg\n+REM https://vcpkg.readthedocs.io/en/latest/\n+REM ================================================================\n+\n+\tSETLOCAL EnableDelayedExpansion\n+\n+\t@FOR /F \"delims=\" %%D IN (\"%~dp0\") DO @SET cwd=%%~fD\n+\tcd %cwd%\n+\n+\tdir vcpkg\\vcpkg.exe >nul 2>nul && GOTO :install_libraries\n+\n+\techo Fetching vcpkg in %cwd%vcpkg\n+\tgit.exe clone https://github.com/Microsoft/vcpkg vcpkg\n+\tIF ERRORLEVEL 1 ( EXIT /B 1 )\n+\n+\tcd vcpkg\n+\techo Building vcpkg\n+\tpowershell -exec bypass scripts\\bootstrap.ps1\n+\tIF ERRORLEVEL 1 ( EXIT /B 1 )\n+\n+\techo Successfully installed %cwd%vcpkg\\vcpkg.exe\n+\n+:install_libraries\n+\tSET arch=x64-windows\n+\n+\techo Installing third-party libraries...\n+\tFOR %%i IN (zlib expat libiconv openssl libssh2 curl) DO (\n+\t    cd %cwd%vcpkg\n+\t    IF NOT EXIST \"packages\\%%i_%arch%\" CALL :sub__install_one %%i\n+\t    IF ERRORLEVEL 1 ( EXIT /B 1 )\n+\t)\n+\n+:install_defines\n+\tcd %cwd%\n+\tSET inst=%cwd%vcpkg\\installed\\%arch%\n+\n+\techo vcpkg_inc=-I\"%inst%\\include\">VCPKG-DEFS\n+\techo vcpkg_rel_lib=-L\"%inst%\\lib\">>VCPKG-DEFS\n+\techo vcpkg_rel_bin=\"%inst%\\bin\">>VCPKG-DEFS\n+\techo vcpkg_dbg_lib=-L\"%inst%\\debug\\lib\">>VCPKG-DEFS\n+\techo vcpkg_dbg_bin=\"%inst%\\debug\\bin\">>VCPKG-DEFS\n+\n+\tEXIT /B 0\n+\n+\n+:sub__install_one\n+\techo     Installing package %1...\n+\n+\t.\\vcpkg.exe install %1:%arch%\n+\tIF ERRORLEVEL 1 ( EXIT /B 1 )\n+\n+\techo     Finished %1\n+\tgoto :EOF\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 3310f6284c..36237711c5 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -1,5 +1,9 @@\n # Platform specific Makefile tweaks based on uname detection\n \n+# Define NO_SAFESEH if you need MSVC/Visual Studio to ignore the lack of\n+# Microsoft's Safe Exception Handling in libraries (such as zlib).\n+# Typically required for VS2013+/32-bit compilation on Vista+ versions.\n+\n uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')\n uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')\n@@ -11,6 +15,19 @@ ifdef MSVC\n \t# avoid the MingW and Cygwin configuration sections\n \tuname_S := Windows\n \tuname_O := Windows\n+\n+\t# Generate and include makefile variables that point to the\n+\t# currently installed set of MSVC command line tools.\n+compat/vcbuild/MSVC-DEFS-GEN: compat/vcbuild/find_vs_env.bat\n+\t@\"$<\" | tr '\\\\' / >\"$@\"\n+include compat/vcbuild/MSVC-DEFS-GEN\n+\n+\t# See if vcpkg and the vcpkg-build versions of the third-party\n+\t# libraries that we use are installed.  We include the result\n+\t# to get $(vcpkg_*) variables defined for the Makefile.\n+compat/vcbuild/VCPKG-DEFS: compat/vcbuild/vcpkg_install.bat\n+\t@\"$<\"\n+include compat/vcbuild/VCPKG-DEFS\n endif\n \n # We choose to avoid \"if .. else if .. else .. endif endif\"\n@@ -356,6 +373,19 @@ endif\n ifeq ($(uname_S),Windows)\n \tGIT_VERSION := $(GIT_VERSION).MSVC\n \tpathsep = ;\n+\t# Assume that this is built in Git for Windows' SDK\n+\tifeq (MINGW32,$(MSYSTEM))\n+\t\tprefix = /mingw32\n+\telse\n+\t\tprefix = /mingw64\n+\tendif\n+\t# Prepend MSVC 64-bit tool-chain to PATH.\n+\t#\n+\t# A regular Git Bash *does not* have cl.exe in its $PATH. As there is a\n+\t# link.exe next to, and required by, cl.exe, we have to prepend this\n+\t# onto the existing $PATH.\n+\t#\n+\tSANE_TOOL_PATH ?= $(msvc_bin_dir_msys)\n \tHAVE_ALLOCA_H = YesPlease\n \tNO_PREAD = YesPlease\n \tNEEDS_CRYPTO_WITH_SSL = YesPlease\n@@ -368,11 +398,14 @@ ifeq ($(uname_S),Windows)\n \tNO_STRCASESTR = YesPlease\n \tNO_STRLCPY = YesPlease\n \tNO_MEMMEM = YesPlease\n-\t# NEEDS_LIBICONV = YesPlease\n-\tNO_ICONV = YesPlease\n+\tNEEDS_LIBICONV = YesPlease\n \tNO_STRTOUMAX = YesPlease\n \tNO_MKDTEMP = YesPlease\n-\tSNPRINTF_RETURNS_BOGUS = YesPlease\n+\tNO_INTTYPES_H = YesPlease\n+\t# VS2015 with UCRT claims that snprintf and friends are C99 compliant,\n+\t# so we don't need this:\n+\t#\n+\t#   SNPRINTF_RETURNS_BOGUS = YesPlease\n \tNO_SVN_TESTS = YesPlease\n \tRUNTIME_PREFIX = YesPlease\n \tHAVE_WPGMPTR = YesWeDo\n@@ -385,7 +418,6 @@ ifeq ($(uname_S),Windows)\n \tNO_REGEX = YesPlease\n \tNO_GETTEXT = YesPlease\n \tNO_PYTHON = YesPlease\n-\tBLK_SHA1 = YesPlease\n \tETAGS_TARGET = ETAGS\n \tNO_POSIX_GOODIES = UnfortunatelyYes\n \tNATIVE_CRLF = YesPlease\n@@ -394,24 +426,46 @@ ifeq ($(uname_S),Windows)\n \tCC = compat/vcbuild/scripts/clink.pl\n \tAR = compat/vcbuild/scripts/lib.pl\n \tCFLAGS =\n-\tBASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE\n+\tBASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE\n \tCOMPAT_OBJS = compat/msvc.o compat/winansi.o \\\n \t\tcompat/win32/path-utils.o \\\n \t\tcompat/win32/pthread.o compat/win32/syslog.o \\\n \t\tcompat/win32/trace2_win32_process_info.o \\\n \t\tcompat/win32/dirent.o\n-\tCOMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\\\".exe\\\"\n+\tCOMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\\\".exe\\\"\n \tBASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE\n-\tEXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj\n+\t# invalidcontinue.obj allows Git's source code to close the same file\n+\t# handle twice, or to access the osfhandle of an already-closed stdout\n+\t# See https://msdn.microsoft.com/en-us/library/ms235330.aspx\n+\tEXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib\n \tPTHREAD_LIBS =\n \tlib =\n+\tBASIC_CFLAGS += $(vcpkg_inc) $(sdk_includes) $(msvc_includes)\n+ifndef DEBUG\n+\tBASIC_CFLAGS += $(vcpkg_rel_lib)\n+else\n+\tBASIC_CFLAGS += $(vcpkg_dbg_lib)\n+endif\n+\tBASIC_CFLAGS += $(sdk_libs) $(msvc_libs)\n+\n+\t# Optionally enable memory leak reporting.\n+\t# BASIC_CLFAGS += -DUSE_MSVC_CRTDBG\n \tBASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1\n+\t# Always give \"-Zi\" to the compiler and \"-debug\" to linker (even in\n+\t# release mode) to force a PDB to be generated (like RelWithDebInfo).\n+\tBASIC_CFLAGS += -Zi\n+\tBASIC_LDFLAGS += -debug -Zf\n+\n+ifdef NO_SAFESEH\n+\tLDFLAGS += -SAFESEH:NO\n+endif\n+\n ifndef DEBUG\n-\tBASIC_CFLAGS += -GL -Os -MD\n-\tBASIC_LDFLAGS += -LTCG\n+\tBASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG\n+\tBASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP\n \tAR += -LTCG\n else\n-\tBASIC_CFLAGS += -Zi -MDd\n+\tBASIC_CFLAGS += -MDd -DDEBUG -D_DEBUG\n endif\n \tX = .exe\n \ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex cc0e7e9733..83be89de0a 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1,6 +1,15 @@\n #ifndef GIT_COMPAT_UTIL_H\n #define GIT_COMPAT_UTIL_H\n \n+#ifdef USE_MSVC_CRTDBG\n+/*\n+ * For these to work they must appear very early in each\n+ * file -- before most of the standard header files.\n+ */\n+#include <stdlib.h>\n+#include <crtdbg.h>\n+#endif\n+\n #define _FILE_OFFSET_BITS 64\n \n \n-- \ngitgitgadget\n\n"},{"id":"377403","messageId":"0cca8c3c68e848836606757745f20287a4fb96c9.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 14/17] msvc: add pragmas for common warnings","fromName":"Philip Oakley via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:24:05Z","receivedAt":"2019-06-18T12:24:15Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: Philip Oakley <philipoakley@iee.org>\n\nMSVC can be overzealous about some warnings. Disable them.\n\nSigned-off-by: Philip Oakley <philipoakley@iee.org>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/msvc.h | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/compat/msvc.h b/compat/msvc.h\nindex d7525cf61d..1d7a8c6145 100644\n--- a/compat/msvc.h\n+++ b/compat/msvc.h\n@@ -6,6 +6,10 @@\n #include <malloc.h>\n #include <io.h>\n \n+#pragma warning(disable: 4018) /* signed/unsigned comparison */\n+#pragma warning(disable: 4244) /* type conversion, possible loss of data */\n+#pragma warning(disable: 4090) /* 'function' : different 'const' qualifiers (ALLOC_GROW etc.)*/\n+\n /* porting function */\n #define inline __inline\n #define __inline__ __inline\n-- \ngitgitgadget\n\n"},{"id":"377404","messageId":"073dc01b1431b62255a2c258c479c8408123fc90.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 12/17] msvc: fix detect_msys_tty()","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:24:03Z","receivedAt":"2019-06-18T12:24:17Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nThe ntstatus.h header is only available in MINGW.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/winansi.c | 13 +++++++++++++\n 1 file changed, 13 insertions(+)\n\ndiff --git a/compat/winansi.c b/compat/winansi.c\nindex f4f08237f9..11cd9b82cc 100644\n--- a/compat/winansi.c\n+++ b/compat/winansi.c\n@@ -544,7 +544,20 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)\n #ifdef DETECT_MSYS_TTY\n \n #include <winternl.h>\n+\n+#if defined(_MSC_VER)\n+\n+typedef struct _OBJECT_NAME_INFORMATION\n+{\n+\tUNICODE_STRING Name;\n+\tWCHAR NameBuffer[0];\n+} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;\n+\n+#define ObjectNameInformation 1\n+\n+#else\n #include <ntstatus.h>\n+#endif\n \n static void detect_msys_tty(int fd)\n {\n-- \ngitgitgadget\n\n"},{"id":"377405","messageId":"0c7f5479bf6d88597a376d446a0673bf5d84a500.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 17/17] msvc: ignore .dll and incremental compile output","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:24:07Z","receivedAt":"2019-06-18T12:24:17Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nIgnore .dll files copied into the top-level directory.\nIgnore MSVC incremental compiler output files.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .gitignore | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/.gitignore b/.gitignore\nindex 2374f77a1a..ba0e52c4d1 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -226,6 +226,11 @@\n *.user\n *.idb\n *.pdb\n+*.ilk\n+*.iobj\n+*.ipdb\n+*.dll\n+.vs/\n /Debug/\n /Release/\n *.dSYM\n-- \ngitgitgadget\n"},{"id":"377406","messageId":"e6cd0028061d13c6ad03178e900085cb752f0603.1560860634.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH 11/17] msvc: define ftello()","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-18T12:24:03Z","receivedAt":"2019-06-18T12:24:18Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nIt is just called differently in MSVC's headers.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/msvc.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/compat/msvc.h b/compat/msvc.h\nindex d336d80670..d7525cf61d 100644\n--- a/compat/msvc.h\n+++ b/compat/msvc.h\n@@ -18,6 +18,8 @@\n \n #undef ERROR\n \n+#define ftello _ftelli64\n+\n typedef int sigset_t;\n /* open for reading, writing, or both (not in fcntl.h) */\n #define O_ACCMODE     (_O_RDONLY | _O_WRONLY | _O_RDWR)\n-- \ngitgitgadget\n\n"},{"id":"377465","messageId":"CAPig+cQaoRBnH0JrUwXTo1hSwjrZ1vJHewjCAkKPeCrRwo=P2w@mail.gmail.com","threadId":"51332","inReplyTo":"d551cdeafbf2953ba340aa16554fbd5ac6194a6e.1560860634.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 02/17] t0001 (mingw): do not expect a specific order of stdout/stderr","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-06-18T23:12:30Z","receivedAt":"2019-06-18T23:12:45Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Jun 18, 2019 at 8:24 AM Johannes Schindelin via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n> When redirecting stdout/stderr to the same file, we cannot guarantee\n> that stdout will come first.\n>\n> In fact, in this test case, it seems that an MSVC build always prints\n> stderr first.\n>\n> In any case, this test case does not want to verify the *order* but\n> the *presence* of both outputs, so let's relax the test a little.\n>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n> diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n> @@ -474,7 +474,8 @@ test_expect_success MINGW 'redirect std handles' '\n>         printf \".git\\nfatal: Needed a single revision\\n\" >expect &&\n> -       test_cmp expect output.txt\n> +       sort <output.txt >output.sorted &&\n> +       test_cmp expect output.sorted\n\nIt was quite surprising to see this sorting only 'output' but not\n'expect'. I see now that 'output' is already \"sorted\" (in that sense),\nbut it feels fragile. More robust would be to sort 'expect' as well:\n\n    printf \".git\\nfatal: Needed a single revision\\n\" | sort >expect &&\n\nThis would protect against the next person who modifies the 'printf'\ntesting on Unix and Windows/gcc and thinking all is well even though\nthe change might make the test fail for an MSVC build.\n"},{"id":"377466","messageId":"CAPig+cTXdz6s_cftPydKjtESz986s1xLQvwV8xPzYSR_xLK6Cg@mail.gmail.com","threadId":"51332","inReplyTo":"486297ec8c146e0ed47cd1dd8fe8f6496c2b54c2.1560860634.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 03/17] cache-tree.c: avoid reusing the DEBUG constant","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-06-18T23:14:14Z","receivedAt":"2019-06-18T23:14:28Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Jun 18, 2019 at 8:24 AM Jeff Hostetler via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n> In MSVC, the DEBUG constant is set automatically whenever compiling with\n> debug information.\n>\n> This is clearly not what was intended in cache-tree.c, so let's use a less\n> ambiguous constant there.\n\ns/constant/macro name/ would be clearer.\n\n> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n"},{"id":"377478","messageId":"CAPUEspi-G7abt-zuLbw0iuyXN0gtrM_6Vy6d+9f-=6FpRsoV4A@mail.gmail.com","threadId":"51332","inReplyTo":"486297ec8c146e0ed47cd1dd8fe8f6496c2b54c2.1560860634.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 03/17] cache-tree.c: avoid reusing the DEBUG constant","fromName":"Carlo Arenas","fromEmail":"carenas@gmail.com","sentAt":"2019-06-19T00:08:42Z","receivedAt":"2019-06-19T00:08:55Z","isPatch":true,"sender":{"key":"carenas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/76036?v=4"},"body":"shouldn't this also be a problem with builtin/blame.c?\n\nCarlo\n"},{"id":"377479","messageId":"CAPUEsphHXxa6xbckKym7Nbx_E6aOzJYL+5j=xXa0oe3BLMrtbQ@mail.gmail.com","threadId":"51332","inReplyTo":"587cbcf61903693139ad4a02b32727bddd6d116d.1560860634.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 13/17] msvc: support building Git using MS Visual C++","fromName":"Carlo Arenas","fromEmail":"carenas@gmail.com","sentAt":"2019-06-19T00:51:39Z","receivedAt":"2019-06-19T00:51:52Z","isPatch":true,"sender":{"key":"carenas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/76036?v=4"},"body":"On Tue, Jun 18, 2019 at 5:26 AM Jeff Hostetler via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n> diff --git a/compat/mingw.c b/compat/mingw.c\n> index d14d33308d..667285887a 100644\n> --- a/compat/mingw.c\n> +++ b/compat/mingw.c\n> @@ -2388,6 +2388,12 @@ static void maybe_redirect_std_handles(void)\n>                                   GENERIC_WRITE, FILE_FLAG_NO_BUFFERING);\n>  }\n>\n> +#ifdef _MSC_VER\n> +#ifdef _DEBUG\n\nwhy not use DEBUG instead (without the leading underscore), then you\ncould also drop the -D_DEBUG below\n\n...\n> +       # BASIC_CLFAGS += -DUSE_MSVC_CRTDBG\n\ntypo\n\nCarlo\n"},{"id":"377483","messageId":"CAPig+cRW+1dEUe1=7=5G-HziJOA2UpYVKsnMdBpkpcU6D8O95A@mail.gmail.com","threadId":"51332","inReplyTo":"1491ea4140518d76d4619fa2da7ec20250da1404.1560860634.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 15/17] msvc: do not pretend to support all signals","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-06-19T04:10:47Z","receivedAt":"2019-06-19T04:11:02Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Jun 18, 2019 at 8:24 AM Jeff Hostetler via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n> This special-cases various signals that are not supported on Windows,\n> such as SIGPIPE. These cause the UCRT to throw asserts (at least in\n> debug mode).\n>\n> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n> diff --git a/compat/mingw.c b/compat/mingw.c\n> @@ -2119,8 +2119,34 @@ int mingw_raise(int sig)\n> +#if defined(_MSC_VER)\n> +               /*\n> +                * <signal.h> in the CRT defines 8 signals as being\n> +                * supported on the platform.  Anything else causes\n> +                * an \"Invalid signal or error\" (which in DEBUG builds\n> +                * causes the Abort/Retry/Ignore dialog).  We by-pass\n> +                * the CRT for things we already know will fail.\n> +                */\n> +               /*case SIGINT:*/\n> +       case SIGILL:\n\nWhy is SIGINT commented out?\n\nAnd, the comment block seems over-indented.\n\n> +       case SIGFPE:\n> +       case SIGSEGV:\n> +       case SIGTERM:\n> +       case SIGBREAK:\n> +       case SIGABRT:\n> +       case SIGABRT_COMPAT:\n> +               return raise(sig);\n> +       default:\n> +               errno = EINVAL;\n> +               return -1;\n"},{"id":"377485","messageId":"40cfbb30-c632-54da-62d9-9b31bc878806@kdbg.org","threadId":"51332","inReplyTo":"CAPig+cQaoRBnH0JrUwXTo1hSwjrZ1vJHewjCAkKPeCrRwo=P2w@mail.gmail.com","subject":"Re: [PATCH 02/17] t0001 (mingw): do not expect a specific order of stdout/stderr","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2019-06-19T06:19:18Z","receivedAt":"2019-06-19T06:19:24Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 19.06.19 um 01:12 schrieb Eric Sunshine:\n> On Tue, Jun 18, 2019 at 8:24 AM Johannes Schindelin via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n>> diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n>> @@ -474,7 +474,8 @@ test_expect_success MINGW 'redirect std handles' '\n>>         printf \".git\\nfatal: Needed a single revision\\n\" >expect &&\n>> -       test_cmp expect output.txt\n>> +       sort <output.txt >output.sorted &&\n>> +       test_cmp expect output.sorted\n> \n> It was quite surprising to see this sorting only 'output' but not\n> 'expect'. I see now that 'output' is already \"sorted\" (in that sense),\n> but it feels fragile. More robust would be to sort 'expect' as well:\n> \n>     printf \".git\\nfatal: Needed a single revision\\n\" | sort >expect &&\n\nFollowing Dscho's recent objection elsewhere that tests tend to check\nfor much more than regressions, wouldn't it be logical to write these as\n\n\tgrep -F .git\" output.txt &&\n\ttest_i18n_grep \"Needed a single rev\" output.txt\n\nwithout an 'expect' file at all?\n\n-- Hannes\n"},{"id":"377487","messageId":"CAPig+cTTAgYia6DUOrg7AuLmGSbqn5u=iy3wx-=--NJuyULwaQ@mail.gmail.com","threadId":"51332","inReplyTo":"40cfbb30-c632-54da-62d9-9b31bc878806@kdbg.org","subject":"Re: [PATCH 02/17] t0001 (mingw): do not expect a specific order of stdout/stderr","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-06-19T06:40:09Z","receivedAt":"2019-06-19T06:40:24Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Jun 19, 2019 at 2:19 AM Johannes Sixt <j6t@kdbg.org> wrote:\n> Am 19.06.19 um 01:12 schrieb Eric Sunshine:\n> > On Tue, Jun 18, 2019 at 8:24 AM Johannes Schindelin via GitGitGadget\n> > <gitgitgadget@gmail.com> wrote:\n> >>         printf \".git\\nfatal: Needed a single revision\\n\" >expect &&\n> >> -       test_cmp expect output.txt\n> >> +       sort <output.txt >output.sorted &&\n> >> +       test_cmp expect output.sorted\n> >\n> > It was quite surprising to see this sorting only 'output' but not\n> > 'expect'. I see now that 'output' is already \"sorted\" (in that sense),\n> > but it feels fragile. More robust would be to sort 'expect' as well:\n> >\n> >     printf \".git\\nfatal: Needed a single revision\\n\" | sort >expect &&\n>\n> Following Dscho's recent objection elsewhere that tests tend to check\n> for much more than regressions, wouldn't it be logical to write these as\n>\n>         grep -F .git\" output.txt &&\n>         test_i18n_grep \"Needed a single rev\" output.txt\n>\n> without an 'expect' file at all?\n\nI considered suggesting that, as well, as being more obvious and less\nfragile (with the exception that \"Needed a single rev\" isn't currently\nlocalizable in builtin/rev-parse.c, so plain 'grep' instead of\n'test_i18n_grep').\n"},{"id":"377489","messageId":"CAPig+cTgmvwg_LV5zonQAR3c0et2p1Nm4YuAfAkYDF=2jY9YeQ@mail.gmail.com","threadId":"51332","inReplyTo":"587cbcf61903693139ad4a02b32727bddd6d116d.1560860634.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 13/17] msvc: support building Git using MS Visual C++","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-06-19T08:35:54Z","receivedAt":"2019-06-19T08:36:08Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Jun 18, 2019 at 8:24 AM Jeff Hostetler via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n> With this patch, Git can be built using the Microsoft toolchain, via:\n>\n>         make MSVC=1 [DEBUG=1]\n>\n> Third party libraries are built from source using the open source\n> \"vcpkg\" tool set. See https://github.com/Microsoft/vcpkg\n> [...]\n> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n> diff --git a/Makefile b/Makefile\n> @@ -1240,7 +1240,7 @@ endif\n> -BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'\n> +BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix \"$(SANE_TOOL_PATH_SQ)\"|'\n\nThis seems like a distinct bug fix which should live in its own patch.\n\n> diff --git a/compat/mingw.c b/compat/mingw.c\n> @@ -2388,6 +2388,12 @@ static void maybe_redirect_std_handles(void)\n> +#ifdef _MSC_VER\n> +#ifdef _DEBUG\n> +#include <crtdbg.h>\n> +#endif\n> +#endif\n> @@ -2405,6 +2411,12 @@ int wmain(int argc, const wchar_t **wargv)\n> +#ifdef _MSC_VER\n> +#ifdef USE_MSVC_CRTDBG\n> +       _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);\n> +#endif\n> +#endif\n\nShouldn't these changes be squashed into 16/17 (with the commit\nmessage of 16/17 adjusted accordingly), rather than being included in\nthis patch?\n\n> diff --git a/compat/vcbuild/README b/compat/vcbuild/README\n> @@ -1,3 +1,54 @@\n> +Alternatively, run `make MSVC=1 vcxproj` and then load the generated\n> +git.sln in Visual Studio. The initial build will install the vcpkg\n> +system and build the dependencies automatically. This will take a while.\n\nIs this bit implemented yet, or will it be introduced by a subsequent\npatch series mentioned in the cover letter? If the latter, perhaps\nthis README snippet belongs to that future patch series.\n\n> +Note that this will automatically add and commit the generated\n> +.sln and .vcxproj files to the repo.  You may want to drop this\n> +commit before submitting a Pull Request....\n\nYuck. An automatic commit as part of the build process has high\nsurprise-factor, and it seems like it's creating extra work (and\npossibility for error) if the user needs to remember to drop it before\nsubmitting.\n\n> +Or maybe we should put the .sln/.vcxproj files in the .gitignore file\n> +and not do this.  I'm not sure.\n\nSeems like a better choice.\n\n> diff --git a/compat/vcbuild/find_vs_env.bat b/compat/vcbuild/find_vs_env.bat\n> @@ -0,0 +1,169 @@\n> +:not_2015\n> +   REM TODO....\n> +   echo TODO support older versions of VS. >&2\n> +   EXIT /B 1\n\nAs this is a user-facing error message, perhaps it could be worded\ndifferently. Maybe:\n\n    ERROR: unsupported VS version (older than VS2015)\n\nor something.\n"},{"id":"377503","messageId":"nycvar.QRO.7.76.6.1906191316210.44@tvgsbejvaqbjf.bet","threadId":"51332","inReplyTo":"CAPUEspi-G7abt-zuLbw0iuyXN0gtrM_6Vy6d+9f-=6FpRsoV4A@mail.gmail.com","subject":"Re: [PATCH 03/17] cache-tree.c: avoid reusing the DEBUG constant","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-19T11:17:54Z","receivedAt":"2019-06-19T11:17:59Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Carlo,\n\nOn Tue, 18 Jun 2019, Carlo Arenas wrote:\n\n> shouldn't this also be a problem with builtin/blame.c?\n\nSharp eyes!\n\nIt does not *really* matter as much here, as that file defines that\n`DEBUG` constant if it has not yet been defined, but yes, it assumes that\n*if* it is defined, then it is set to `1`. Which is the case, but it is\nfragile.\n\nI changed it locally already, and it will be part of the next iteration.\n\nThanks,\nJohannes\n"},{"id":"377504","messageId":"nycvar.QRO.7.76.6.1906191318570.44@tvgsbejvaqbjf.bet","threadId":"51332","inReplyTo":"CAPig+cTXdz6s_cftPydKjtESz986s1xLQvwV8xPzYSR_xLK6Cg@mail.gmail.com","subject":"Re: [PATCH 03/17] cache-tree.c: avoid reusing the DEBUG constant","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-19T11:19:39Z","receivedAt":"2019-06-19T11:19:36Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Eric,\n\nOn Tue, 18 Jun 2019, Eric Sunshine wrote:\n\n> On Tue, Jun 18, 2019 at 8:24 AM Jeff Hostetler via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n> > In MSVC, the DEBUG constant is set automatically whenever compiling with\n> > debug information.\n> >\n> > This is clearly not what was intended in cache-tree.c, so let's use a less\n> > ambiguous constant there.\n>\n> s/constant/macro name/ would be clearer.\n\nTo me, \"macro\" always sounds as if it referred to executable code, or at\nleast to something that expands to code.\n\nI went with s/constant/name/ instead.\n\nThanks,\nDscho\n\n>\n> > Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n"},{"id":"377505","messageId":"nycvar.QRO.7.76.6.1906191325130.44@tvgsbejvaqbjf.bet","threadId":"51332","inReplyTo":"CAPig+cTTAgYia6DUOrg7AuLmGSbqn5u=iy3wx-=--NJuyULwaQ@mail.gmail.com","subject":"Re: [PATCH 02/17] t0001 (mingw): do not expect a specific order of stdout/stderr","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-19T11:26:08Z","receivedAt":"2019-06-19T11:26:02Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Eric & Hannes,\n\nOn Wed, 19 Jun 2019, Eric Sunshine wrote:\n\n> On Wed, Jun 19, 2019 at 2:19 AM Johannes Sixt <j6t@kdbg.org> wrote:\n> > Am 19.06.19 um 01:12 schrieb Eric Sunshine:\n> > > On Tue, Jun 18, 2019 at 8:24 AM Johannes Schindelin via GitGitGadget\n> > > <gitgitgadget@gmail.com> wrote:\n> > >>         printf \".git\\nfatal: Needed a single revision\\n\" >expect &&\n> > >> -       test_cmp expect output.txt\n> > >> +       sort <output.txt >output.sorted &&\n> > >> +       test_cmp expect output.sorted\n> > >\n> > > It was quite surprising to see this sorting only 'output' but not\n> > > 'expect'. I see now that 'output' is already \"sorted\" (in that sense),\n> > > but it feels fragile. More robust would be to sort 'expect' as well:\n> > >\n> > >     printf \".git\\nfatal: Needed a single revision\\n\" | sort >expect &&\n> >\n> > Following Dscho's recent objection elsewhere that tests tend to check\n> > for much more than regressions, wouldn't it be logical to write these as\n> >\n> >         grep -F .git\" output.txt &&\n> >         test_i18n_grep \"Needed a single rev\" output.txt\n> >\n> > without an 'expect' file at all?\n>\n> I considered suggesting that, as well, as being more obvious and less\n> fragile (with the exception that \"Needed a single rev\" isn't currently\n> localizable in builtin/rev-parse.c, so plain 'grep' instead of\n> 'test_i18n_grep').\n\nValid points all around, thank you so much!\n\nThe next iteration will have the two `grep`s instead,\nDscho\n"},{"id":"377506","messageId":"nycvar.QRO.7.76.6.1906191329040.44@tvgsbejvaqbjf.bet","threadId":"51332","inReplyTo":"nycvar.QRO.7.76.6.1906191325130.44@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 02/17] t0001 (mingw): do not expect a specific order of stdout/stderr","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-19T11:30:05Z","receivedAt":"2019-06-19T11:30:01Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Eric,\n\nOn Wed, 19 Jun 2019, Johannes Schindelin wrote:\n\n> On Wed, 19 Jun 2019, Eric Sunshine wrote:\n>\n> > On Wed, Jun 19, 2019 at 2:19 AM Johannes Sixt <j6t@kdbg.org> wrote:\n> > > Am 19.06.19 um 01:12 schrieb Eric Sunshine:\n> > > > On Tue, Jun 18, 2019 at 8:24 AM Johannes Schindelin via GitGitGadget\n> > > > <gitgitgadget@gmail.com> wrote:\n> > > >>         printf \".git\\nfatal: Needed a single revision\\n\" >expect &&\n> > > >> -       test_cmp expect output.txt\n> > > >> +       sort <output.txt >output.sorted &&\n> > > >> +       test_cmp expect output.sorted\n> > > >\n> > > > It was quite surprising to see this sorting only 'output' but not\n> > > > 'expect'. I see now that 'output' is already \"sorted\" (in that sense),\n> > > > but it feels fragile. More robust would be to sort 'expect' as well:\n> > > >\n> > > >     printf \".git\\nfatal: Needed a single revision\\n\" | sort >expect &&\n> > >\n> > > Following Dscho's recent objection elsewhere that tests tend to check\n> > > for much more than regressions, wouldn't it be logical to write these as\n> > >\n> > >         grep -F .git\" output.txt &&\n> > >         test_i18n_grep \"Needed a single rev\" output.txt\n> > >\n> > > without an 'expect' file at all?\n> >\n> > I considered suggesting that, as well, as being more obvious and less\n> > fragile (with the exception that \"Needed a single rev\" isn't currently\n> > localizable in builtin/rev-parse.c, so plain 'grep' instead of\n> > 'test_i18n_grep').\n\nInteresting side note: I just realized that t6050-replace.sh does indeed\ncontain\n\n\ttest_i18ngrep \"Needed a single revision\" err\n\nso I wonder why that works.\n\nIf anybody has an answer, I'd be curious, but for now I want to focus on\nthis here patch series instead.\n\nCiao,\nDscho\n\n> Valid points all around, thank you so much!\n>\n> The next iteration will have the two `grep`s instead,\n> Dscho\n>\n"},{"id":"377512","messageId":"nycvar.QRO.7.76.6.1906191442240.44@tvgsbejvaqbjf.bet","threadId":"51332","inReplyTo":"CAPUEsphHXxa6xbckKym7Nbx_E6aOzJYL+5j=xXa0oe3BLMrtbQ@mail.gmail.com","subject":"Re: [PATCH 13/17] msvc: support building Git using MS Visual C++","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-19T12:50:53Z","receivedAt":"2019-06-19T12:50:52Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Carlo,\n\nOn Tue, 18 Jun 2019, Carlo Arenas wrote:\n\n> On Tue, Jun 18, 2019 at 5:26 AM Jeff Hostetler via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n> > diff --git a/compat/mingw.c b/compat/mingw.c\n> > index d14d33308d..667285887a 100644\n> > --- a/compat/mingw.c\n> > +++ b/compat/mingw.c\n> > @@ -2388,6 +2388,12 @@ static void maybe_redirect_std_handles(void)\n> >                                   GENERIC_WRITE, FILE_FLAG_NO_BUFFERING);\n> >  }\n> >\n> > +#ifdef _MSC_VER\n> > +#ifdef _DEBUG\n>\n> why not use DEBUG instead (without the leading underscore), then you\n> could also drop the -D_DEBUG below\n\nAs per\nhttps://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2019,\nthe convention is actually to define `_DEBUG` in debug mode and `NDEBUG`\nin release mode (yes, it's a bit redundant and possibly contradictory).\nMy reading is that `DEBUG` is only a historical wart.\n\n> ...\n> > +       # BASIC_CLFAGS += -DUSE_MSVC_CRTDBG\n>\n> typo\n\nYep, and a copy-edited of the tyop I introduced in df5218b4c30b\n(config.mak.uname: support MSys2, 2016-01-13)!\n\nThanks!\nJohannes\n"},{"id":"377529","messageId":"nycvar.QRO.7.76.6.1906191500241.44@tvgsbejvaqbjf.bet","threadId":"51332","inReplyTo":"CAPig+cTgmvwg_LV5zonQAR3c0et2p1Nm4YuAfAkYDF=2jY9YeQ@mail.gmail.com","subject":"Re: [PATCH 13/17] msvc: support building Git using MS Visual C++","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-19T15:11:20Z","receivedAt":"2019-06-19T15:11:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Eric,\n\nOn Wed, 19 Jun 2019, Eric Sunshine wrote:\n\n> On Tue, Jun 18, 2019 at 8:24 AM Jeff Hostetler via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n> > With this patch, Git can be built using the Microsoft toolchain, via:\n> >\n> >         make MSVC=1 [DEBUG=1]\n> >\n> > Third party libraries are built from source using the open source\n> > \"vcpkg\" tool set. See https://github.com/Microsoft/vcpkg\n> > [...]\n> > Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > ---\n> > diff --git a/Makefile b/Makefile\n> > @@ -1240,7 +1240,7 @@ endif\n> > -BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'\n> > +BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix \"$(SANE_TOOL_PATH_SQ)\"|'\n>\n> This seems like a distinct bug fix which should live in its own patch.\n\nAnd so it did! And so it will do again, starting from the next iteration.\nThanks.\n\n> > diff --git a/compat/mingw.c b/compat/mingw.c\n> > @@ -2388,6 +2388,12 @@ static void maybe_redirect_std_handles(void)\n> > +#ifdef _MSC_VER\n> > +#ifdef _DEBUG\n> > +#include <crtdbg.h>\n> > +#endif\n> > +#endif\n> > @@ -2405,6 +2411,12 @@ int wmain(int argc, const wchar_t **wargv)\n> > +#ifdef _MSC_VER\n> > +#ifdef USE_MSVC_CRTDBG\n> > +       _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);\n> > +#endif\n> > +#endif\n>\n> Shouldn't these changes be squashed into 16/17 (with the commit\n> message of 16/17 adjusted accordingly), rather than being included in\n> this patch?\n\nNot really. This has little to do with assertions, and much more with\nmemory usage debugging support in Visual Studio.\n\nI guess that this (together with the other `USE_MSVC_CRTDBG`) should go\ninto its own, separate commit.\n\n> > diff --git a/compat/vcbuild/README b/compat/vcbuild/README\n> > @@ -1,3 +1,54 @@\n> > +Alternatively, run `make MSVC=1 vcxproj` and then load the generated\n> > +git.sln in Visual Studio. The initial build will install the vcpkg\n> > +system and build the dependencies automatically. This will take a while.\n>\n> Is this bit implemented yet, or will it be introduced by a subsequent\n> patch series mentioned in the cover letter? If the latter, perhaps\n> this README snippet belongs to that future patch series.\n\nIt is actually implemented in a future patch series (I hinted at it in the\ncover letter).\n\n> > +Note that this will automatically add and commit the generated\n> > +.sln and .vcxproj files to the repo.  You may want to drop this\n> > +commit before submitting a Pull Request....\n>\n> Yuck. An automatic commit as part of the build process has high\n> surprise-factor, and it seems like it's creating extra work (and\n> possibility for error) if the user needs to remember to drop it before\n> submitting.\n\nThe thing to keep in mind is that the *primary* reason for this Makefile\ntarget is to publish a version of the source code that works in Visual\nStudio out of the box. Read: without getting a (pretty heavy) Git for\nWindows SDK on top.\n\nThe idea is to avoid having to download several hundred megabytes of\nGit for Windows SDK, and instead run the tests in the Git Bash of a\nregular Git for Windows.\n\nOf course, this only works when certain \"build products\" (such as shell\nscripts that have been copy-edited to their final form, or certain\ngenerated files that the test suite wants to see) are included.\n\nIf you do not include them, tough luck, you cannot run the tests.\n\nOf course, I *do* want contributors to run the tests, even if they choose\nthe convenience of a full-fledged IDE, and I don't want to punish them for\nit by forcing them to pick all of the bits and pieces for themselves.\n\nTo achieve that, I force-add those generated files and commit the whole\nbunch, and publish the result as `vs/master` at\nhttps://github.com/git-for-windows/git. Actually, it is a trusty Azure\nPipeline that does that.\n\n> > +Or maybe we should put the .sln/.vcxproj files in the .gitignore file\n> > +and not do this.  I'm not sure.\n>\n> Seems like a better choice.\n\nUnless you struggled for yourself to find all the missing files you need\nin order to run the test suite. Or to cobble together a working Git from\nthe build output of Visual Studio (which only contains the compiled C\ncode, after all, and as you and me know fully well, Git insists on support\nfiles such as templates, too, and yes, they have to be \"generated\" and are\nof course excluded via `.gitignore`).\n\nOnce you went through those struggles, you don't want to do it again. I\nwent a step further, and I don't want anybody but me to have to go through\nthat again, either.\n\nThat is why I think that your statement might have been made under the\nfalse impression that this is an easy decision.\n\nIn any case, this is indeed a discussion for the next patch series, not\nthis one.\n\n> > diff --git a/compat/vcbuild/find_vs_env.bat b/compat/vcbuild/find_vs_env.bat\n> > @@ -0,0 +1,169 @@\n> > +:not_2015\n> > +   REM TODO....\n> > +   echo TODO support older versions of VS. >&2\n> > +   EXIT /B 1\n>\n> As this is a user-facing error message, perhaps it could be worded\n> differently. Maybe:\n>\n>     ERROR: unsupported VS version (older than VS2015)\n>\n> or something.\n\nGood idea! I made it so.\n\nThanks!\nDscho\n"},{"id":"377535","messageId":"xmqqzhmdppmn.fsf@gitster-ct.c.googlers.com","threadId":"51332","inReplyTo":"CAPig+cTXdz6s_cftPydKjtESz986s1xLQvwV8xPzYSR_xLK6Cg@mail.gmail.com","subject":"Re: [PATCH 03/17] cache-tree.c: avoid reusing the DEBUG constant","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-06-19T15:21:36Z","receivedAt":"2019-06-19T15:21:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> On Tue, Jun 18, 2019 at 8:24 AM Jeff Hostetler via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n>> In MSVC, the DEBUG constant is set automatically whenever compiling with\n>> debug information.\n>>\n>> This is clearly not what was intended in cache-tree.c, so let's use a less\n>> ambiguous constant there.\n>\n> s/constant/macro name/ would be clearer.\n\nIt is closer to the standard-kosher terminology, I would think; if\nsomebody is in more pedantic mood, \"C preprocessor macro\" is\nprobably the phrase to use.\n"},{"id":"377539","messageId":"nycvar.QRO.7.76.6.1906191848080.44@tvgsbejvaqbjf.bet","threadId":"51332","inReplyTo":"CAPig+cRW+1dEUe1=7=5G-HziJOA2UpYVKsnMdBpkpcU6D8O95A@mail.gmail.com","subject":"Re: [PATCH 15/17] msvc: do not pretend to support all signals","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-19T16:49:31Z","receivedAt":"2019-06-19T16:49:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Eric,\n\nOn Wed, 19 Jun 2019, Eric Sunshine wrote:\n\n> On Tue, Jun 18, 2019 at 8:24 AM Jeff Hostetler via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n> > This special-cases various signals that are not supported on Windows,\n> > such as SIGPIPE. These cause the UCRT to throw asserts (at least in\n> > debug mode).\n> >\n> > Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > ---\n> > diff --git a/compat/mingw.c b/compat/mingw.c\n> > @@ -2119,8 +2119,34 @@ int mingw_raise(int sig)\n> > +#if defined(_MSC_VER)\n> > +               /*\n> > +                * <signal.h> in the CRT defines 8 signals as being\n> > +                * supported on the platform.  Anything else causes\n> > +                * an \"Invalid signal or error\" (which in DEBUG builds\n> > +                * causes the Abort/Retry/Ignore dialog).  We by-pass\n> > +                * the CRT for things we already know will fail.\n> > +                */\n> > +               /*case SIGINT:*/\n> > +       case SIGILL:\n>\n> Why is SIGINT commented out?\n\nWhoops. The `case` before that already handles `SIGINT`, I think that's\nwhy... I removed it.\n\n> And, the comment block seems over-indented.\n\nNot really, as the `case` statements are indented one level less than the\ncode (including the comments).\n\nBut I agree that it looks funny, and moved it within the `case` arm.\n\nThanks!\nDscho\n\n>\n> > +       case SIGFPE:\n> > +       case SIGSEGV:\n> > +       case SIGTERM:\n> > +       case SIGBREAK:\n> > +       case SIGABRT:\n> > +       case SIGABRT_COMPAT:\n> > +               return raise(sig);\n> > +       default:\n> > +               errno = EINVAL;\n> > +               return -1;\n>\n"},{"id":"377540","messageId":"CAPUEspjJe1n0sTG292YaHU+qBa4yLrEw2G_6Fd1U5Af=f9JRAg@mail.gmail.com","threadId":"51332","inReplyTo":"nycvar.QRO.7.76.6.1906191316210.44@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 03/17] cache-tree.c: avoid reusing the DEBUG constant","fromName":"Carlo Arenas","fromEmail":"carenas@gmail.com","sentAt":"2019-06-19T17:15:08Z","receivedAt":"2019-06-19T17:15:21Z","isPatch":true,"sender":{"key":"carenas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/76036?v=4"},"body":"while those two changes (from DEBUG to DEBUG_$foo) are worth doing in\ntheir own merit, I am more inclined to consider this as orthogonal\nsince by your own description[1] the right name to use would be _DEBUG\n(with a preceding dash) and that would obviously not conflict here.\n\nthe only remaining change then would be to drop the -DDEBUG that gets\nadded to your BASIC_CFLAGS\n\nCarlo\n[1] https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2019\n"},{"id":"377541","messageId":"0841b134-0719-8bda-41ec-abd124157df6@kdbg.org","threadId":"51332","inReplyTo":"nycvar.QRO.7.76.6.1906191329040.44@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 02/17] t0001 (mingw): do not expect a specific order of stdout/stderr","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2019-06-19T17:24:23Z","receivedAt":"2019-06-19T17:24:28Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 19.06.19 um 13:30 schrieb Johannes Schindelin:\n> Interesting side note: I just realized that t6050-replace.sh does indeed\n> contain\n> \n> \ttest_i18ngrep \"Needed a single revision\" err\n> \n> so I wonder why that works.\n\nWhy should it not work? If GIT_TEST_GETTEXT_POISON is on, it pretends\nsuccess; otherwise, it does a regular grep.\n\n-- Hannes\n"},{"id":"377559","messageId":"nycvar.QRO.7.76.6.1906192257000.44@tvgsbejvaqbjf.bet","threadId":"51332","inReplyTo":"0841b134-0719-8bda-41ec-abd124157df6@kdbg.org","subject":"Re: [PATCH 02/17] t0001 (mingw): do not expect a specific order of stdout/stderr","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-19T20:58:56Z","receivedAt":"2019-06-19T20:58:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Hannes,\n\nOn Wed, 19 Jun 2019, Johannes Sixt wrote:\n\n> Am 19.06.19 um 13:30 schrieb Johannes Schindelin:\n> > Interesting side note: I just realized that t6050-replace.sh does indeed\n> > contain\n> >\n> > \ttest_i18ngrep \"Needed a single revision\" err\n> >\n> > so I wonder why that works.\n>\n> Why should it not work? If GIT_TEST_GETTEXT_POISON is on, it pretends\n> success; otherwise, it does a regular grep.\n\nAh, right, I vaguely remembered that Duy offered patches to do something\nfunny with a pseudo locale (I never understood why not go for the much\nsimpler ROT-13), and I guess that effort never went anywhere.\n\nSo essentially the test case in t6050 will succeed under GETTEXT_POISON\nfor the wrong reasons.\n\nThanks for explaining this to me!\n\nCiao,\nDscho\n"},{"id":"377560","messageId":"nycvar.QRO.7.76.6.1906192300060.44@tvgsbejvaqbjf.bet","threadId":"51332","inReplyTo":"CAPUEspjJe1n0sTG292YaHU+qBa4yLrEw2G_6Fd1U5Af=f9JRAg@mail.gmail.com","subject":"Re: [PATCH 03/17] cache-tree.c: avoid reusing the DEBUG constant","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-19T21:03:02Z","receivedAt":"2019-06-19T21:02:57Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Carlo,\n\nOn Wed, 19 Jun 2019, Carlo Arenas wrote:\n\n> while those two changes (from DEBUG to DEBUG_$foo) are worth doing in\n> their own merit, I am more inclined to consider this as orthogonal\n> since by your own description[1] the right name to use would be _DEBUG\n> (with a preceding dash) and that would obviously not conflict here.\n\nWell, both `_DEBUG` and `DEBUG` appear to be defined by Visual Studio in\ndebug mode. So we still need to rename them, and I'd rather rename them\nhere than in the next patch series (that will (re-)add support to build in\nVisual Studio), as I want the command-line MSVC build to also define both\nconstants.\n\n> the only remaining change then would be to drop the -DDEBUG that gets\n> added to your BASIC_CFLAGS\n\nNo, for consistency with Visual Studio, I want to keep defining both\n`DEBUG` and `_DEBUG`. It's just easier that way, as I won't have to spend\nextra cycles to remember that those two ways to build Git are slightly\ndifferent, when they shouldn't be.\n\nThanks,\nDscho\n\n> Carlo\n> [1] https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2019\n>\n>\n"},{"id":"377561","messageId":"pull.149.v2.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.git.gitgitgadget@gmail.com","subject":"[PATCH v2 00/20] Fix MSVC support, at long last","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:05:55Z","receivedAt":"2019-06-19T21:05:59Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Philip Oakley and Jeff Hostetler worked quite a bit on getting Git to\ncompile with MS Visual C again, and this patch series is the culmination of\nthose efforts. With these patches, it is as easy as\n\nmake MSVC=1\n\nNote: the patches went through quite the number of iterations. For example,\nfor a long time we targeted Visual Studio 2015, and used NuGet packages for\nthe dependencies (such as OpenSSL, cURL, etc), while the current iteration\ntargets Visual Studio 2017 and uses vcpkg\n[https://docs.microsoft.com/en-us/cpp/vcpkg?view=vs-2017] for dependencies.\nHopefully I did not forget to remove any remnants of those previous\nversions.\n\nPlease also note that this patch series is part 1 of 3 in a bigger story:\nthe next patch series will add support to build Git in Microsoft Visual\nStudio, and the third patch series will add Continuous Testing by adding an\nMSVC build and a corresponding parallelized test job to our Azure Pipeline.\n\nChanges since v1:\n\n * The BASIC_CLFAGS typo was fixed.\n * Instead of sorting the output of stdout/stderr, the fixed test case in \n   t0001 now greps for the tell-tales it wants to be present.\n * In addition to cache-tree.c's DEBUG constant, now also builtin/blame.c's\n   is renamed.\n * Two changes were factored out of the patch titled \"msvc: support building\n   Git using MS Visual C++\": the support for spaces in SANE_TOOL_PATH, and\n   the support for the compile time flag to enable CrtDbg's detailed heap\n   diagnostics.\n * A comment about the vcxproj target has been dropped; The corresponding\n   change is slated for a future patch series.\n * A left-over \"TODO\" comment was replaced by stating the final decision\n   that only Visual Studio 2015 or later are supported for now.\n * A left-over, commented-out SIGINT case label was removed, and an adjacent\n   comment was moved so that its indentation no longer looks strange.\n\nJeff Hostetler (10):\n  cache-tree/blame: avoid reusing the DEBUG constant\n  msvc: mark a variable as non-const\n  msvc: do not re-declare the timespec struct\n  msvc: define ftello()\n  msvc: fix detect_msys_tty()\n  msvc: update Makefile to allow for spaces in the compiler path\n  msvc: support building Git using MS Visual C++\n  msvc: add a compile-time flag to allow detailed heap debugging\n  msvc: do not pretend to support all signals\n  msvc: ignore .dll and incremental compile output\n\nJohannes Schindelin (7):\n  mingw: fix a typo in the msysGit-specific section\n  Mark .bat files as requiring CR/LF endings\n  t0001 (mingw): do not expect a specific order of stdout/stderr\n  obstack: fix compiler warning\n  mingw: replace mingw_startup() hack\n  msvc: fix dependencies of compat/msvc.c\n  msvc: avoid debug assertion windows in Debug Mode\n\nPhilip Oakley (3):\n  msvc: include sigset_t definition\n  msvc: define O_ACCMODE\n  msvc: add pragmas for common warnings\n\n .gitattributes                     |   1 +\n .gitignore                         |   5 +\n Makefile                           |  40 +++++++\n builtin/blame.c                    |   6 +-\n cache-tree.c                       |  14 +--\n compat/mingw.c                     |  99 +++++++++++++----\n compat/mingw.h                     |  24 +++--\n compat/msvc.h                      |  10 ++\n compat/obstack.h                   |   2 +-\n compat/vcbuild/.gitignore          |   3 +\n compat/vcbuild/README              |  39 +++++++\n compat/vcbuild/find_vs_env.bat     | 168 +++++++++++++++++++++++++++++\n compat/vcbuild/scripts/clink.pl    |  41 ++++++-\n compat/vcbuild/vcpkg_copy_dlls.bat |  39 +++++++\n compat/vcbuild/vcpkg_install.bat   |  80 ++++++++++++++\n compat/winansi.c                   |  13 +++\n config.mak.uname                   |  83 +++++++++++---\n git-compat-util.h                  |   9 ++\n t/t0001-init.sh                    |   4 +-\n 19 files changed, 619 insertions(+), 61 deletions(-)\n create mode 100644 compat/vcbuild/.gitignore\n create mode 100644 compat/vcbuild/find_vs_env.bat\n create mode 100644 compat/vcbuild/vcpkg_copy_dlls.bat\n create mode 100644 compat/vcbuild/vcpkg_install.bat\n\n\nbase-commit: b697d92f56511e804b8ba20ccbe7bdc85dc66810\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-149%2Fdscho%2Fmsvc-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-149/dscho/msvc-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/149\n\nRange-diff vs v1:\n\n  -:  ---------- >  1:  9d4d6ae7db mingw: fix a typo in the msysGit-specific section\n  1:  b30429e0a4 =  2:  aa27e7f9cb Mark .bat files as requiring CR/LF endings\n  2:  d551cdeafb <  -:  ---------- t0001 (mingw): do not expect a specific order of stdout/stderr\n  -:  ---------- >  3:  3e108cfb02 t0001 (mingw): do not expect a specific order of stdout/stderr\n  3:  486297ec8c !  4:  90ac088d22 cache-tree.c: avoid reusing the DEBUG constant\n     @@ -1,16 +1,40 @@\n      Author: Jeff Hostetler <jeffhost@microsoft.com>\n      \n     -    cache-tree.c: avoid reusing the DEBUG constant\n     +    cache-tree/blame: avoid reusing the DEBUG constant\n      \n     -    In MSVC, the DEBUG constant is set automatically whenever compiling with\n     -    debug information.\n     +    In MS Visual C, the `DEBUG` constant is set automatically whenever\n     +    compiling with debug information.\n      \n     -    This is clearly not what was intended in cache-tree.c, so let's use a less\n     -    ambiguous constant there.\n     +    This is clearly not what was intended in `cache-tree.c` nor in\n     +    `builtin/blame.c`, so let's use a less ambiguous name there.\n      \n          Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n      \n     + diff --git a/builtin/blame.c b/builtin/blame.c\n     + --- a/builtin/blame.c\n     + +++ b/builtin/blame.c\n     +@@\n     + \n     + static struct string_list mailmap = STRING_LIST_INIT_NODUP;\n     + \n     +-#ifndef DEBUG\n     +-#define DEBUG 0\n     ++#ifndef DEBUG_BLAME\n     ++#define DEBUG_BLAME 0\n     + #endif\n     + \n     + static unsigned blame_move_score;\n     +@@\n     + \tif (blame_copy_score)\n     + \t\tsb.copy_score = blame_copy_score;\n     + \n     +-\tsb.debug = DEBUG;\n     ++\tsb.debug = DEBUG_BLAME;\n     + \tsb.on_sanity_fail = &sanity_check_on_fail;\n     + \n     + \tsb.show_root = show_root;\n     +\n       diff --git a/cache-tree.c b/cache-tree.c\n       --- a/cache-tree.c\n       +++ b/cache-tree.c\n  4:  bda1c270c1 =  5:  71d85b58b6 obstack: fix compiler warning\n  5:  47105b6350 =  6:  02f618464f mingw: replace mingw_startup() hack\n  6:  250385d7a3 =  7:  5c383985a1 msvc: fix dependencies of compat/msvc.c\n  7:  037fbed117 =  8:  0a2985dc3c msvc: include sigset_t definition\n  8:  b23651a357 =  9:  99a2939cc2 msvc: define O_ACCMODE\n  9:  e813075ade = 10:  1542e8abe5 msvc: mark a variable as non-const\n 10:  2ed60dfffc = 11:  51d73c61d3 msvc: do not re-declare the timespec struct\n 11:  e6cd002806 = 12:  7cfd0fc9b4 msvc: define ftello()\n 12:  073dc01b14 = 13:  f528883d97 msvc: fix detect_msys_tty()\n  -:  ---------- > 14:  63bf9f1f92 msvc: update Makefile to allow for spaces in the compiler path\n 13:  587cbcf619 ! 15:  245f28ac3b msvc: support building Git using MS Visual C++\n     @@ -46,8 +46,8 @@\n       \n       ifdef SANE_TOOL_PATH\n       SANE_TOOL_PATH_SQ = $(subst ','\\'',$(SANE_TOOL_PATH))\n     --BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'\n     -+BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix \"$(SANE_TOOL_PATH_SQ)\"|'\n     +-BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix \"$(SANE_TOOL_PATH_SQ)\"|'\n     ++BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'\n       PATH := $(SANE_TOOL_PATH):${PATH}\n       else\n       BROKEN_PATH_FIX = '/^\\# @@BROKEN_PATH_FIX@@$$/d'\n     @@ -122,19 +122,6 @@\n       /*\n        * We implement wmain() and compile with -municode, which would\n        * normally ignore main(), but we call the latter from the former\n     -@@\n     - \n     - \ttrace2_initialize_clock();\n     - \n     -+#ifdef _MSC_VER\n     -+#ifdef USE_MSVC_CRTDBG\n     -+\t_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);\n     -+#endif\n     -+#endif\n     -+\n     - \tmaybe_redirect_std_handles();\n     - \n     - \t/* determine size of argv and environ conversion buffer */\n      \n       diff --git a/compat/vcbuild/.gitignore b/compat/vcbuild/.gitignore\n       new file mode 100644\n     @@ -188,18 +175,6 @@\n      +\n      +================================================================\n      +\n     -+Alternatively, run `make MSVC=1 vcxproj` and then load the generated\n     -+git.sln in Visual Studio. The initial build will install the vcpkg\n     -+system and build the dependencies automatically. This will take a while.\n     -+\n     -+Note that this will automatically add and commit the generated\n     -+.sln and .vcxproj files to the repo.  You may want to drop this\n     -+commit before submitting a Pull Request....\n     -+\n     -+Or maybe we should put the .sln/.vcxproj files in the .gitignore file\n     -+and not do this.  I'm not sure.\n     -+\n     -+================================================================\n       The Steps of Build Git with VS2008\n       \n       1. You need the build environment, which contains the Git dependencies\n     @@ -264,7 +239,7 @@\n      +REM\n      +REM Earlier Versions\n      +REM ----------------\n     -+REM TODO\n     ++REM Currently unsupported.\n      +REM\n      +REM ================================================================\n      +REM Note: Throughout this script we use \"dir <path> && <cmd>\" rather\n     @@ -353,8 +328,7 @@\n      +REM ================================================================\n      +\n      +:not_2015\n     -+   REM TODO....\n     -+   echo TODO support older versions of VS. >&2\n     ++   echo \"ERROR: unsupported VS version (older than VS2015)\" >&2\n      +   EXIT /B 1\n      +\n      +REM ================================================================\n     @@ -702,8 +676,6 @@\n      +endif\n      +\tBASIC_CFLAGS += $(sdk_libs) $(msvc_libs)\n      +\n     -+\t# Optionally enable memory leak reporting.\n     -+\t# BASIC_CLFAGS += -DUSE_MSVC_CRTDBG\n       \tBASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1\n      +\t# Always give \"-Zi\" to the compiler and \"-debug\" to linker (even in\n      +\t# release mode) to force a PDB to be generated (like RelWithDebInfo).\n     @@ -726,23 +698,3 @@\n       endif\n       \tX = .exe\n       \n     -\n     - diff --git a/git-compat-util.h b/git-compat-util.h\n     - --- a/git-compat-util.h\n     - +++ b/git-compat-util.h\n     -@@\n     - #ifndef GIT_COMPAT_UTIL_H\n     - #define GIT_COMPAT_UTIL_H\n     - \n     -+#ifdef USE_MSVC_CRTDBG\n     -+/*\n     -+ * For these to work they must appear very early in each\n     -+ * file -- before most of the standard header files.\n     -+ */\n     -+#include <stdlib.h>\n     -+#include <crtdbg.h>\n     -+#endif\n     -+\n     - #define _FILE_OFFSET_BITS 64\n     - \n     - \n  -:  ---------- > 16:  e7888bedbd msvc: add a compile-time flag to allow detailed heap debugging\n 14:  0cca8c3c68 = 17:  d9668558dd msvc: add pragmas for common warnings\n 15:  1491ea4140 ! 18:  c883f037e0 msvc: do not pretend to support all signals\n     @@ -17,14 +17,6 @@\n       \t\treturn 0;\n       \n      +#if defined(_MSC_VER)\n     -+\t\t/*\n     -+\t\t * <signal.h> in the CRT defines 8 signals as being\n     -+\t\t * supported on the platform.  Anything else causes\n     -+\t\t * an \"Invalid signal or error\" (which in DEBUG builds\n     -+\t\t * causes the Abort/Retry/Ignore dialog).  We by-pass\n     -+\t\t * the CRT for things we already know will fail.\n     -+\t\t */\n     -+\t\t/*case SIGINT:*/\n      +\tcase SIGILL:\n      +\tcase SIGFPE:\n      +\tcase SIGSEGV:\n     @@ -32,6 +24,13 @@\n      +\tcase SIGBREAK:\n      +\tcase SIGABRT:\n      +\tcase SIGABRT_COMPAT:\n     ++\t\t/*\n     ++\t\t * The <signal.h> header in the MS C Runtime defines 8 signals\n     ++\t\t * as being supported on the platform. Anything else causes an\n     ++\t\t * \"Invalid signal or error\" (which in DEBUG builds causes the\n     ++\t\t * Abort/Retry/Ignore dialog). We by-pass the CRT for things we\n     ++\t\t * already know will fail.\n     ++\t\t */\n      +\t\treturn raise(sig);\n      +\tdefault:\n      +\t\terrno = EINVAL;\n 16:  831d603e25 = 19:  51a20ff2df msvc: avoid debug assertion windows in Debug Mode\n 17:  0c7f5479bf = 20:  4d44d1fab1 msvc: ignore .dll and incremental compile output\n\n-- \ngitgitgadget\n"},{"id":"377562","messageId":"9d4d6ae7db55309ff99c34237b64d7edae2dbbd6.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 01/20] mingw: fix a typo in the msysGit-specific section","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:05:56Z","receivedAt":"2019-06-19T21:06:01Z","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 msysGit project (i.e. Git for Windows 1.x' SDK) is safely dead for\n*years* already. This is probably the reason why nobody caught this typo\nuntil Carlo Arenas spotted a copy-edited version of it nearby.\n\nIt is probably about time to rip out the remainders of msysGit/MSys1\nsupport, but that can safely wait a bit longer, and we can at least fix\nthe typo for now.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n config.mak.uname | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex b71688eeb7..9fc053cac0 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -571,7 +571,7 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))\n \tINTERNAL_QSORT = YesPlease\n \tHAVE_LIBCHARSET_H = YesPlease\n \tNO_GETTEXT = YesPlease\n-\tCOMPAT_CLFAGS += -D__USE_MINGW_ACCESS\n+\tCOMPAT_CFLAGS += -D__USE_MINGW_ACCESS\n else\n \tifneq ($(shell expr \"$(uname_R)\" : '1\\.'),2)\n \t\t# MSys2\n-- \ngitgitgadget\n\n"},{"id":"377563","messageId":"aa27e7f9cbfda50a02ac6bb555f2ee6487c47625.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 02/20] Mark .bat files as requiring CR/LF endings","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:05:57Z","receivedAt":"2019-06-19T21:06:01Z","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\nJust like the natural line ending for Unix shell scripts consist of a\nsingle Line Feed, the natural line ending for (DOS) Batch scripts\nconsists of a Carriage Return followed by a Line Feed.\n\nIt seems that both Unix shell script interpreters and the interpreter\nfor Batch scripts (`cmd.exe`) are keen on seeing the \"right\" line\nendings.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .gitattributes | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/.gitattributes b/.gitattributes\nindex 9fa72ad450..b08a1416d8 100644\n--- a/.gitattributes\n+++ b/.gitattributes\n@@ -5,6 +5,7 @@\n *.pl eof=lf diff=perl\n *.pm eol=lf diff=perl\n *.py eol=lf diff=python\n+*.bat eol=crlf\n /Documentation/**/*.txt eol=lf\n /command-list.txt eol=lf\n /GIT-VERSION-GEN eol=lf\n-- \ngitgitgadget\n\n"},{"id":"377564","messageId":"3e108cfb0250919c10833bcff3985e79c6452ae0.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 03/20] t0001 (mingw): do not expect a specific order of stdout/stderr","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:05:57Z","receivedAt":"2019-06-19T21:06:02Z","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\nWhen redirecting stdout/stderr to the same file, we cannot guarantee\nthat stdout will come first.\n\nIn fact, in this test case, it seems that an MSVC build always prints\nstderr first.\n\nIn any case, this test case does not want to verify the *order* but\nthe *presence* of both outputs, so let's test exactly that.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/t0001-init.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 77a224aafb..387e4e6b81 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -473,8 +473,8 @@ test_expect_success MINGW 'redirect std handles' '\n \t\tGIT_REDIRECT_STDOUT=output.txt \\\n \t\tGIT_REDIRECT_STDERR=\"2>&1\" \\\n \t\tgit rev-parse --git-dir --verify refs/invalid &&\n-\tprintf \".git\\nfatal: Needed a single revision\\n\" >expect &&\n-\ttest_cmp expect output.txt\n+\tgrep \"^\\\\.git\\$\" output.txt &&\n+\tgrep \"Needed a single revision\" output.txt\n '\n \n test_done\n-- \ngitgitgadget\n\n"},{"id":"377565","messageId":"5c383985a19f8d7edff4a496021c99849840c8be.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 07/20] msvc: fix dependencies of compat/msvc.c","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:00Z","receivedAt":"2019-06-19T21:06: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 file compat/msvc.c includes compat/mingw.c, which means that we have\nto recompile compat/msvc.o if compat/mingw.c changes.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n config.mak.uname | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 6ddece0350..473613a20d 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -414,6 +414,8 @@ else\n \tBASIC_CFLAGS += -Zi -MDd\n endif\n \tX = .exe\n+\n+compat/msvc.o: compat/msvc.c compat/mingw.c GIT-CFLAGS\n endif\n ifeq ($(uname_S),Interix)\n \tNO_INITGROUPS = YesPlease\n-- \ngitgitgadget\n\n"},{"id":"377566","messageId":"02f618464f85c0d61921f22948369f76b630e1e0.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 06/20] mingw: replace mingw_startup() hack","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:05:59Z","receivedAt":"2019-06-19T21:06: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\nGit for Windows has special code to retrieve the command-line parameters\n(and even the environment) in UTF-16 encoding, so that they can be\nconverted to UTF-8. This is necessary because Git for Windows wants to\nuse UTF-8 encoded strings throughout its code, and the main() function\ndoes not get the parameters in that encoding.\n\nTo do that, we used the __wgetmainargs() function, which is not even a\nWin32 API function, but provided by the MINGW \"runtime\" instead.\n\nObviously, this method would not work with any compiler other than GCC,\nand in preparation for compiling with Visual C++, we would like to avoid\nprecisely that.\n\nLucky us, there is a much more elegant way: we can simply implement the\nUTF-16 variant of `main()`: `wmain()`.\n\nTo make that work, we need to link with -municode. The command-line\nparameters are passed to `wmain()` encoded in UTF-16, as desired, and\nthis method also works with GCC, and also with Visual C++ after\nadjusting the MSVC linker flags to force it to use `wmain()`.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c   | 53 +++++++++++++++++++++++++++++++-----------------\n compat/mingw.h   | 22 ++++++++++----------\n config.mak.uname |  3 ++-\n 3 files changed, 47 insertions(+), 31 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 9b6d2400e1..0d8713e515 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2301,18 +2301,13 @@ static void setup_windows_environment(void)\n \t\tsetenv(\"TERM\", \"cygwin\", 1);\n }\n \n+#if !defined(_MSC_VER)\n /*\n  * Disable MSVCRT command line wildcard expansion (__getmainargs called from\n  * mingw startup code, see init.c in mingw runtime).\n  */\n int _CRT_glob = 0;\n-\n-typedef struct {\n-\tint newmode;\n-} _startupinfo;\n-\n-extern int __wgetmainargs(int *argc, wchar_t ***argv, wchar_t ***env, int glob,\n-\t\t_startupinfo *si);\n+#endif\n \n static NORETURN void die_startup(void)\n {\n@@ -2390,22 +2385,25 @@ static void maybe_redirect_std_handles(void)\n \t\t\t\t  GENERIC_WRITE, FILE_FLAG_NO_BUFFERING);\n }\n \n-void mingw_startup(void)\n+/*\n+ * We implement wmain() and compile with -municode, which would\n+ * normally ignore main(), but we call the latter from the former\n+ * so that we can handle non-ASCII command-line parameters\n+ * appropriately.\n+ *\n+ * To be more compatible with the core git code, we convert\n+ * argv into UTF8 and pass them directly to main().\n+ */\n+int wmain(int argc, const wchar_t **wargv)\n {\n-\tint i, maxlen, argc;\n-\tchar *buffer;\n-\twchar_t **wenv, **wargv;\n-\t_startupinfo si;\n+\tint i, maxlen, exit_status;\n+\tchar *buffer, **save;\n+\tconst char **argv;\n \n \ttrace2_initialize_clock();\n \n \tmaybe_redirect_std_handles();\n \n-\t/* get wide char arguments and environment */\n-\tsi.newmode = 0;\n-\tif (__wgetmainargs(&argc, &wargv, &wenv, _CRT_glob, &si) < 0)\n-\t\tdie_startup();\n-\n \t/* determine size of argv and environ conversion buffer */\n \tmaxlen = wcslen(wargv[0]);\n \tfor (i = 1; i < argc; i++)\n@@ -2415,9 +2413,16 @@ void mingw_startup(void)\n \tmaxlen = 3 * maxlen + 1;\n \tbuffer = malloc_startup(maxlen);\n \n-\t/* convert command line arguments and environment to UTF-8 */\n+\t/*\n+\t * Create a UTF-8 version of w_argv. Also create a \"save\" copy\n+\t * to remember all the string pointers because parse_options()\n+\t * will remove claimed items from the argv that we pass down.\n+\t */\n+\tALLOC_ARRAY(argv, argc + 1);\n+\tALLOC_ARRAY(save, argc + 1);\n \tfor (i = 0; i < argc; i++)\n-\t\t__argv[i] = wcstoutfdup_startup(buffer, wargv[i], maxlen);\n+\t\targv[i] = save[i] = wcstoutfdup_startup(buffer, wargv[i], maxlen);\n+\targv[i] = save[i] = NULL;\n \tfree(buffer);\n \n \t/* fix Windows specific environment settings */\n@@ -2436,6 +2441,16 @@ void mingw_startup(void)\n \n \t/* initialize Unicode console */\n \twinansi_init();\n+\n+\t/* invoke the real main() using our utf8 version of argv. */\n+\texit_status = main(argc, argv);\n+\n+\tfor (i = 0; i < argc; i++)\n+\t\tfree(save[i]);\n+\tfree(save);\n+\tfree(argv);\n+\n+\treturn exit_status;\n }\n \n int uname(struct utsname *buf)\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 593bdbffe6..210f1b01a8 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -562,18 +562,18 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen);\n extern CRITICAL_SECTION pinfo_cs;\n \n /*\n- * A replacement of main() that adds win32 specific initialization.\n+ * Git, like most portable C applications, implements a main() function. On\n+ * Windows, this main() function would receive parameters encoded in the\n+ * current locale, but Git for Windows would prefer UTF-8 encoded  parameters.\n+ *\n+ * To make that happen, we still declare main() here, and then declare and\n+ * implement wmain() (which is the Unicode variant of main()) and compile with\n+ * -municode. This wmain() function reencodes the parameters from UTF-16 to\n+ * UTF-8 format, sets up a couple of other things as required on Windows, and\n+ * then hands off to the main() function.\n  */\n-\n-void mingw_startup(void);\n-#define main(c,v) dummy_decl_mingw_main(void); \\\n-static int mingw_main(c,v); \\\n-int main(int argc, const char **argv) \\\n-{ \\\n-\tmingw_startup(); \\\n-\treturn mingw_main(__argc, (void *)__argv); \\\n-} \\\n-static int mingw_main(c,v)\n+int wmain(int argc, const wchar_t **w_argv);\n+int main(int argc, const char **argv);\n \n /*\n  * Used by Pthread API implementation for Windows\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 9fc053cac0..6ddece0350 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -401,7 +401,7 @@ ifeq ($(uname_S),Windows)\n \t\tcompat/win32/trace2_win32_process_info.o \\\n \t\tcompat/win32/dirent.o\n \tCOMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\\\".exe\\\"\n-\tBASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE\n+\tBASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE\n \tEXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj\n \tPTHREAD_LIBS =\n \tlib =\n@@ -548,6 +548,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tETAGS_TARGET = ETAGS\n \tNO_POSIX_GOODIES = UnfortunatelyYes\n \tDEFAULT_HELP_FORMAT = html\n+\tBASIC_LDFLAGS += -municode\n \tCOMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32\n \tCOMPAT_CFLAGS += -DSTRIP_EXTENSION=\\\".exe\\\"\n \tCOMPAT_OBJS += compat/mingw.o compat/winansi.o \\\n-- \ngitgitgadget\n\n"},{"id":"377567","messageId":"71d85b58b66af94b6e85776f74a63774bfb91845.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 05/20] obstack: fix compiler warning","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:05:59Z","receivedAt":"2019-06-19T21:06:06Z","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\nMS Visual C suggests that the construct\n\n\tcondition ? (int) i : (ptrdiff_t) d\n\nis incorrect. Let's fix this by casting to ptrdiff_t also for the\npositive arm of the conditional.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/obstack.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/obstack.h b/compat/obstack.h\nindex ced94d0118..ae36ed6a66 100644\n--- a/compat/obstack.h\n+++ b/compat/obstack.h\n@@ -496,7 +496,7 @@ __extension__\t\t\t\t\t\t\t\t\\\n ( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk,\t\t\\\n   ((((h)->temp.tempint > 0\t\t\t\t\t\t\\\n     && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk))\t\\\n-   ? (int) ((h)->next_free = (h)->object_base\t\t\t\t\\\n+   ? (ptrdiff_t) ((h)->next_free = (h)->object_base\t\t\t\t\\\n \t    = (h)->temp.tempint + (char *) (h)->chunk)\t\t\t\\\n    : (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))\n \n-- \ngitgitgadget\n\n"},{"id":"377568","messageId":"99a2939cc2d4501d37e806de9273c8f9832b7849.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 09/20] msvc: define O_ACCMODE","fromName":"Philip Oakley via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:02Z","receivedAt":"2019-06-19T21:06:09Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: Philip Oakley <philipoakley@iee.org>\n\nThis constant is not defined in MSVC's headers.\n\nIn UCRT's fcntl.h, _O_RDONLY, _O_WRONLY and _O_RDWR are defined as 0, 1\nand 2, respectively. Yes, that means that UCRT breaks with the tradition\nthat O_RDWR == O_RDONLY | O_WRONLY.\n\nIt is a perfectly legal way to define those constants, though, therefore\nwe need to take care of defining O_ACCMODE accordingly.\n\nThis is particularly important in order to keep our \"open() can set\nerrno to EISDIR\" emulation working: it tests that (flags & O_ACCMODE) is\nnot identical to O_RDONLY before going on to test specifically whether\nthe file for which open() reported EACCES is, in fact, a directory.\n\nSigned-off-by: Philip Oakley <philipoakley@iee.org>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/msvc.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/compat/msvc.h b/compat/msvc.h\nindex 04b4750b87..d336d80670 100644\n--- a/compat/msvc.h\n+++ b/compat/msvc.h\n@@ -19,6 +19,8 @@\n #undef ERROR\n \n typedef int sigset_t;\n+/* open for reading, writing, or both (not in fcntl.h) */\n+#define O_ACCMODE     (_O_RDONLY | _O_WRONLY | _O_RDWR)\n \n #include \"compat/mingw.h\"\n \n-- \ngitgitgadget\n\n"},{"id":"377569","messageId":"1542e8abe5c40b6ebae5924e5912523a0f4aa4a1.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 10/20] msvc: mark a variable as non-const","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:02Z","receivedAt":"2019-06-19T21:06:09Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nVS2015 complains when using a const pointer in memcpy()/free().\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c | 5 ++++-\n 1 file changed, 4 insertions(+), 1 deletion(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 0d8713e515..d14d33308d 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1553,7 +1553,10 @@ static int try_shell_exec(const char *cmd, char *const *argv)\n \tif (prog) {\n \t\tint exec_id;\n \t\tint argc = 0;\n-\t\tconst char **argv2;\n+#ifndef _MSC_VER\n+\t\tconst\n+#endif\n+\t\tchar **argv2;\n \t\twhile (argv[argc]) argc++;\n \t\tALLOC_ARRAY(argv2, argc + 1);\n \t\targv2[0] = (char *)cmd;\t/* full path to the script file */\n-- \ngitgitgadget\n\n"},{"id":"377570","messageId":"7cfd0fc9b42eee9bac026f7541b6cceec215000b.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 12/20] msvc: define ftello()","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:04Z","receivedAt":"2019-06-19T21:06:12Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nIt is just called differently in MSVC's headers.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/msvc.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/compat/msvc.h b/compat/msvc.h\nindex d336d80670..d7525cf61d 100644\n--- a/compat/msvc.h\n+++ b/compat/msvc.h\n@@ -18,6 +18,8 @@\n \n #undef ERROR\n \n+#define ftello _ftelli64\n+\n typedef int sigset_t;\n /* open for reading, writing, or both (not in fcntl.h) */\n #define O_ACCMODE     (_O_RDONLY | _O_WRONLY | _O_RDWR)\n-- \ngitgitgadget\n\n"},{"id":"377571","messageId":"e7888bedbd0cd861a7e84d687dc624d1518cc67d.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 16/20] msvc: add a compile-time flag to allow detailed heap debugging","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:07Z","receivedAt":"2019-06-19T21:06:12Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nMS Visual C comes with a few neat features we can use to analyze the\nheap consumption (i.e. leaks, max memory, etc).\n\nWith this patch, we introduce support via the build-time flag\n`USE_MSVC_CRTDBG`.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c    | 6 ++++++\n config.mak.uname  | 4 ++++\n git-compat-util.h | 9 +++++++++\n 3 files changed, 19 insertions(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex c063ae62be..667285887a 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2411,6 +2411,12 @@ int wmain(int argc, const wchar_t **wargv)\n \n \ttrace2_initialize_clock();\n \n+#ifdef _MSC_VER\n+#ifdef USE_MSVC_CRTDBG\n+\t_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);\n+#endif\n+#endif\n+\n \tmaybe_redirect_std_handles();\n \n \t/* determine size of argv and environ conversion buffer */\ndiff --git a/config.mak.uname b/config.mak.uname\nindex b8c52e49d2..3fde48c64d 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -448,6 +448,10 @@ else\n endif\n \tBASIC_CFLAGS += $(sdk_libs) $(msvc_libs)\n \n+ifneq ($(USE_MSVC_CRTDBG),)\n+\t# Optionally enable memory leak reporting.\n+\tBASIC_CFLAGS += -DUSE_MSVC_CRTDBG\n+endif\n \tBASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1\n \t# Always give \"-Zi\" to the compiler and \"-debug\" to linker (even in\n \t# release mode) to force a PDB to be generated (like RelWithDebInfo).\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex cc0e7e9733..83be89de0a 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1,6 +1,15 @@\n #ifndef GIT_COMPAT_UTIL_H\n #define GIT_COMPAT_UTIL_H\n \n+#ifdef USE_MSVC_CRTDBG\n+/*\n+ * For these to work they must appear very early in each\n+ * file -- before most of the standard header files.\n+ */\n+#include <stdlib.h>\n+#include <crtdbg.h>\n+#endif\n+\n #define _FILE_OFFSET_BITS 64\n \n \n-- \ngitgitgadget\n\n"},{"id":"377572","messageId":"d9668558dd3dc006c45c5284cd43fbcf78ac094f.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 17/20] msvc: add pragmas for common warnings","fromName":"Philip Oakley via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:08Z","receivedAt":"2019-06-19T21:06:13Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: Philip Oakley <philipoakley@iee.org>\n\nMSVC can be overzealous about some warnings. Disable them.\n\nSigned-off-by: Philip Oakley <philipoakley@iee.org>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/msvc.h | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/compat/msvc.h b/compat/msvc.h\nindex d7525cf61d..1d7a8c6145 100644\n--- a/compat/msvc.h\n+++ b/compat/msvc.h\n@@ -6,6 +6,10 @@\n #include <malloc.h>\n #include <io.h>\n \n+#pragma warning(disable: 4018) /* signed/unsigned comparison */\n+#pragma warning(disable: 4244) /* type conversion, possible loss of data */\n+#pragma warning(disable: 4090) /* 'function' : different 'const' qualifiers (ALLOC_GROW etc.)*/\n+\n /* porting function */\n #define inline __inline\n #define __inline__ __inline\n-- \ngitgitgadget\n\n"},{"id":"377574","messageId":"245f28ac3beda03c980220657ccc6e4d75269c00.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 15/20] msvc: support building Git using MS Visual C++","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:06Z","receivedAt":"2019-06-19T21:06:15Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nWith this patch, Git can be built using the Microsoft toolchain, via:\n\n\tmake MSVC=1 [DEBUG=1]\n\nThird party libraries are built from source using the open source\n\"vcpkg\" tool set. See https://github.com/Microsoft/vcpkg\n\nOn a first build, the vcpkg tools and the third party libraries are\nautomatically downloaded and built. DLLs for the third party libraries\nare copied to the top-level (and t/helper) directory to facilitate\ndebugging. See compat/vcbuild/README.\n\nA series of .bat files are invoked by the Makefile to find the location\nof the installed version of Visual Studio and the associated compiler\ntools (essentially replicating the environment setup performed by a\n\"Developer Command Prompt\"). This should find the most recent VS2015 or\nVS2017 installation. Output from these scripts are used by the Makefile\nto define compiler and linker pathnames and -I and -L arguments.\n\nThe build produces .pdb files for both debug and release builds.\n\nNote: This commit was squashed from an organic series of commits\ndeveloped between 2016 and 2018 in Git for Windows' `master` branch.\nThis combined commit eliminates the obsolete commits related to fetching\nNuGet packages for third party libraries. It is difficult to use NuGet\npackages for C/C++ sources because they may be built by earlier versions\nof the MSVC compiler and have CRT version and linking issues.\n\nAdditionally, the C/C++ NuGet packages that we were using tended to not\nbe updated concurrently with the sources.  And in the case of cURL and\nOpenSSL, this could expose us to security issues.\n\nHelped-by: Yue Lin Ho <b8732003@student.nsysu.edu.tw>\nHelped-by: Philip Oakley <philipoakley@iee.org>\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Makefile                           |  42 +++++++-\n compat/mingw.c                     |   6 ++\n compat/vcbuild/.gitignore          |   3 +\n compat/vcbuild/README              |  39 +++++++\n compat/vcbuild/find_vs_env.bat     | 168 +++++++++++++++++++++++++++++\n compat/vcbuild/scripts/clink.pl    |  41 ++++++-\n compat/vcbuild/vcpkg_copy_dlls.bat |  39 +++++++\n compat/vcbuild/vcpkg_install.bat   |  80 ++++++++++++++\n config.mak.uname                   |  72 +++++++++++--\n 9 files changed, 474 insertions(+), 16 deletions(-)\n create mode 100644 compat/vcbuild/.gitignore\n create mode 100644 compat/vcbuild/find_vs_env.bat\n create mode 100644 compat/vcbuild/vcpkg_copy_dlls.bat\n create mode 100644 compat/vcbuild/vcpkg_install.bat\n\ndiff --git a/Makefile b/Makefile\nindex 3cf8cc8ffd..2b66d5a3f3 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1240,7 +1240,7 @@ endif\n \n ifdef SANE_TOOL_PATH\n SANE_TOOL_PATH_SQ = $(subst ','\\'',$(SANE_TOOL_PATH))\n-BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix \"$(SANE_TOOL_PATH_SQ)\"|'\n+BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'\n PATH := $(SANE_TOOL_PATH):${PATH}\n else\n BROKEN_PATH_FIX = '/^\\# @@BROKEN_PATH_FIX@@$$/d'\n@@ -2873,6 +2873,33 @@ install: all\n \t$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n \t$(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n \t$(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'\n+ifdef MSVC\n+\t# We DO NOT install the individual foo.o.pdb files because they\n+\t# have already been rolled up into the exe's pdb file.\n+\t# We DO NOT have pdb files for the builtin commands (like git-status.exe)\n+\t# because it is just a copy/hardlink of git.exe, rather than a unique binary.\n+\t$(INSTALL) git.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) git-shell.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) git-upload-pack.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) git-credential-store.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-daemon.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-fast-import.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-http-backend.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-http-fetch.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-http-push.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-imap-send.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-remote-http.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-remote-testsvn.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-sh-i18n--envsubst.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-show-index.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+ifndef DEBUG\n+\t$(INSTALL) $(vcpkg_rel_bin)/*.dll '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) $(vcpkg_rel_bin)/*.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+else\n+\t$(INSTALL) $(vcpkg_dbg_bin)/*.dll '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) $(vcpkg_dbg_bin)/*.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+endif\n+endif\n \t$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'\n \t$(INSTALL) -m 644 mergetools/* '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'\n@@ -3085,6 +3112,19 @@ endif\n \t$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS\n \t$(RM) GIT-USER-AGENT GIT-PREFIX\n \t$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT-PYTHON-VARS\n+ifdef MSVC\n+\t$(RM) $(patsubst %.o,%.o.pdb,$(OBJECTS))\n+\t$(RM) $(patsubst %.exe,%.pdb,$(OTHER_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.iobj,$(OTHER_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.ipdb,$(OTHER_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.pdb,$(PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.iobj,$(PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.ipdb,$(PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.pdb,$(TEST_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.iobj,$(TEST_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.ipdb,$(TEST_PROGRAMS))\n+\t$(RM) compat/vcbuild/MSVC-DEFS-GEN\n+endif\n \n .PHONY: all install profile-clean cocciclean clean strip\n .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex d14d33308d..c063ae62be 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2388,6 +2388,12 @@ static void maybe_redirect_std_handles(void)\n \t\t\t\t  GENERIC_WRITE, FILE_FLAG_NO_BUFFERING);\n }\n \n+#ifdef _MSC_VER\n+#ifdef _DEBUG\n+#include <crtdbg.h>\n+#endif\n+#endif\n+\n /*\n  * We implement wmain() and compile with -municode, which would\n  * normally ignore main(), but we call the latter from the former\ndiff --git a/compat/vcbuild/.gitignore b/compat/vcbuild/.gitignore\nnew file mode 100644\nindex 0000000000..8f8b794ef3\n--- /dev/null\n+++ b/compat/vcbuild/.gitignore\n@@ -0,0 +1,3 @@\n+/vcpkg/\n+/MSVC-DEFS-GEN\n+/VCPKG-DEFS\ndiff --git a/compat/vcbuild/README b/compat/vcbuild/README\nindex 60fd873fe8..b633e7db98 100644\n--- a/compat/vcbuild/README\n+++ b/compat/vcbuild/README\n@@ -1,3 +1,42 @@\n+The Steps to Build Git with VS2015 or VS2017 from the command line.\n+\n+1. Install the \"vcpkg\" open source package manager and build essential\n+   third-party libraries.  The steps for this have been captured in a\n+   set of convenience scripts.  These can be run from a stock Command\n+   Prompt or from an SDK bash window:\n+\n+   $ cd <repo_root>\n+   $ ./compat/vcbuild/vcpkg_install.bat\n+\n+   The vcpkg tools and all of the third-party sources will be installed\n+   in this folder:\n+      <repo_root>/compat/vcbuild/vcpkg/\n+\n+   A file will be created with a set of Makefile macros pointing to a\n+   unified \"include\", \"lib\", and \"bin\" directory (release and debug) for\n+   all of the required packages.  This file will be included by the main\n+   Makefile:\n+      <repo_root>/compat/vcbuild/MSVC-DEFS-GEN\n+\n+2. OPTIONALLY copy the third-party *.dll and *.pdb files into the repo\n+   root to make it easier to run and debug git.exe without having to\n+   manipulate your PATH.  This is especially true for debug sessions in\n+   Visual Studio.\n+\n+   Use ONE of the following forms which should match how you want to\n+   compile git.exe.\n+\n+   $ ./compat/vcbuild/vcpkg_copy_packages.bat debug\n+   $ ./compat/vcbuild/vcpkg_copy_packages.bat release\n+\n+3. Build git using MSVC from an SDK bash window using one of the\n+   following commands:\n+\n+   $ make MSVC=1\n+   $ make MSVC=1 DEBUG=1\n+\n+================================================================\n+\n The Steps of Build Git with VS2008\n \n 1. You need the build environment, which contains the Git dependencies\ndiff --git a/compat/vcbuild/find_vs_env.bat b/compat/vcbuild/find_vs_env.bat\nnew file mode 100644\nindex 0000000000..40194dd230\n--- /dev/null\n+++ b/compat/vcbuild/find_vs_env.bat\n@@ -0,0 +1,168 @@\n+@ECHO OFF\n+REM ================================================================\n+REM You can use either GCC (the default) or MSVC to build git\n+REM using the GIT-SDK command line tools.\n+REM        $ make\n+REM        $ make MSVC=1\n+REM\n+REM GIT-SDK BASH windows inherit environment variables with all of\n+REM the bin/lib/include paths for GCC.  It DOES NOT inherit values\n+REM for the corresponding MSVC tools.\n+REM\n+REM During normal (non-git) Windows development, you launch one\n+REM of the provided \"developer command prompts\" to set environment\n+REM variables for the MSVC tools.\n+REM\n+REM Therefore, to allow MSVC command line builds of git from BASH\n+REM and MAKE, we must blend these two different worlds.  This script\n+REM attempts to do that.\n+REM ================================================================\n+REM This BAT file starts in a plain (non-developer) command prompt,\n+REM searches for the \"best\" commmand prompt setup script, installs\n+REM it into the current CMD process, and exports the various MSVC\n+REM environment variables for use by MAKE.\n+REM\n+REM The output of this script should be written to a make \"include\n+REM file\" and referenced by the top-level Makefile.\n+REM\n+REM See \"config.mak.uname\" (look for compat/vcbuild/MSVC-DEFS-GEN).\n+REM ================================================================\n+REM The provided command prompts are custom to each VS release and\n+REM filled with lots of internal knowledge (such as Registry settings);\n+REM even their names vary by release, so it is not appropriate for us\n+REM to look inside them.  Rather, just run them in a subordinate\n+REM process and extract the settings we need.\n+REM ================================================================\n+REM\n+REM Current (VS2017 and beyond)\n+REM -------------------\n+REM Visual Studio 2017 introduced a new installation layout and\n+REM support for side-by-side installation of multiple versions of\n+REM VS2017.  Furthermore, these can all coexist with installations\n+REM of previous versions of VS (which have a completely different\n+REM layout on disk).\n+REM\n+REM VS2017 Update 2 introduced a \"vswhere.exe\" command:\n+REM https://github.com/Microsoft/vswhere\n+REM https://blogs.msdn.microsoft.com/heaths/2017/02/25/vswhere-available/\n+REM https://blogs.msdn.microsoft.com/vcblog/2017/03/06/finding-the-visual-c-compiler-tools-in-visual-studio-2017/\n+REM\n+REM VS2015\n+REM ------\n+REM Visual Studio 2015 uses the traditional VcVarsAll.\n+REM\n+REM Earlier Versions\n+REM ----------------\n+REM Currently unsupported.\n+REM\n+REM ================================================================\n+REM Note: Throughout this script we use \"dir <path> && <cmd>\" rather\n+REM than \"if exist <path>\" because of script problems with pathnames\n+REM containing spaces.\n+REM ================================================================\n+\n+REM Sanitize PATH to prevent git-sdk paths from confusing \"wmic.exe\"\n+REM (called internally in some of the system BAT files).\n+SET PATH=%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;\n+\n+REM ================================================================\n+\n+:current\n+   SET vs_where=C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe\n+   dir \"%vs_where%\" >nul 2>nul && GOTO have_vs_where\n+   GOTO not_2017\n+\n+:have_vs_where\n+   REM Try to use VsWhere to get the location of VsDevCmd.\n+\n+   REM Keep VsDevCmd from cd'ing away.\n+   SET VSCMD_START_DIR=.\n+\n+   REM Get the root of the VS product installation.\n+   FOR /F \"usebackq tokens=*\" %%i IN (`\"%vs_where%\" -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath`) DO @SET vs_ip=%%i\n+\n+   SET vs_devcmd=%vs_ip%\\Common7\\Tools\\VsDevCmd.bat\n+   dir \"%vs_devcmd%\" >nul 2>nul && GOTO have_vs_devcmd\n+   GOTO not_2017\n+\n+:have_vs_devcmd\n+   REM Use VsDevCmd to setup the environment of this process.\n+   REM Setup CL for building 64-bit apps using 64-bit tools.\n+   @call \"%vs_devcmd%\" -no_logo -arch=x64 -host_arch=x64\n+\n+   SET tgt=%VSCMD_ARG_TGT_ARCH%\n+\n+   SET mn=%VCToolsInstallDir%\n+   SET msvc_includes=-I\"%mn%INCLUDE\"\n+   SET msvc_libs=-L\"%mn%lib\\%tgt%\"\n+   SET msvc_bin_dir=%mn%bin\\Host%VSCMD_ARG_HOST_ARCH%\\%tgt%\n+\n+   SET sdk_dir=%WindowsSdkDir%\n+   SET sdk_ver=%WindowsSDKVersion%\n+   SET si=%sdk_dir%Include\\%sdk_ver%\n+   SET sdk_includes=-I\"%si%ucrt\" -I\"%si%um\" -I\"%si%shared\"\n+   SET sl=%sdk_dir%lib\\%sdk_ver%\n+   SET sdk_libs=-L\"%sl%ucrt\\%tgt%\" -L\"%sl%um\\%tgt%\"\n+\n+   SET vs_ver=%VisualStudioVersion%\n+\n+   GOTO print_vars\n+\n+REM ================================================================\n+\n+:not_2017\n+   REM See if VS2015 is installed.\n+\n+   SET vs_2015_bat=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat\n+   dir \"%vs_2015_bat%\" >nul 2>nul && GOTO have_vs_2015\n+   GOTO not_2015\n+\n+:have_vs_2015\n+   REM Use VcVarsAll like the \"x64 Native\" command prompt.\n+   REM Setup CL for building 64-bit apps using 64-bit tools.\n+   @call \"%vs_2015_bat%\" amd64\n+\n+   REM Note that in VS2015 they use \"x64\" in some contexts and \"amd64\" in others.\n+   SET mn=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\\n+   SET msvc_includes=-I\"%mn%INCLUDE\"\n+   SET msvc_libs=-L\"%mn%lib\\amd64\"\n+   SET msvc_bin_dir=%mn%bin\\amd64\n+\n+   SET sdk_dir=%WindowsSdkDir%\n+   SET sdk_ver=%WindowsSDKVersion%\n+   SET si=%sdk_dir%Include\\%sdk_ver%\n+   SET sdk_includes=-I\"%si%ucrt\" -I\"%si%um\" -I\"%si%shared\" -I\"%si%winrt\"\n+   SET sl=%sdk_dir%lib\\%sdk_ver%\n+   SET sdk_libs=-L\"%sl%ucrt\\x64\" -L\"%sl%um\\x64\"\n+\n+   SET vs_ver=%VisualStudioVersion%\n+\n+   GOTO print_vars\n+\n+REM ================================================================\n+\n+:not_2015\n+   echo \"ERROR: unsupported VS version (older than VS2015)\" >&2\n+   EXIT /B 1\n+\n+REM ================================================================\n+\n+:print_vars\n+   REM Dump the essential vars to stdout to allow the main\n+   REM Makefile to include it.  See config.mak.uname.\n+   REM Include DOS-style and BASH-style path for bin dir.\n+\n+   echo msvc_bin_dir=%msvc_bin_dir%\n+   SET X1=%msvc_bin_dir:C:=/C%\n+   SET X2=%X1:\\=/%\n+   echo msvc_bin_dir_msys=%X2%\n+\n+   echo msvc_includes=%msvc_includes%\n+   echo msvc_libs=%msvc_libs%\n+\n+   echo sdk_includes=%sdk_includes%\n+   echo sdk_libs=%sdk_libs%\n+\n+   echo vs_ver=%vs_ver%\n+\n+   EXIT /B 0\ndiff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl\nindex a87d0da512..c7b021bfac 100755\n--- a/compat/vcbuild/scripts/clink.pl\n+++ b/compat/vcbuild/scripts/clink.pl\n@@ -12,32 +12,62 @@\n use strict;\n my @args = ();\n my @cflags = ();\n+my @lflags = ();\n my $is_linking = 0;\n+my $is_debug = 0;\n while (@ARGV) {\n \tmy $arg = shift @ARGV;\n-\tif (\"$arg\" =~ /^-[DIMGO]/) {\n+\tif (\"$arg\" eq \"-DDEBUG\") {\n+\t    # Some vcpkg-based libraries have different names for release\n+\t    # and debug versions.  This hack assumes that -DDEBUG comes\n+\t    # before any \"-l*\" flags.\n+\t    $is_debug = 1;\n+\t}\n+\tif (\"$arg\" =~ /^-[DIMGOZ]/) {\n \t\tpush(@cflags, $arg);\n \t} elsif (\"$arg\" eq \"-o\") {\n \t\tmy $file_out = shift @ARGV;\n \t\tif (\"$file_out\" =~ /exe$/) {\n \t\t\t$is_linking = 1;\n+\t\t\t# Create foo.exe and foo.pdb\n \t\t\tpush(@args, \"-OUT:$file_out\");\n \t\t} else {\n+\t\t\t# Create foo.o and foo.o.pdb\n \t\t\tpush(@args, \"-Fo$file_out\");\n+\t\t\tpush(@args, \"-Fd$file_out.pdb\");\n \t\t}\n \t} elsif (\"$arg\" eq \"-lz\") {\n+\t    if ($is_debug) {\n+\t\tpush(@args, \"zlibd.lib\");\n+\t    } else{\n \t\tpush(@args, \"zlib.lib\");\n+\t    }\n \t} elsif (\"$arg\" eq \"-liconv\") {\n-\t\tpush(@args, \"iconv.lib\");\n+\t\tpush(@args, \"libiconv.lib\");\n \t} elsif (\"$arg\" eq \"-lcrypto\") {\n \t\tpush(@args, \"libeay32.lib\");\n \t} elsif (\"$arg\" eq \"-lssl\") {\n \t\tpush(@args, \"ssleay32.lib\");\n \t} elsif (\"$arg\" eq \"-lcurl\") {\n-\t\tpush(@args, \"libcurl.lib\");\n+\t\tmy $lib = \"\";\n+\t\t# Newer vcpkg definitions call this libcurl_imp.lib; Do we\n+\t\t# need to use that instead?\n+\t\tforeach my $flag (@lflags) {\n+\t\t\tif ($flag =~ /^-LIBPATH:(.*)/) {\n+\t\t\t\tforeach my $l (\"libcurl_imp.lib\", \"libcurl.lib\") {\n+\t\t\t\t\tif (-f \"$1/$l\") {\n+\t\t\t\t\t\t$lib = $l;\n+\t\t\t\t\t\tlast;\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t\tpush(@args, $lib);\n+\t} elsif (\"$arg\" eq \"-lexpat\") {\n+\t\tpush(@args, \"expat.lib\");\n \t} elsif (\"$arg\" =~ /^-L/ && \"$arg\" ne \"-LTCG\") {\n \t\t$arg =~ s/^-L/-LIBPATH:/;\n-\t\tpush(@args, $arg);\n+\t\tpush(@lflags, $arg);\n \t} elsif (\"$arg\" =~ /^-R/) {\n \t\t# eat\n \t} else {\n@@ -45,10 +75,11 @@\n \t}\n }\n if ($is_linking) {\n+\tpush(@args, @lflags);\n \tunshift(@args, \"link.exe\");\n } else {\n \tunshift(@args, \"cl.exe\");\n \tpush(@args, @cflags);\n }\n-#printf(\"**** @args\\n\");\n+printf(STDERR \"**** @args\\n\\n\\n\") if (!defined($ENV{'QUIET_GEN'}));\n exit (system(@args) != 0);\ndiff --git a/compat/vcbuild/vcpkg_copy_dlls.bat b/compat/vcbuild/vcpkg_copy_dlls.bat\nnew file mode 100644\nindex 0000000000..13661c14f8\n--- /dev/null\n+++ b/compat/vcbuild/vcpkg_copy_dlls.bat\n@@ -0,0 +1,39 @@\n+@ECHO OFF\n+REM ================================================================\n+REM This script is an optional step. It copies the *.dll and *.pdb\n+REM files (created by vcpkg_install.bat) into the top-level directory\n+REM of the repo so that you can type \"./git.exe\" and find them without\n+REM having to fixup your PATH.\n+REM\n+REM NOTE: Because the names of some DLL files change between DEBUG and\n+REM NOTE: RELEASE builds when built using \"vcpkg.exe\", you will need\n+REM NOTE: to copy up the corresponding version.\n+REM ================================================================\n+\n+\tSETLOCAL EnableDelayedExpansion\n+\n+\t@FOR /F \"delims=\" %%D IN (\"%~dp0\") DO @SET cwd=%%~fD\n+\tcd %cwd%\n+\n+\tSET arch=x64-windows\n+\tSET inst=%cwd%vcpkg\\installed\\%arch%\n+\n+\tIF [%1]==[release] (\n+\t\techo Copying RELEASE mode DLLs to repo root...\n+\t) ELSE IF [%1]==[debug] (\n+\t\tSET inst=%inst%\\debug\n+\t\techo Copying DEBUG mode DLLs to repo root...\n+\t) ELSE (\n+\t\techo ERROR: Invalid argument.\n+\t\techo Usage: %~0 release\n+\t\techo Usage: %~0 debug\n+\t\tEXIT /B 1\n+\t)\n+\n+\txcopy /e/s/v/y %inst%\\bin\\*.dll ..\\..\\\n+\txcopy /e/s/v/y %inst%\\bin\\*.pdb ..\\..\\\n+\n+\txcopy /e/s/v/y %inst%\\bin\\*.dll ..\\..\\t\\helper\\\n+\txcopy /e/s/v/y %inst%\\bin\\*.pdb ..\\..\\t\\helper\\\n+\n+\tEXIT /B 0\ndiff --git a/compat/vcbuild/vcpkg_install.bat b/compat/vcbuild/vcpkg_install.bat\nnew file mode 100644\nindex 0000000000..ebd0bad242\n--- /dev/null\n+++ b/compat/vcbuild/vcpkg_install.bat\n@@ -0,0 +1,80 @@\n+@ECHO OFF\n+REM ================================================================\n+REM This script installs the \"vcpkg\" source package manager and uses\n+REM it to build the third-party libraries that git requires when it\n+REM is built using MSVC.\n+REM\n+REM [1] Install VCPKG.\n+REM     [a] Create <root>/compat/vcbuild/vcpkg/\n+REM     [b] Download \"vcpkg\".\n+REM     [c] Compile using the currently installed version of VS.\n+REM     [d] Create <root>/compat/vcbuild/vcpkg/vcpkg.exe\n+REM\n+REM [2] Install third-party libraries.\n+REM     [a] Download each (which may also install CMAKE).\n+REM     [b] Compile in RELEASE mode and install in:\n+REM         vcpkg/installed/<arch>/{bin,lib}\n+REM     [c] Compile in DEBUG mode and install in:\n+REM         vcpkg/installed/<arch>/debug/{bin,lib}\n+REM     [d] Install headers in:\n+REM         vcpkg/installed/<arch>/include\n+REM\n+REM [3] Create a set of MAKE definitions for the top-level\n+REM     Makefile to allow \"make MSVC=1\" to find the above\n+REM     third-party libraries.\n+REM     [a] Write vcpkg/VCPGK-DEFS\n+REM\n+REM https://blogs.msdn.microsoft.com/vcblog/2016/09/19/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows/\n+REM https://github.com/Microsoft/vcpkg\n+REM https://vcpkg.readthedocs.io/en/latest/\n+REM ================================================================\n+\n+\tSETLOCAL EnableDelayedExpansion\n+\n+\t@FOR /F \"delims=\" %%D IN (\"%~dp0\") DO @SET cwd=%%~fD\n+\tcd %cwd%\n+\n+\tdir vcpkg\\vcpkg.exe >nul 2>nul && GOTO :install_libraries\n+\n+\techo Fetching vcpkg in %cwd%vcpkg\n+\tgit.exe clone https://github.com/Microsoft/vcpkg vcpkg\n+\tIF ERRORLEVEL 1 ( EXIT /B 1 )\n+\n+\tcd vcpkg\n+\techo Building vcpkg\n+\tpowershell -exec bypass scripts\\bootstrap.ps1\n+\tIF ERRORLEVEL 1 ( EXIT /B 1 )\n+\n+\techo Successfully installed %cwd%vcpkg\\vcpkg.exe\n+\n+:install_libraries\n+\tSET arch=x64-windows\n+\n+\techo Installing third-party libraries...\n+\tFOR %%i IN (zlib expat libiconv openssl libssh2 curl) DO (\n+\t    cd %cwd%vcpkg\n+\t    IF NOT EXIST \"packages\\%%i_%arch%\" CALL :sub__install_one %%i\n+\t    IF ERRORLEVEL 1 ( EXIT /B 1 )\n+\t)\n+\n+:install_defines\n+\tcd %cwd%\n+\tSET inst=%cwd%vcpkg\\installed\\%arch%\n+\n+\techo vcpkg_inc=-I\"%inst%\\include\">VCPKG-DEFS\n+\techo vcpkg_rel_lib=-L\"%inst%\\lib\">>VCPKG-DEFS\n+\techo vcpkg_rel_bin=\"%inst%\\bin\">>VCPKG-DEFS\n+\techo vcpkg_dbg_lib=-L\"%inst%\\debug\\lib\">>VCPKG-DEFS\n+\techo vcpkg_dbg_bin=\"%inst%\\debug\\bin\">>VCPKG-DEFS\n+\n+\tEXIT /B 0\n+\n+\n+:sub__install_one\n+\techo     Installing package %1...\n+\n+\t.\\vcpkg.exe install %1:%arch%\n+\tIF ERRORLEVEL 1 ( EXIT /B 1 )\n+\n+\techo     Finished %1\n+\tgoto :EOF\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 473613a20d..b8c52e49d2 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -1,5 +1,9 @@\n # Platform specific Makefile tweaks based on uname detection\n \n+# Define NO_SAFESEH if you need MSVC/Visual Studio to ignore the lack of\n+# Microsoft's Safe Exception Handling in libraries (such as zlib).\n+# Typically required for VS2013+/32-bit compilation on Vista+ versions.\n+\n uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')\n uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')\n@@ -11,6 +15,19 @@ ifdef MSVC\n \t# avoid the MingW and Cygwin configuration sections\n \tuname_S := Windows\n \tuname_O := Windows\n+\n+\t# Generate and include makefile variables that point to the\n+\t# currently installed set of MSVC command line tools.\n+compat/vcbuild/MSVC-DEFS-GEN: compat/vcbuild/find_vs_env.bat\n+\t@\"$<\" | tr '\\\\' / >\"$@\"\n+include compat/vcbuild/MSVC-DEFS-GEN\n+\n+\t# See if vcpkg and the vcpkg-build versions of the third-party\n+\t# libraries that we use are installed.  We include the result\n+\t# to get $(vcpkg_*) variables defined for the Makefile.\n+compat/vcbuild/VCPKG-DEFS: compat/vcbuild/vcpkg_install.bat\n+\t@\"$<\"\n+include compat/vcbuild/VCPKG-DEFS\n endif\n \n # We choose to avoid \"if .. else if .. else .. endif endif\"\n@@ -356,6 +373,19 @@ endif\n ifeq ($(uname_S),Windows)\n \tGIT_VERSION := $(GIT_VERSION).MSVC\n \tpathsep = ;\n+\t# Assume that this is built in Git for Windows' SDK\n+\tifeq (MINGW32,$(MSYSTEM))\n+\t\tprefix = /mingw32\n+\telse\n+\t\tprefix = /mingw64\n+\tendif\n+\t# Prepend MSVC 64-bit tool-chain to PATH.\n+\t#\n+\t# A regular Git Bash *does not* have cl.exe in its $PATH. As there is a\n+\t# link.exe next to, and required by, cl.exe, we have to prepend this\n+\t# onto the existing $PATH.\n+\t#\n+\tSANE_TOOL_PATH ?= $(msvc_bin_dir_msys)\n \tHAVE_ALLOCA_H = YesPlease\n \tNO_PREAD = YesPlease\n \tNEEDS_CRYPTO_WITH_SSL = YesPlease\n@@ -368,11 +398,14 @@ ifeq ($(uname_S),Windows)\n \tNO_STRCASESTR = YesPlease\n \tNO_STRLCPY = YesPlease\n \tNO_MEMMEM = YesPlease\n-\t# NEEDS_LIBICONV = YesPlease\n-\tNO_ICONV = YesPlease\n+\tNEEDS_LIBICONV = YesPlease\n \tNO_STRTOUMAX = YesPlease\n \tNO_MKDTEMP = YesPlease\n-\tSNPRINTF_RETURNS_BOGUS = YesPlease\n+\tNO_INTTYPES_H = YesPlease\n+\t# VS2015 with UCRT claims that snprintf and friends are C99 compliant,\n+\t# so we don't need this:\n+\t#\n+\t#   SNPRINTF_RETURNS_BOGUS = YesPlease\n \tNO_SVN_TESTS = YesPlease\n \tRUNTIME_PREFIX = YesPlease\n \tHAVE_WPGMPTR = YesWeDo\n@@ -385,7 +418,6 @@ ifeq ($(uname_S),Windows)\n \tNO_REGEX = YesPlease\n \tNO_GETTEXT = YesPlease\n \tNO_PYTHON = YesPlease\n-\tBLK_SHA1 = YesPlease\n \tETAGS_TARGET = ETAGS\n \tNO_POSIX_GOODIES = UnfortunatelyYes\n \tNATIVE_CRLF = YesPlease\n@@ -394,24 +426,44 @@ ifeq ($(uname_S),Windows)\n \tCC = compat/vcbuild/scripts/clink.pl\n \tAR = compat/vcbuild/scripts/lib.pl\n \tCFLAGS =\n-\tBASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE\n+\tBASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE\n \tCOMPAT_OBJS = compat/msvc.o compat/winansi.o \\\n \t\tcompat/win32/path-utils.o \\\n \t\tcompat/win32/pthread.o compat/win32/syslog.o \\\n \t\tcompat/win32/trace2_win32_process_info.o \\\n \t\tcompat/win32/dirent.o\n-\tCOMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\\\".exe\\\"\n+\tCOMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\\\".exe\\\"\n \tBASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE\n-\tEXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj\n+\t# invalidcontinue.obj allows Git's source code to close the same file\n+\t# handle twice, or to access the osfhandle of an already-closed stdout\n+\t# See https://msdn.microsoft.com/en-us/library/ms235330.aspx\n+\tEXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib\n \tPTHREAD_LIBS =\n \tlib =\n+\tBASIC_CFLAGS += $(vcpkg_inc) $(sdk_includes) $(msvc_includes)\n+ifndef DEBUG\n+\tBASIC_CFLAGS += $(vcpkg_rel_lib)\n+else\n+\tBASIC_CFLAGS += $(vcpkg_dbg_lib)\n+endif\n+\tBASIC_CFLAGS += $(sdk_libs) $(msvc_libs)\n+\n \tBASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1\n+\t# Always give \"-Zi\" to the compiler and \"-debug\" to linker (even in\n+\t# release mode) to force a PDB to be generated (like RelWithDebInfo).\n+\tBASIC_CFLAGS += -Zi\n+\tBASIC_LDFLAGS += -debug -Zf\n+\n+ifdef NO_SAFESEH\n+\tLDFLAGS += -SAFESEH:NO\n+endif\n+\n ifndef DEBUG\n-\tBASIC_CFLAGS += -GL -Os -MD\n-\tBASIC_LDFLAGS += -LTCG\n+\tBASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG\n+\tBASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP\n \tAR += -LTCG\n else\n-\tBASIC_CFLAGS += -Zi -MDd\n+\tBASIC_CFLAGS += -MDd -DDEBUG -D_DEBUG\n endif\n \tX = .exe\n \n-- \ngitgitgadget\n\n"},{"id":"377573","messageId":"51a20ff2dfb864fb5fb209386764e62d71bf1069.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 19/20] msvc: avoid debug assertion windows in Debug Mode","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:09Z","receivedAt":"2019-06-19T21:06:17Z","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\nFor regular debugging, it is pretty helpful when a debug assertion in a\nrunning application triggers a window that offers to start the debugger.\n\nHowever, when running the test suite, it is not so helpful, in\nparticular when the debug assertions are then suppressed anyway because\nwe disable the invalid parameter checking (via invalidcontinue.obj, see\nthe comment in config.mak.uname about that object for more information).\n\nSo let's simply disable that window in Debug Mode (it is already\ndisabled in Release Mode).\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex d01e88c2f8..433838391f 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2437,6 +2437,10 @@ int wmain(int argc, const wchar_t **wargv)\n \ttrace2_initialize_clock();\n \n #ifdef _MSC_VER\n+#ifdef _DEBUG\n+\t_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);\n+#endif\n+\n #ifdef USE_MSVC_CRTDBG\n \t_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);\n #endif\n-- \ngitgitgadget\n\n"},{"id":"377575","messageId":"4d44d1fab18a3ed59d9fbea4f39ab9b6c1f03d3d.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 20/20] msvc: ignore .dll and incremental compile output","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:10Z","receivedAt":"2019-06-19T21:06:17Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nIgnore .dll files copied into the top-level directory.\nIgnore MSVC incremental compiler output files.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .gitignore | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/.gitignore b/.gitignore\nindex 2374f77a1a..ba0e52c4d1 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -226,6 +226,11 @@\n *.user\n *.idb\n *.pdb\n+*.ilk\n+*.iobj\n+*.ipdb\n+*.dll\n+.vs/\n /Debug/\n /Release/\n *.dSYM\n-- \ngitgitgadget\n"},{"id":"377576","messageId":"f528883d97011128d77061c4976655b80a7e7b14.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 13/20] msvc: fix detect_msys_tty()","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:05Z","receivedAt":"2019-06-19T21:06:19Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nThe ntstatus.h header is only available in MINGW.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/winansi.c | 13 +++++++++++++\n 1 file changed, 13 insertions(+)\n\ndiff --git a/compat/winansi.c b/compat/winansi.c\nindex f4f08237f9..11cd9b82cc 100644\n--- a/compat/winansi.c\n+++ b/compat/winansi.c\n@@ -544,7 +544,20 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)\n #ifdef DETECT_MSYS_TTY\n \n #include <winternl.h>\n+\n+#if defined(_MSC_VER)\n+\n+typedef struct _OBJECT_NAME_INFORMATION\n+{\n+\tUNICODE_STRING Name;\n+\tWCHAR NameBuffer[0];\n+} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;\n+\n+#define ObjectNameInformation 1\n+\n+#else\n #include <ntstatus.h>\n+#endif\n \n static void detect_msys_tty(int fd)\n {\n-- \ngitgitgadget\n\n"},{"id":"377577","messageId":"c883f037e0c6fb408dbe0350f264c0b41e5623db.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 18/20] msvc: do not pretend to support all signals","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:08Z","receivedAt":"2019-06-19T21:06:19Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nThis special-cases various signals that are not supported on Windows,\nsuch as SIGPIPE. These cause the UCRT to throw asserts (at least in\ndebug mode).\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c | 25 +++++++++++++++++++++++++\n 1 file changed, 25 insertions(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 667285887a..d01e88c2f8 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2119,8 +2119,33 @@ int mingw_raise(int sig)\n \t\t\tsigint_fn(SIGINT);\n \t\treturn 0;\n \n+#if defined(_MSC_VER)\n+\tcase SIGILL:\n+\tcase SIGFPE:\n+\tcase SIGSEGV:\n+\tcase SIGTERM:\n+\tcase SIGBREAK:\n+\tcase SIGABRT:\n+\tcase SIGABRT_COMPAT:\n+\t\t/*\n+\t\t * The <signal.h> header in the MS C Runtime defines 8 signals\n+\t\t * as being supported on the platform. Anything else causes an\n+\t\t * \"Invalid signal or error\" (which in DEBUG builds causes the\n+\t\t * Abort/Retry/Ignore dialog). We by-pass the CRT for things we\n+\t\t * already know will fail.\n+\t\t */\n+\t\treturn raise(sig);\n+\tdefault:\n+\t\terrno = EINVAL;\n+\t\treturn -1;\n+\n+#else\n+\n \tdefault:\n \t\treturn raise(sig);\n+\n+#endif\n+\n \t}\n }\n \n-- \ngitgitgadget\n\n"},{"id":"377578","messageId":"63bf9f1f9239280359c0086375117f984ae72dc1.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 14/20] msvc: update Makefile to allow for spaces in the compiler path","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:06Z","receivedAt":"2019-06-19T21:06:21Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nIt is quite common that MS Visual C++ is installed into a location whose\npath contains spaces, therefore we need to quote it.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Makefile | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 8a7e235352..3cf8cc8ffd 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1240,7 +1240,7 @@ endif\n \n ifdef SANE_TOOL_PATH\n SANE_TOOL_PATH_SQ = $(subst ','\\'',$(SANE_TOOL_PATH))\n-BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'\n+BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix \"$(SANE_TOOL_PATH_SQ)\"|'\n PATH := $(SANE_TOOL_PATH):${PATH}\n else\n BROKEN_PATH_FIX = '/^\\# @@BROKEN_PATH_FIX@@$$/d'\n-- \ngitgitgadget\n\n"},{"id":"377579","messageId":"90ac088d22359de9c86e7e5ee54cfb59071b1cff.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 04/20] cache-tree/blame: avoid reusing the DEBUG constant","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:05:58Z","receivedAt":"2019-06-19T21:06:21Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nIn MS Visual C, the `DEBUG` constant is set automatically whenever\ncompiling with debug information.\n\nThis is clearly not what was intended in `cache-tree.c` nor in\n`builtin/blame.c`, so let's use a less ambiguous name there.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin/blame.c |  6 +++---\n cache-tree.c    | 14 +++++++-------\n 2 files changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 21cde57e71..50e3d4a265 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -59,8 +59,8 @@ static size_t blame_date_width;\n \n static struct string_list mailmap = STRING_LIST_INIT_NODUP;\n \n-#ifndef DEBUG\n-#define DEBUG 0\n+#ifndef DEBUG_BLAME\n+#define DEBUG_BLAME 0\n #endif\n \n static unsigned blame_move_score;\n@@ -1062,7 +1062,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \tif (blame_copy_score)\n \t\tsb.copy_score = blame_copy_score;\n \n-\tsb.debug = DEBUG;\n+\tsb.debug = DEBUG_BLAME;\n \tsb.on_sanity_fail = &sanity_check_on_fail;\n \n \tsb.show_root = show_root;\ndiff --git a/cache-tree.c b/cache-tree.c\nindex b13bfaf71e..706ffcf188 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -6,8 +6,8 @@\n #include \"object-store.h\"\n #include \"replace-object.h\"\n \n-#ifndef DEBUG\n-#define DEBUG 0\n+#ifndef DEBUG_CACHE_TREE\n+#define DEBUG_CACHE_TREE 0\n #endif\n \n struct cache_tree *cache_tree(void)\n@@ -111,7 +111,7 @@ static int do_invalidate_path(struct cache_tree *it, const char *path)\n \tint namelen;\n \tstruct cache_tree_sub *down;\n \n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \tfprintf(stderr, \"cache-tree invalidate <%s>\\n\", path);\n #endif\n \n@@ -398,7 +398,7 @@ static int update_one(struct cache_tree *it,\n \t\tstrbuf_addf(&buffer, \"%o %.*s%c\", mode, entlen, path + baselen, '\\0');\n \t\tstrbuf_add(&buffer, oid->hash, the_hash_algo->rawsz);\n \n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \t\tfprintf(stderr, \"cache-tree update-one %o %.*s\\n\",\n \t\t\tmode, entlen, path + baselen);\n #endif\n@@ -421,7 +421,7 @@ static int update_one(struct cache_tree *it,\n \n \tstrbuf_release(&buffer);\n \tit->entry_count = to_invalidate ? -1 : i - *skip_count;\n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \tfprintf(stderr, \"cache-tree update-one (%d ent, %d subtree) %s\\n\",\n \t\tit->entry_count, it->subtree_nr,\n \t\toid_to_hex(&it->oid));\n@@ -462,7 +462,7 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,\n \tstrbuf_add(buffer, path, pathlen);\n \tstrbuf_addf(buffer, \"%c%d %d\\n\", 0, it->entry_count, it->subtree_nr);\n \n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \tif (0 <= it->entry_count)\n \t\tfprintf(stderr, \"cache-tree <%.*s> (%d ent, %d subtree) %s\\n\",\n \t\t\tpathlen, path, it->entry_count, it->subtree_nr,\n@@ -536,7 +536,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)\n \t\tsize -= rawsz;\n \t}\n \n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \tif (0 <= it->entry_count)\n \t\tfprintf(stderr, \"cache-tree <%s> (%d ent, %d subtree) %s\\n\",\n \t\t\t*buffer, it->entry_count, subtree_nr,\n-- \ngitgitgadget\n\n"},{"id":"377580","messageId":"51d73c61d3fea7c02cf2c9622f6c492adf56502b.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 11/20] msvc: do not re-declare the timespec struct","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:03Z","receivedAt":"2019-06-19T21:06:22Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nVS2015's headers already declare that struct.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 210f1b01a8..a03e40e6e2 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -352,11 +352,13 @@ static inline int getrlimit(int resource, struct rlimit *rlp)\n #ifndef __MINGW64_VERSION_MAJOR\n #define off_t off64_t\n #define lseek _lseeki64\n+#ifndef _MSC_VER\n struct timespec {\n \ttime_t tv_sec;\n \tlong tv_nsec;\n };\n #endif\n+#endif\n \n struct mingw_stat {\n     _dev_t st_dev;\n-- \ngitgitgadget\n\n"},{"id":"377581","messageId":"0a2985dc3c096023928ef81eea6da05ed1cd73f7.1560978354.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 08/20] msvc: include sigset_t definition","fromName":"Philip Oakley via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-19T21:06:01Z","receivedAt":"2019-06-19T21:06:23Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: Philip Oakley <philipoakley@iee.org>\n\nOn MSVC (VS2008) sigset_t is not defined.\n\nSigned-off-by: Philip Oakley <philipoakley@iee.org>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/msvc.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/compat/msvc.h b/compat/msvc.h\nindex 29a8ce8204..04b4750b87 100644\n--- a/compat/msvc.h\n+++ b/compat/msvc.h\n@@ -18,6 +18,8 @@\n \n #undef ERROR\n \n+typedef int sigset_t;\n+\n #include \"compat/mingw.h\"\n \n #endif\n-- \ngitgitgadget\n\n"},{"id":"377770","messageId":"nycvar.QRO.7.76.6.1906212216410.44@tvgsbejvaqbjf.bet","threadId":"51332","inReplyTo":"245f28ac3beda03c980220657ccc6e4d75269c00.1560978354.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 15/20] msvc: support building Git using MS Visual C++","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-21T20:17:36Z","receivedAt":"2019-06-21T20:17:29Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 19 Jun 2019, Jeff Hostetler via GitGitGadget wrote:\n\n> diff --git a/Makefile b/Makefile\n> index 3cf8cc8ffd..2b66d5a3f3 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -1240,7 +1240,7 @@ endif\n>\n>  ifdef SANE_TOOL_PATH\n>  SANE_TOOL_PATH_SQ = $(subst ','\\'',$(SANE_TOOL_PATH))\n> -BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix \"$(SANE_TOOL_PATH_SQ)\"|'\n> +BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'\n\nAaargh! I totally managed to mess this split up. This line should *not* be\ntouched by this patch.\n\nWill fix locally, in preparation for the next iteration.\n\nSorry,\nDscho\n"},{"id":"377772","messageId":"xmqqv9wyis5o.fsf@gitster-ct.c.googlers.com","threadId":"51332","inReplyTo":"nycvar.QRO.7.76.6.1906212216410.44@tvgsbejvaqbjf.bet","subject":"Re: [PATCH v2 15/20] msvc: support building Git using MS Visual C++","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-06-21T20:45:39Z","receivedAt":"2019-06-21T20:45:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n>>  ifdef SANE_TOOL_PATH\n>>  SANE_TOOL_PATH_SQ = $(subst ','\\'',$(SANE_TOOL_PATH))\n>> -BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix \"$(SANE_TOOL_PATH_SQ)\"|'\n>> +BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'\n>\n> Aaargh! I totally managed to mess this split up. This line should *not* be\n> touched by this patch.\n>\n> Will fix locally, in preparation for the next iteration.\n\nThanks for stopping me soon enough.  I am in the middle of picking\nwhich ones should go 'next', as we can now start 'next' from the tip\nof 'master'---hat I pushed out some time ago has master and next\nwith identical trees ;-)\n"},{"id":"378002","messageId":"pull.149.v3.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v3 00/20] Fix MSVC support, at long last","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:28Z","receivedAt":"2019-06-25T14:49:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Philip Oakley and Jeff Hostetler worked quite a bit on getting Git to\ncompile with MS Visual C again, and this patch series is the culmination of\nthose efforts. With these patches, it is as easy as\n\nmake MSVC=1\n\nNote: the patches went through quite the number of iterations. For example,\nfor a long time we targeted Visual Studio 2015, and used NuGet packages for\nthe dependencies (such as OpenSSL, cURL, etc), while the current iteration\ntargets Visual Studio 2017 and uses vcpkg\n[https://docs.microsoft.com/en-us/cpp/vcpkg?view=vs-2017] for dependencies.\nHopefully I did not forget to remove any remnants of those previous\nversions.\n\nPlease also note that this patch series is part 1 of 3 in a bigger story:\nthe next patch series will add support to build Git in Microsoft Visual\nStudio, and the third patch series will add Continuous Testing by adding an\nMSVC build and a corresponding parallelized test job to our Azure Pipeline.\n\nChanges since v2:\n\n * Fixed the incorrect split-out of the \"msvc: update Makefile to allow for\n   spaces in the compiler path\" patch: I had accidentally reverted that\n   change in a later patch in the series.\n\nChanges since v1:\n\n * The BASIC_CLFAGS typo was fixed.\n * Instead of sorting the output of stdout/stderr, the fixed test case in \n   t0001 now greps for the tell-tales it wants to be present.\n * In addition to cache-tree.c's DEBUG constant, now also builtin/blame.c's\n   is renamed.\n * Two changes were factored out of the patch titled \"msvc: support building\n   Git using MS Visual C++\": the support for spaces in SANE_TOOL_PATH, and\n   the support for the compile time flag to enable CrtDbg's detailed heap\n   diagnostics.\n * A comment about the vcxproj target has been dropped; The corresponding\n   change is slated for a future patch series.\n * A left-over \"TODO\" comment was replaced by stating the final decision\n   that only Visual Studio 2015 or later are supported for now.\n * A left-over, commented-out SIGINT case label was removed, and an adjacent\n   comment was moved so that its indentation no longer looks strange.\n\nJeff Hostetler (10):\n  cache-tree/blame: avoid reusing the DEBUG constant\n  msvc: mark a variable as non-const\n  msvc: do not re-declare the timespec struct\n  msvc: define ftello()\n  msvc: fix detect_msys_tty()\n  msvc: update Makefile to allow for spaces in the compiler path\n  msvc: support building Git using MS Visual C++\n  msvc: add a compile-time flag to allow detailed heap debugging\n  msvc: do not pretend to support all signals\n  msvc: ignore .dll and incremental compile output\n\nJohannes Schindelin (7):\n  mingw: fix a typo in the msysGit-specific section\n  Mark .bat files as requiring CR/LF endings\n  t0001 (mingw): do not expect a specific order of stdout/stderr\n  obstack: fix compiler warning\n  mingw: replace mingw_startup() hack\n  msvc: fix dependencies of compat/msvc.c\n  msvc: avoid debug assertion windows in Debug Mode\n\nPhilip Oakley (3):\n  msvc: include sigset_t definition\n  msvc: define O_ACCMODE\n  msvc: add pragmas for common warnings\n\n .gitattributes                     |   1 +\n .gitignore                         |   5 +\n Makefile                           |  42 +++++++-\n builtin/blame.c                    |   6 +-\n cache-tree.c                       |  14 +--\n compat/mingw.c                     |  99 +++++++++++++----\n compat/mingw.h                     |  24 +++--\n compat/msvc.h                      |  10 ++\n compat/obstack.h                   |   2 +-\n compat/vcbuild/.gitignore          |   3 +\n compat/vcbuild/README              |  39 +++++++\n compat/vcbuild/find_vs_env.bat     | 168 +++++++++++++++++++++++++++++\n compat/vcbuild/scripts/clink.pl    |  41 ++++++-\n compat/vcbuild/vcpkg_copy_dlls.bat |  39 +++++++\n compat/vcbuild/vcpkg_install.bat   |  80 ++++++++++++++\n compat/winansi.c                   |  13 +++\n config.mak.uname                   |  83 +++++++++++---\n git-compat-util.h                  |   9 ++\n t/t0001-init.sh                    |   4 +-\n 19 files changed, 620 insertions(+), 62 deletions(-)\n create mode 100644 compat/vcbuild/.gitignore\n create mode 100644 compat/vcbuild/find_vs_env.bat\n create mode 100644 compat/vcbuild/vcpkg_copy_dlls.bat\n create mode 100644 compat/vcbuild/vcpkg_install.bat\n\n\nbase-commit: b697d92f56511e804b8ba20ccbe7bdc85dc66810\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-149%2Fdscho%2Fmsvc-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-149/dscho/msvc-v3\nPull-Request: https://github.com/gitgitgadget/git/pull/149\n\nRange-diff vs v2:\n\n  1:  9d4d6ae7db =  1:  9d4d6ae7db mingw: fix a typo in the msysGit-specific section\n  2:  aa27e7f9cb =  2:  aa27e7f9cb Mark .bat files as requiring CR/LF endings\n  3:  3e108cfb02 =  3:  3e108cfb02 t0001 (mingw): do not expect a specific order of stdout/stderr\n  4:  90ac088d22 =  4:  90ac088d22 cache-tree/blame: avoid reusing the DEBUG constant\n  5:  71d85b58b6 =  5:  71d85b58b6 obstack: fix compiler warning\n  6:  02f618464f =  6:  02f618464f mingw: replace mingw_startup() hack\n  7:  5c383985a1 =  7:  5c383985a1 msvc: fix dependencies of compat/msvc.c\n  8:  0a2985dc3c =  8:  0a2985dc3c msvc: include sigset_t definition\n  9:  99a2939cc2 =  9:  99a2939cc2 msvc: define O_ACCMODE\n 10:  1542e8abe5 = 10:  1542e8abe5 msvc: mark a variable as non-const\n 11:  51d73c61d3 = 11:  51d73c61d3 msvc: do not re-declare the timespec struct\n 12:  7cfd0fc9b4 = 12:  7cfd0fc9b4 msvc: define ftello()\n 13:  f528883d97 = 13:  f528883d97 msvc: fix detect_msys_tty()\n 14:  63bf9f1f92 = 14:  63bf9f1f92 msvc: update Makefile to allow for spaces in the compiler path\n 15:  245f28ac3b ! 15:  fee0ad048e msvc: support building Git using MS Visual C++\n     @@ -43,15 +43,6 @@\n       --- a/Makefile\n       +++ b/Makefile\n      @@\n     - \n     - ifdef SANE_TOOL_PATH\n     - SANE_TOOL_PATH_SQ = $(subst ','\\'',$(SANE_TOOL_PATH))\n     --BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix \"$(SANE_TOOL_PATH_SQ)\"|'\n     -+BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'\n     - PATH := $(SANE_TOOL_PATH):${PATH}\n     - else\n     - BROKEN_PATH_FIX = '/^\\# @@BROKEN_PATH_FIX@@$$/d'\n     -@@\n       \t$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n       \t$(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n       \t$(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'\n 16:  e7888bedbd = 16:  993b6bcd0a msvc: add a compile-time flag to allow detailed heap debugging\n 17:  d9668558dd = 17:  42f5b8cee8 msvc: add pragmas for common warnings\n 18:  c883f037e0 = 18:  c9a6f6892c msvc: do not pretend to support all signals\n 19:  51a20ff2df = 19:  7cb0434fac msvc: avoid debug assertion windows in Debug Mode\n 20:  4d44d1fab1 = 20:  4a7ceb2172 msvc: ignore .dll and incremental compile output\n\n-- \ngitgitgadget\n"},{"id":"378003","messageId":"9d4d6ae7db55309ff99c34237b64d7edae2dbbd6.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 01/20] mingw: fix a typo in the msysGit-specific section","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:28Z","receivedAt":"2019-06-25T14:49:33Z","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 msysGit project (i.e. Git for Windows 1.x' SDK) is safely dead for\n*years* already. This is probably the reason why nobody caught this typo\nuntil Carlo Arenas spotted a copy-edited version of it nearby.\n\nIt is probably about time to rip out the remainders of msysGit/MSys1\nsupport, but that can safely wait a bit longer, and we can at least fix\nthe typo for now.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n config.mak.uname | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex b71688eeb7..9fc053cac0 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -571,7 +571,7 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))\n \tINTERNAL_QSORT = YesPlease\n \tHAVE_LIBCHARSET_H = YesPlease\n \tNO_GETTEXT = YesPlease\n-\tCOMPAT_CLFAGS += -D__USE_MINGW_ACCESS\n+\tCOMPAT_CFLAGS += -D__USE_MINGW_ACCESS\n else\n \tifneq ($(shell expr \"$(uname_R)\" : '1\\.'),2)\n \t\t# MSys2\n-- \ngitgitgadget\n\n"},{"id":"378004","messageId":"aa27e7f9cbfda50a02ac6bb555f2ee6487c47625.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 02/20] Mark .bat files as requiring CR/LF endings","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:29Z","receivedAt":"2019-06-25T14:49:33Z","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\nJust like the natural line ending for Unix shell scripts consist of a\nsingle Line Feed, the natural line ending for (DOS) Batch scripts\nconsists of a Carriage Return followed by a Line Feed.\n\nIt seems that both Unix shell script interpreters and the interpreter\nfor Batch scripts (`cmd.exe`) are keen on seeing the \"right\" line\nendings.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .gitattributes | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/.gitattributes b/.gitattributes\nindex 9fa72ad450..b08a1416d8 100644\n--- a/.gitattributes\n+++ b/.gitattributes\n@@ -5,6 +5,7 @@\n *.pl eof=lf diff=perl\n *.pm eol=lf diff=perl\n *.py eol=lf diff=python\n+*.bat eol=crlf\n /Documentation/**/*.txt eol=lf\n /command-list.txt eol=lf\n /GIT-VERSION-GEN eol=lf\n-- \ngitgitgadget\n\n"},{"id":"378005","messageId":"3e108cfb0250919c10833bcff3985e79c6452ae0.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 03/20] t0001 (mingw): do not expect a specific order of stdout/stderr","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:30Z","receivedAt":"2019-06-25T14:49:35Z","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\nWhen redirecting stdout/stderr to the same file, we cannot guarantee\nthat stdout will come first.\n\nIn fact, in this test case, it seems that an MSVC build always prints\nstderr first.\n\nIn any case, this test case does not want to verify the *order* but\nthe *presence* of both outputs, so let's test exactly that.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/t0001-init.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 77a224aafb..387e4e6b81 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -473,8 +473,8 @@ test_expect_success MINGW 'redirect std handles' '\n \t\tGIT_REDIRECT_STDOUT=output.txt \\\n \t\tGIT_REDIRECT_STDERR=\"2>&1\" \\\n \t\tgit rev-parse --git-dir --verify refs/invalid &&\n-\tprintf \".git\\nfatal: Needed a single revision\\n\" >expect &&\n-\ttest_cmp expect output.txt\n+\tgrep \"^\\\\.git\\$\" output.txt &&\n+\tgrep \"Needed a single revision\" output.txt\n '\n \n test_done\n-- \ngitgitgadget\n\n"},{"id":"378006","messageId":"90ac088d22359de9c86e7e5ee54cfb59071b1cff.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 04/20] cache-tree/blame: avoid reusing the DEBUG constant","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:31Z","receivedAt":"2019-06-25T14:49:37Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nIn MS Visual C, the `DEBUG` constant is set automatically whenever\ncompiling with debug information.\n\nThis is clearly not what was intended in `cache-tree.c` nor in\n`builtin/blame.c`, so let's use a less ambiguous name there.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin/blame.c |  6 +++---\n cache-tree.c    | 14 +++++++-------\n 2 files changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 21cde57e71..50e3d4a265 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -59,8 +59,8 @@ static size_t blame_date_width;\n \n static struct string_list mailmap = STRING_LIST_INIT_NODUP;\n \n-#ifndef DEBUG\n-#define DEBUG 0\n+#ifndef DEBUG_BLAME\n+#define DEBUG_BLAME 0\n #endif\n \n static unsigned blame_move_score;\n@@ -1062,7 +1062,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \tif (blame_copy_score)\n \t\tsb.copy_score = blame_copy_score;\n \n-\tsb.debug = DEBUG;\n+\tsb.debug = DEBUG_BLAME;\n \tsb.on_sanity_fail = &sanity_check_on_fail;\n \n \tsb.show_root = show_root;\ndiff --git a/cache-tree.c b/cache-tree.c\nindex b13bfaf71e..706ffcf188 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -6,8 +6,8 @@\n #include \"object-store.h\"\n #include \"replace-object.h\"\n \n-#ifndef DEBUG\n-#define DEBUG 0\n+#ifndef DEBUG_CACHE_TREE\n+#define DEBUG_CACHE_TREE 0\n #endif\n \n struct cache_tree *cache_tree(void)\n@@ -111,7 +111,7 @@ static int do_invalidate_path(struct cache_tree *it, const char *path)\n \tint namelen;\n \tstruct cache_tree_sub *down;\n \n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \tfprintf(stderr, \"cache-tree invalidate <%s>\\n\", path);\n #endif\n \n@@ -398,7 +398,7 @@ static int update_one(struct cache_tree *it,\n \t\tstrbuf_addf(&buffer, \"%o %.*s%c\", mode, entlen, path + baselen, '\\0');\n \t\tstrbuf_add(&buffer, oid->hash, the_hash_algo->rawsz);\n \n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \t\tfprintf(stderr, \"cache-tree update-one %o %.*s\\n\",\n \t\t\tmode, entlen, path + baselen);\n #endif\n@@ -421,7 +421,7 @@ static int update_one(struct cache_tree *it,\n \n \tstrbuf_release(&buffer);\n \tit->entry_count = to_invalidate ? -1 : i - *skip_count;\n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \tfprintf(stderr, \"cache-tree update-one (%d ent, %d subtree) %s\\n\",\n \t\tit->entry_count, it->subtree_nr,\n \t\toid_to_hex(&it->oid));\n@@ -462,7 +462,7 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,\n \tstrbuf_add(buffer, path, pathlen);\n \tstrbuf_addf(buffer, \"%c%d %d\\n\", 0, it->entry_count, it->subtree_nr);\n \n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \tif (0 <= it->entry_count)\n \t\tfprintf(stderr, \"cache-tree <%.*s> (%d ent, %d subtree) %s\\n\",\n \t\t\tpathlen, path, it->entry_count, it->subtree_nr,\n@@ -536,7 +536,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)\n \t\tsize -= rawsz;\n \t}\n \n-#if DEBUG\n+#if DEBUG_CACHE_TREE\n \tif (0 <= it->entry_count)\n \t\tfprintf(stderr, \"cache-tree <%s> (%d ent, %d subtree) %s\\n\",\n \t\t\t*buffer, it->entry_count, subtree_nr,\n-- \ngitgitgadget\n\n"},{"id":"378007","messageId":"5c383985a19f8d7edff4a496021c99849840c8be.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 07/20] msvc: fix dependencies of compat/msvc.c","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:33Z","receivedAt":"2019-06-25T14:49:38Z","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 file compat/msvc.c includes compat/mingw.c, which means that we have\nto recompile compat/msvc.o if compat/mingw.c changes.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n config.mak.uname | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 6ddece0350..473613a20d 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -414,6 +414,8 @@ else\n \tBASIC_CFLAGS += -Zi -MDd\n endif\n \tX = .exe\n+\n+compat/msvc.o: compat/msvc.c compat/mingw.c GIT-CFLAGS\n endif\n ifeq ($(uname_S),Interix)\n \tNO_INITGROUPS = YesPlease\n-- \ngitgitgadget\n\n"},{"id":"378008","messageId":"51d73c61d3fea7c02cf2c9622f6c492adf56502b.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 11/20] msvc: do not re-declare the timespec struct","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:36Z","receivedAt":"2019-06-25T14:49:40Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nVS2015's headers already declare that struct.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 210f1b01a8..a03e40e6e2 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -352,11 +352,13 @@ static inline int getrlimit(int resource, struct rlimit *rlp)\n #ifndef __MINGW64_VERSION_MAJOR\n #define off_t off64_t\n #define lseek _lseeki64\n+#ifndef _MSC_VER\n struct timespec {\n \ttime_t tv_sec;\n \tlong tv_nsec;\n };\n #endif\n+#endif\n \n struct mingw_stat {\n     _dev_t st_dev;\n-- \ngitgitgadget\n\n"},{"id":"378009","messageId":"1542e8abe5c40b6ebae5924e5912523a0f4aa4a1.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 10/20] msvc: mark a variable as non-const","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:35Z","receivedAt":"2019-06-25T14:49:41Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nVS2015 complains when using a const pointer in memcpy()/free().\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c | 5 ++++-\n 1 file changed, 4 insertions(+), 1 deletion(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 0d8713e515..d14d33308d 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1553,7 +1553,10 @@ static int try_shell_exec(const char *cmd, char *const *argv)\n \tif (prog) {\n \t\tint exec_id;\n \t\tint argc = 0;\n-\t\tconst char **argv2;\n+#ifndef _MSC_VER\n+\t\tconst\n+#endif\n+\t\tchar **argv2;\n \t\twhile (argv[argc]) argc++;\n \t\tALLOC_ARRAY(argv2, argc + 1);\n \t\targv2[0] = (char *)cmd;\t/* full path to the script file */\n-- \ngitgitgadget\n\n"},{"id":"378010","messageId":"f528883d97011128d77061c4976655b80a7e7b14.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 13/20] msvc: fix detect_msys_tty()","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:37Z","receivedAt":"2019-06-25T14:49:42Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nThe ntstatus.h header is only available in MINGW.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/winansi.c | 13 +++++++++++++\n 1 file changed, 13 insertions(+)\n\ndiff --git a/compat/winansi.c b/compat/winansi.c\nindex f4f08237f9..11cd9b82cc 100644\n--- a/compat/winansi.c\n+++ b/compat/winansi.c\n@@ -544,7 +544,20 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)\n #ifdef DETECT_MSYS_TTY\n \n #include <winternl.h>\n+\n+#if defined(_MSC_VER)\n+\n+typedef struct _OBJECT_NAME_INFORMATION\n+{\n+\tUNICODE_STRING Name;\n+\tWCHAR NameBuffer[0];\n+} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;\n+\n+#define ObjectNameInformation 1\n+\n+#else\n #include <ntstatus.h>\n+#endif\n \n static void detect_msys_tty(int fd)\n {\n-- \ngitgitgadget\n\n"},{"id":"378011","messageId":"993b6bcd0a8cf47acd0cfa695ad6e34865b060d3.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 16/20] msvc: add a compile-time flag to allow detailed heap debugging","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:40Z","receivedAt":"2019-06-25T14:49:44Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nMS Visual C comes with a few neat features we can use to analyze the\nheap consumption (i.e. leaks, max memory, etc).\n\nWith this patch, we introduce support via the build-time flag\n`USE_MSVC_CRTDBG`.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c    | 6 ++++++\n config.mak.uname  | 4 ++++\n git-compat-util.h | 9 +++++++++\n 3 files changed, 19 insertions(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex c063ae62be..667285887a 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2411,6 +2411,12 @@ int wmain(int argc, const wchar_t **wargv)\n \n \ttrace2_initialize_clock();\n \n+#ifdef _MSC_VER\n+#ifdef USE_MSVC_CRTDBG\n+\t_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);\n+#endif\n+#endif\n+\n \tmaybe_redirect_std_handles();\n \n \t/* determine size of argv and environ conversion buffer */\ndiff --git a/config.mak.uname b/config.mak.uname\nindex b8c52e49d2..3fde48c64d 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -448,6 +448,10 @@ else\n endif\n \tBASIC_CFLAGS += $(sdk_libs) $(msvc_libs)\n \n+ifneq ($(USE_MSVC_CRTDBG),)\n+\t# Optionally enable memory leak reporting.\n+\tBASIC_CFLAGS += -DUSE_MSVC_CRTDBG\n+endif\n \tBASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1\n \t# Always give \"-Zi\" to the compiler and \"-debug\" to linker (even in\n \t# release mode) to force a PDB to be generated (like RelWithDebInfo).\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex cc0e7e9733..83be89de0a 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1,6 +1,15 @@\n #ifndef GIT_COMPAT_UTIL_H\n #define GIT_COMPAT_UTIL_H\n \n+#ifdef USE_MSVC_CRTDBG\n+/*\n+ * For these to work they must appear very early in each\n+ * file -- before most of the standard header files.\n+ */\n+#include <stdlib.h>\n+#include <crtdbg.h>\n+#endif\n+\n #define _FILE_OFFSET_BITS 64\n \n \n-- \ngitgitgadget\n\n"},{"id":"378012","messageId":"63bf9f1f9239280359c0086375117f984ae72dc1.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 14/20] msvc: update Makefile to allow for spaces in the compiler path","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:38Z","receivedAt":"2019-06-25T14:49:44Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nIt is quite common that MS Visual C++ is installed into a location whose\npath contains spaces, therefore we need to quote it.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Makefile | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 8a7e235352..3cf8cc8ffd 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1240,7 +1240,7 @@ endif\n \n ifdef SANE_TOOL_PATH\n SANE_TOOL_PATH_SQ = $(subst ','\\'',$(SANE_TOOL_PATH))\n-BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'\n+BROKEN_PATH_FIX = 's|^\\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix \"$(SANE_TOOL_PATH_SQ)\"|'\n PATH := $(SANE_TOOL_PATH):${PATH}\n else\n BROKEN_PATH_FIX = '/^\\# @@BROKEN_PATH_FIX@@$$/d'\n-- \ngitgitgadget\n\n"},{"id":"378013","messageId":"c9a6f6892c5ff0f24da0464895865eeea1240f42.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 18/20] msvc: do not pretend to support all signals","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:41Z","receivedAt":"2019-06-25T14:49:45Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nThis special-cases various signals that are not supported on Windows,\nsuch as SIGPIPE. These cause the UCRT to throw asserts (at least in\ndebug mode).\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c | 25 +++++++++++++++++++++++++\n 1 file changed, 25 insertions(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 667285887a..d01e88c2f8 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2119,8 +2119,33 @@ int mingw_raise(int sig)\n \t\t\tsigint_fn(SIGINT);\n \t\treturn 0;\n \n+#if defined(_MSC_VER)\n+\tcase SIGILL:\n+\tcase SIGFPE:\n+\tcase SIGSEGV:\n+\tcase SIGTERM:\n+\tcase SIGBREAK:\n+\tcase SIGABRT:\n+\tcase SIGABRT_COMPAT:\n+\t\t/*\n+\t\t * The <signal.h> header in the MS C Runtime defines 8 signals\n+\t\t * as being supported on the platform. Anything else causes an\n+\t\t * \"Invalid signal or error\" (which in DEBUG builds causes the\n+\t\t * Abort/Retry/Ignore dialog). We by-pass the CRT for things we\n+\t\t * already know will fail.\n+\t\t */\n+\t\treturn raise(sig);\n+\tdefault:\n+\t\terrno = EINVAL;\n+\t\treturn -1;\n+\n+#else\n+\n \tdefault:\n \t\treturn raise(sig);\n+\n+#endif\n+\n \t}\n }\n \n-- \ngitgitgadget\n\n"},{"id":"378014","messageId":"fee0ad048e2639507c7b19f6aec2c36fe634707a.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 15/20] msvc: support building Git using MS Visual C++","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:39Z","receivedAt":"2019-06-25T14:49:46Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nWith this patch, Git can be built using the Microsoft toolchain, via:\n\n\tmake MSVC=1 [DEBUG=1]\n\nThird party libraries are built from source using the open source\n\"vcpkg\" tool set. See https://github.com/Microsoft/vcpkg\n\nOn a first build, the vcpkg tools and the third party libraries are\nautomatically downloaded and built. DLLs for the third party libraries\nare copied to the top-level (and t/helper) directory to facilitate\ndebugging. See compat/vcbuild/README.\n\nA series of .bat files are invoked by the Makefile to find the location\nof the installed version of Visual Studio and the associated compiler\ntools (essentially replicating the environment setup performed by a\n\"Developer Command Prompt\"). This should find the most recent VS2015 or\nVS2017 installation. Output from these scripts are used by the Makefile\nto define compiler and linker pathnames and -I and -L arguments.\n\nThe build produces .pdb files for both debug and release builds.\n\nNote: This commit was squashed from an organic series of commits\ndeveloped between 2016 and 2018 in Git for Windows' `master` branch.\nThis combined commit eliminates the obsolete commits related to fetching\nNuGet packages for third party libraries. It is difficult to use NuGet\npackages for C/C++ sources because they may be built by earlier versions\nof the MSVC compiler and have CRT version and linking issues.\n\nAdditionally, the C/C++ NuGet packages that we were using tended to not\nbe updated concurrently with the sources.  And in the case of cURL and\nOpenSSL, this could expose us to security issues.\n\nHelped-by: Yue Lin Ho <b8732003@student.nsysu.edu.tw>\nHelped-by: Philip Oakley <philipoakley@iee.org>\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Makefile                           |  40 +++++++\n compat/mingw.c                     |   6 ++\n compat/vcbuild/.gitignore          |   3 +\n compat/vcbuild/README              |  39 +++++++\n compat/vcbuild/find_vs_env.bat     | 168 +++++++++++++++++++++++++++++\n compat/vcbuild/scripts/clink.pl    |  41 ++++++-\n compat/vcbuild/vcpkg_copy_dlls.bat |  39 +++++++\n compat/vcbuild/vcpkg_install.bat   |  80 ++++++++++++++\n config.mak.uname                   |  72 +++++++++++--\n 9 files changed, 473 insertions(+), 15 deletions(-)\n create mode 100644 compat/vcbuild/.gitignore\n create mode 100644 compat/vcbuild/find_vs_env.bat\n create mode 100644 compat/vcbuild/vcpkg_copy_dlls.bat\n create mode 100644 compat/vcbuild/vcpkg_install.bat\n\ndiff --git a/Makefile b/Makefile\nindex 3cf8cc8ffd..7777af7d0e 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2873,6 +2873,33 @@ install: all\n \t$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n \t$(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n \t$(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'\n+ifdef MSVC\n+\t# We DO NOT install the individual foo.o.pdb files because they\n+\t# have already been rolled up into the exe's pdb file.\n+\t# We DO NOT have pdb files for the builtin commands (like git-status.exe)\n+\t# because it is just a copy/hardlink of git.exe, rather than a unique binary.\n+\t$(INSTALL) git.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) git-shell.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) git-upload-pack.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) git-credential-store.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-daemon.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-fast-import.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-http-backend.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-http-fetch.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-http-push.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-imap-send.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-remote-http.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-remote-testsvn.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-sh-i18n--envsubst.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) git-show-index.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+ifndef DEBUG\n+\t$(INSTALL) $(vcpkg_rel_bin)/*.dll '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) $(vcpkg_rel_bin)/*.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+else\n+\t$(INSTALL) $(vcpkg_dbg_bin)/*.dll '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) $(vcpkg_dbg_bin)/*.pdb '$(DESTDIR_SQ)$(bindir_SQ)'\n+endif\n+endif\n \t$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'\n \t$(INSTALL) -m 644 mergetools/* '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'\n@@ -3085,6 +3112,19 @@ endif\n \t$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS\n \t$(RM) GIT-USER-AGENT GIT-PREFIX\n \t$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT-PYTHON-VARS\n+ifdef MSVC\n+\t$(RM) $(patsubst %.o,%.o.pdb,$(OBJECTS))\n+\t$(RM) $(patsubst %.exe,%.pdb,$(OTHER_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.iobj,$(OTHER_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.ipdb,$(OTHER_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.pdb,$(PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.iobj,$(PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.ipdb,$(PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.pdb,$(TEST_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.iobj,$(TEST_PROGRAMS))\n+\t$(RM) $(patsubst %.exe,%.ipdb,$(TEST_PROGRAMS))\n+\t$(RM) compat/vcbuild/MSVC-DEFS-GEN\n+endif\n \n .PHONY: all install profile-clean cocciclean clean strip\n .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex d14d33308d..c063ae62be 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2388,6 +2388,12 @@ static void maybe_redirect_std_handles(void)\n \t\t\t\t  GENERIC_WRITE, FILE_FLAG_NO_BUFFERING);\n }\n \n+#ifdef _MSC_VER\n+#ifdef _DEBUG\n+#include <crtdbg.h>\n+#endif\n+#endif\n+\n /*\n  * We implement wmain() and compile with -municode, which would\n  * normally ignore main(), but we call the latter from the former\ndiff --git a/compat/vcbuild/.gitignore b/compat/vcbuild/.gitignore\nnew file mode 100644\nindex 0000000000..8f8b794ef3\n--- /dev/null\n+++ b/compat/vcbuild/.gitignore\n@@ -0,0 +1,3 @@\n+/vcpkg/\n+/MSVC-DEFS-GEN\n+/VCPKG-DEFS\ndiff --git a/compat/vcbuild/README b/compat/vcbuild/README\nindex 60fd873fe8..b633e7db98 100644\n--- a/compat/vcbuild/README\n+++ b/compat/vcbuild/README\n@@ -1,3 +1,42 @@\n+The Steps to Build Git with VS2015 or VS2017 from the command line.\n+\n+1. Install the \"vcpkg\" open source package manager and build essential\n+   third-party libraries.  The steps for this have been captured in a\n+   set of convenience scripts.  These can be run from a stock Command\n+   Prompt or from an SDK bash window:\n+\n+   $ cd <repo_root>\n+   $ ./compat/vcbuild/vcpkg_install.bat\n+\n+   The vcpkg tools and all of the third-party sources will be installed\n+   in this folder:\n+      <repo_root>/compat/vcbuild/vcpkg/\n+\n+   A file will be created with a set of Makefile macros pointing to a\n+   unified \"include\", \"lib\", and \"bin\" directory (release and debug) for\n+   all of the required packages.  This file will be included by the main\n+   Makefile:\n+      <repo_root>/compat/vcbuild/MSVC-DEFS-GEN\n+\n+2. OPTIONALLY copy the third-party *.dll and *.pdb files into the repo\n+   root to make it easier to run and debug git.exe without having to\n+   manipulate your PATH.  This is especially true for debug sessions in\n+   Visual Studio.\n+\n+   Use ONE of the following forms which should match how you want to\n+   compile git.exe.\n+\n+   $ ./compat/vcbuild/vcpkg_copy_packages.bat debug\n+   $ ./compat/vcbuild/vcpkg_copy_packages.bat release\n+\n+3. Build git using MSVC from an SDK bash window using one of the\n+   following commands:\n+\n+   $ make MSVC=1\n+   $ make MSVC=1 DEBUG=1\n+\n+================================================================\n+\n The Steps of Build Git with VS2008\n \n 1. You need the build environment, which contains the Git dependencies\ndiff --git a/compat/vcbuild/find_vs_env.bat b/compat/vcbuild/find_vs_env.bat\nnew file mode 100644\nindex 0000000000..40194dd230\n--- /dev/null\n+++ b/compat/vcbuild/find_vs_env.bat\n@@ -0,0 +1,168 @@\n+@ECHO OFF\n+REM ================================================================\n+REM You can use either GCC (the default) or MSVC to build git\n+REM using the GIT-SDK command line tools.\n+REM        $ make\n+REM        $ make MSVC=1\n+REM\n+REM GIT-SDK BASH windows inherit environment variables with all of\n+REM the bin/lib/include paths for GCC.  It DOES NOT inherit values\n+REM for the corresponding MSVC tools.\n+REM\n+REM During normal (non-git) Windows development, you launch one\n+REM of the provided \"developer command prompts\" to set environment\n+REM variables for the MSVC tools.\n+REM\n+REM Therefore, to allow MSVC command line builds of git from BASH\n+REM and MAKE, we must blend these two different worlds.  This script\n+REM attempts to do that.\n+REM ================================================================\n+REM This BAT file starts in a plain (non-developer) command prompt,\n+REM searches for the \"best\" commmand prompt setup script, installs\n+REM it into the current CMD process, and exports the various MSVC\n+REM environment variables for use by MAKE.\n+REM\n+REM The output of this script should be written to a make \"include\n+REM file\" and referenced by the top-level Makefile.\n+REM\n+REM See \"config.mak.uname\" (look for compat/vcbuild/MSVC-DEFS-GEN).\n+REM ================================================================\n+REM The provided command prompts are custom to each VS release and\n+REM filled with lots of internal knowledge (such as Registry settings);\n+REM even their names vary by release, so it is not appropriate for us\n+REM to look inside them.  Rather, just run them in a subordinate\n+REM process and extract the settings we need.\n+REM ================================================================\n+REM\n+REM Current (VS2017 and beyond)\n+REM -------------------\n+REM Visual Studio 2017 introduced a new installation layout and\n+REM support for side-by-side installation of multiple versions of\n+REM VS2017.  Furthermore, these can all coexist with installations\n+REM of previous versions of VS (which have a completely different\n+REM layout on disk).\n+REM\n+REM VS2017 Update 2 introduced a \"vswhere.exe\" command:\n+REM https://github.com/Microsoft/vswhere\n+REM https://blogs.msdn.microsoft.com/heaths/2017/02/25/vswhere-available/\n+REM https://blogs.msdn.microsoft.com/vcblog/2017/03/06/finding-the-visual-c-compiler-tools-in-visual-studio-2017/\n+REM\n+REM VS2015\n+REM ------\n+REM Visual Studio 2015 uses the traditional VcVarsAll.\n+REM\n+REM Earlier Versions\n+REM ----------------\n+REM Currently unsupported.\n+REM\n+REM ================================================================\n+REM Note: Throughout this script we use \"dir <path> && <cmd>\" rather\n+REM than \"if exist <path>\" because of script problems with pathnames\n+REM containing spaces.\n+REM ================================================================\n+\n+REM Sanitize PATH to prevent git-sdk paths from confusing \"wmic.exe\"\n+REM (called internally in some of the system BAT files).\n+SET PATH=%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;\n+\n+REM ================================================================\n+\n+:current\n+   SET vs_where=C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe\n+   dir \"%vs_where%\" >nul 2>nul && GOTO have_vs_where\n+   GOTO not_2017\n+\n+:have_vs_where\n+   REM Try to use VsWhere to get the location of VsDevCmd.\n+\n+   REM Keep VsDevCmd from cd'ing away.\n+   SET VSCMD_START_DIR=.\n+\n+   REM Get the root of the VS product installation.\n+   FOR /F \"usebackq tokens=*\" %%i IN (`\"%vs_where%\" -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath`) DO @SET vs_ip=%%i\n+\n+   SET vs_devcmd=%vs_ip%\\Common7\\Tools\\VsDevCmd.bat\n+   dir \"%vs_devcmd%\" >nul 2>nul && GOTO have_vs_devcmd\n+   GOTO not_2017\n+\n+:have_vs_devcmd\n+   REM Use VsDevCmd to setup the environment of this process.\n+   REM Setup CL for building 64-bit apps using 64-bit tools.\n+   @call \"%vs_devcmd%\" -no_logo -arch=x64 -host_arch=x64\n+\n+   SET tgt=%VSCMD_ARG_TGT_ARCH%\n+\n+   SET mn=%VCToolsInstallDir%\n+   SET msvc_includes=-I\"%mn%INCLUDE\"\n+   SET msvc_libs=-L\"%mn%lib\\%tgt%\"\n+   SET msvc_bin_dir=%mn%bin\\Host%VSCMD_ARG_HOST_ARCH%\\%tgt%\n+\n+   SET sdk_dir=%WindowsSdkDir%\n+   SET sdk_ver=%WindowsSDKVersion%\n+   SET si=%sdk_dir%Include\\%sdk_ver%\n+   SET sdk_includes=-I\"%si%ucrt\" -I\"%si%um\" -I\"%si%shared\"\n+   SET sl=%sdk_dir%lib\\%sdk_ver%\n+   SET sdk_libs=-L\"%sl%ucrt\\%tgt%\" -L\"%sl%um\\%tgt%\"\n+\n+   SET vs_ver=%VisualStudioVersion%\n+\n+   GOTO print_vars\n+\n+REM ================================================================\n+\n+:not_2017\n+   REM See if VS2015 is installed.\n+\n+   SET vs_2015_bat=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat\n+   dir \"%vs_2015_bat%\" >nul 2>nul && GOTO have_vs_2015\n+   GOTO not_2015\n+\n+:have_vs_2015\n+   REM Use VcVarsAll like the \"x64 Native\" command prompt.\n+   REM Setup CL for building 64-bit apps using 64-bit tools.\n+   @call \"%vs_2015_bat%\" amd64\n+\n+   REM Note that in VS2015 they use \"x64\" in some contexts and \"amd64\" in others.\n+   SET mn=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\\n+   SET msvc_includes=-I\"%mn%INCLUDE\"\n+   SET msvc_libs=-L\"%mn%lib\\amd64\"\n+   SET msvc_bin_dir=%mn%bin\\amd64\n+\n+   SET sdk_dir=%WindowsSdkDir%\n+   SET sdk_ver=%WindowsSDKVersion%\n+   SET si=%sdk_dir%Include\\%sdk_ver%\n+   SET sdk_includes=-I\"%si%ucrt\" -I\"%si%um\" -I\"%si%shared\" -I\"%si%winrt\"\n+   SET sl=%sdk_dir%lib\\%sdk_ver%\n+   SET sdk_libs=-L\"%sl%ucrt\\x64\" -L\"%sl%um\\x64\"\n+\n+   SET vs_ver=%VisualStudioVersion%\n+\n+   GOTO print_vars\n+\n+REM ================================================================\n+\n+:not_2015\n+   echo \"ERROR: unsupported VS version (older than VS2015)\" >&2\n+   EXIT /B 1\n+\n+REM ================================================================\n+\n+:print_vars\n+   REM Dump the essential vars to stdout to allow the main\n+   REM Makefile to include it.  See config.mak.uname.\n+   REM Include DOS-style and BASH-style path for bin dir.\n+\n+   echo msvc_bin_dir=%msvc_bin_dir%\n+   SET X1=%msvc_bin_dir:C:=/C%\n+   SET X2=%X1:\\=/%\n+   echo msvc_bin_dir_msys=%X2%\n+\n+   echo msvc_includes=%msvc_includes%\n+   echo msvc_libs=%msvc_libs%\n+\n+   echo sdk_includes=%sdk_includes%\n+   echo sdk_libs=%sdk_libs%\n+\n+   echo vs_ver=%vs_ver%\n+\n+   EXIT /B 0\ndiff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl\nindex a87d0da512..c7b021bfac 100755\n--- a/compat/vcbuild/scripts/clink.pl\n+++ b/compat/vcbuild/scripts/clink.pl\n@@ -12,32 +12,62 @@\n use strict;\n my @args = ();\n my @cflags = ();\n+my @lflags = ();\n my $is_linking = 0;\n+my $is_debug = 0;\n while (@ARGV) {\n \tmy $arg = shift @ARGV;\n-\tif (\"$arg\" =~ /^-[DIMGO]/) {\n+\tif (\"$arg\" eq \"-DDEBUG\") {\n+\t    # Some vcpkg-based libraries have different names for release\n+\t    # and debug versions.  This hack assumes that -DDEBUG comes\n+\t    # before any \"-l*\" flags.\n+\t    $is_debug = 1;\n+\t}\n+\tif (\"$arg\" =~ /^-[DIMGOZ]/) {\n \t\tpush(@cflags, $arg);\n \t} elsif (\"$arg\" eq \"-o\") {\n \t\tmy $file_out = shift @ARGV;\n \t\tif (\"$file_out\" =~ /exe$/) {\n \t\t\t$is_linking = 1;\n+\t\t\t# Create foo.exe and foo.pdb\n \t\t\tpush(@args, \"-OUT:$file_out\");\n \t\t} else {\n+\t\t\t# Create foo.o and foo.o.pdb\n \t\t\tpush(@args, \"-Fo$file_out\");\n+\t\t\tpush(@args, \"-Fd$file_out.pdb\");\n \t\t}\n \t} elsif (\"$arg\" eq \"-lz\") {\n+\t    if ($is_debug) {\n+\t\tpush(@args, \"zlibd.lib\");\n+\t    } else{\n \t\tpush(@args, \"zlib.lib\");\n+\t    }\n \t} elsif (\"$arg\" eq \"-liconv\") {\n-\t\tpush(@args, \"iconv.lib\");\n+\t\tpush(@args, \"libiconv.lib\");\n \t} elsif (\"$arg\" eq \"-lcrypto\") {\n \t\tpush(@args, \"libeay32.lib\");\n \t} elsif (\"$arg\" eq \"-lssl\") {\n \t\tpush(@args, \"ssleay32.lib\");\n \t} elsif (\"$arg\" eq \"-lcurl\") {\n-\t\tpush(@args, \"libcurl.lib\");\n+\t\tmy $lib = \"\";\n+\t\t# Newer vcpkg definitions call this libcurl_imp.lib; Do we\n+\t\t# need to use that instead?\n+\t\tforeach my $flag (@lflags) {\n+\t\t\tif ($flag =~ /^-LIBPATH:(.*)/) {\n+\t\t\t\tforeach my $l (\"libcurl_imp.lib\", \"libcurl.lib\") {\n+\t\t\t\t\tif (-f \"$1/$l\") {\n+\t\t\t\t\t\t$lib = $l;\n+\t\t\t\t\t\tlast;\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t\tpush(@args, $lib);\n+\t} elsif (\"$arg\" eq \"-lexpat\") {\n+\t\tpush(@args, \"expat.lib\");\n \t} elsif (\"$arg\" =~ /^-L/ && \"$arg\" ne \"-LTCG\") {\n \t\t$arg =~ s/^-L/-LIBPATH:/;\n-\t\tpush(@args, $arg);\n+\t\tpush(@lflags, $arg);\n \t} elsif (\"$arg\" =~ /^-R/) {\n \t\t# eat\n \t} else {\n@@ -45,10 +75,11 @@\n \t}\n }\n if ($is_linking) {\n+\tpush(@args, @lflags);\n \tunshift(@args, \"link.exe\");\n } else {\n \tunshift(@args, \"cl.exe\");\n \tpush(@args, @cflags);\n }\n-#printf(\"**** @args\\n\");\n+printf(STDERR \"**** @args\\n\\n\\n\") if (!defined($ENV{'QUIET_GEN'}));\n exit (system(@args) != 0);\ndiff --git a/compat/vcbuild/vcpkg_copy_dlls.bat b/compat/vcbuild/vcpkg_copy_dlls.bat\nnew file mode 100644\nindex 0000000000..13661c14f8\n--- /dev/null\n+++ b/compat/vcbuild/vcpkg_copy_dlls.bat\n@@ -0,0 +1,39 @@\n+@ECHO OFF\n+REM ================================================================\n+REM This script is an optional step. It copies the *.dll and *.pdb\n+REM files (created by vcpkg_install.bat) into the top-level directory\n+REM of the repo so that you can type \"./git.exe\" and find them without\n+REM having to fixup your PATH.\n+REM\n+REM NOTE: Because the names of some DLL files change between DEBUG and\n+REM NOTE: RELEASE builds when built using \"vcpkg.exe\", you will need\n+REM NOTE: to copy up the corresponding version.\n+REM ================================================================\n+\n+\tSETLOCAL EnableDelayedExpansion\n+\n+\t@FOR /F \"delims=\" %%D IN (\"%~dp0\") DO @SET cwd=%%~fD\n+\tcd %cwd%\n+\n+\tSET arch=x64-windows\n+\tSET inst=%cwd%vcpkg\\installed\\%arch%\n+\n+\tIF [%1]==[release] (\n+\t\techo Copying RELEASE mode DLLs to repo root...\n+\t) ELSE IF [%1]==[debug] (\n+\t\tSET inst=%inst%\\debug\n+\t\techo Copying DEBUG mode DLLs to repo root...\n+\t) ELSE (\n+\t\techo ERROR: Invalid argument.\n+\t\techo Usage: %~0 release\n+\t\techo Usage: %~0 debug\n+\t\tEXIT /B 1\n+\t)\n+\n+\txcopy /e/s/v/y %inst%\\bin\\*.dll ..\\..\\\n+\txcopy /e/s/v/y %inst%\\bin\\*.pdb ..\\..\\\n+\n+\txcopy /e/s/v/y %inst%\\bin\\*.dll ..\\..\\t\\helper\\\n+\txcopy /e/s/v/y %inst%\\bin\\*.pdb ..\\..\\t\\helper\\\n+\n+\tEXIT /B 0\ndiff --git a/compat/vcbuild/vcpkg_install.bat b/compat/vcbuild/vcpkg_install.bat\nnew file mode 100644\nindex 0000000000..ebd0bad242\n--- /dev/null\n+++ b/compat/vcbuild/vcpkg_install.bat\n@@ -0,0 +1,80 @@\n+@ECHO OFF\n+REM ================================================================\n+REM This script installs the \"vcpkg\" source package manager and uses\n+REM it to build the third-party libraries that git requires when it\n+REM is built using MSVC.\n+REM\n+REM [1] Install VCPKG.\n+REM     [a] Create <root>/compat/vcbuild/vcpkg/\n+REM     [b] Download \"vcpkg\".\n+REM     [c] Compile using the currently installed version of VS.\n+REM     [d] Create <root>/compat/vcbuild/vcpkg/vcpkg.exe\n+REM\n+REM [2] Install third-party libraries.\n+REM     [a] Download each (which may also install CMAKE).\n+REM     [b] Compile in RELEASE mode and install in:\n+REM         vcpkg/installed/<arch>/{bin,lib}\n+REM     [c] Compile in DEBUG mode and install in:\n+REM         vcpkg/installed/<arch>/debug/{bin,lib}\n+REM     [d] Install headers in:\n+REM         vcpkg/installed/<arch>/include\n+REM\n+REM [3] Create a set of MAKE definitions for the top-level\n+REM     Makefile to allow \"make MSVC=1\" to find the above\n+REM     third-party libraries.\n+REM     [a] Write vcpkg/VCPGK-DEFS\n+REM\n+REM https://blogs.msdn.microsoft.com/vcblog/2016/09/19/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows/\n+REM https://github.com/Microsoft/vcpkg\n+REM https://vcpkg.readthedocs.io/en/latest/\n+REM ================================================================\n+\n+\tSETLOCAL EnableDelayedExpansion\n+\n+\t@FOR /F \"delims=\" %%D IN (\"%~dp0\") DO @SET cwd=%%~fD\n+\tcd %cwd%\n+\n+\tdir vcpkg\\vcpkg.exe >nul 2>nul && GOTO :install_libraries\n+\n+\techo Fetching vcpkg in %cwd%vcpkg\n+\tgit.exe clone https://github.com/Microsoft/vcpkg vcpkg\n+\tIF ERRORLEVEL 1 ( EXIT /B 1 )\n+\n+\tcd vcpkg\n+\techo Building vcpkg\n+\tpowershell -exec bypass scripts\\bootstrap.ps1\n+\tIF ERRORLEVEL 1 ( EXIT /B 1 )\n+\n+\techo Successfully installed %cwd%vcpkg\\vcpkg.exe\n+\n+:install_libraries\n+\tSET arch=x64-windows\n+\n+\techo Installing third-party libraries...\n+\tFOR %%i IN (zlib expat libiconv openssl libssh2 curl) DO (\n+\t    cd %cwd%vcpkg\n+\t    IF NOT EXIST \"packages\\%%i_%arch%\" CALL :sub__install_one %%i\n+\t    IF ERRORLEVEL 1 ( EXIT /B 1 )\n+\t)\n+\n+:install_defines\n+\tcd %cwd%\n+\tSET inst=%cwd%vcpkg\\installed\\%arch%\n+\n+\techo vcpkg_inc=-I\"%inst%\\include\">VCPKG-DEFS\n+\techo vcpkg_rel_lib=-L\"%inst%\\lib\">>VCPKG-DEFS\n+\techo vcpkg_rel_bin=\"%inst%\\bin\">>VCPKG-DEFS\n+\techo vcpkg_dbg_lib=-L\"%inst%\\debug\\lib\">>VCPKG-DEFS\n+\techo vcpkg_dbg_bin=\"%inst%\\debug\\bin\">>VCPKG-DEFS\n+\n+\tEXIT /B 0\n+\n+\n+:sub__install_one\n+\techo     Installing package %1...\n+\n+\t.\\vcpkg.exe install %1:%arch%\n+\tIF ERRORLEVEL 1 ( EXIT /B 1 )\n+\n+\techo     Finished %1\n+\tgoto :EOF\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 473613a20d..b8c52e49d2 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -1,5 +1,9 @@\n # Platform specific Makefile tweaks based on uname detection\n \n+# Define NO_SAFESEH if you need MSVC/Visual Studio to ignore the lack of\n+# Microsoft's Safe Exception Handling in libraries (such as zlib).\n+# Typically required for VS2013+/32-bit compilation on Vista+ versions.\n+\n uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')\n uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')\n@@ -11,6 +15,19 @@ ifdef MSVC\n \t# avoid the MingW and Cygwin configuration sections\n \tuname_S := Windows\n \tuname_O := Windows\n+\n+\t# Generate and include makefile variables that point to the\n+\t# currently installed set of MSVC command line tools.\n+compat/vcbuild/MSVC-DEFS-GEN: compat/vcbuild/find_vs_env.bat\n+\t@\"$<\" | tr '\\\\' / >\"$@\"\n+include compat/vcbuild/MSVC-DEFS-GEN\n+\n+\t# See if vcpkg and the vcpkg-build versions of the third-party\n+\t# libraries that we use are installed.  We include the result\n+\t# to get $(vcpkg_*) variables defined for the Makefile.\n+compat/vcbuild/VCPKG-DEFS: compat/vcbuild/vcpkg_install.bat\n+\t@\"$<\"\n+include compat/vcbuild/VCPKG-DEFS\n endif\n \n # We choose to avoid \"if .. else if .. else .. endif endif\"\n@@ -356,6 +373,19 @@ endif\n ifeq ($(uname_S),Windows)\n \tGIT_VERSION := $(GIT_VERSION).MSVC\n \tpathsep = ;\n+\t# Assume that this is built in Git for Windows' SDK\n+\tifeq (MINGW32,$(MSYSTEM))\n+\t\tprefix = /mingw32\n+\telse\n+\t\tprefix = /mingw64\n+\tendif\n+\t# Prepend MSVC 64-bit tool-chain to PATH.\n+\t#\n+\t# A regular Git Bash *does not* have cl.exe in its $PATH. As there is a\n+\t# link.exe next to, and required by, cl.exe, we have to prepend this\n+\t# onto the existing $PATH.\n+\t#\n+\tSANE_TOOL_PATH ?= $(msvc_bin_dir_msys)\n \tHAVE_ALLOCA_H = YesPlease\n \tNO_PREAD = YesPlease\n \tNEEDS_CRYPTO_WITH_SSL = YesPlease\n@@ -368,11 +398,14 @@ ifeq ($(uname_S),Windows)\n \tNO_STRCASESTR = YesPlease\n \tNO_STRLCPY = YesPlease\n \tNO_MEMMEM = YesPlease\n-\t# NEEDS_LIBICONV = YesPlease\n-\tNO_ICONV = YesPlease\n+\tNEEDS_LIBICONV = YesPlease\n \tNO_STRTOUMAX = YesPlease\n \tNO_MKDTEMP = YesPlease\n-\tSNPRINTF_RETURNS_BOGUS = YesPlease\n+\tNO_INTTYPES_H = YesPlease\n+\t# VS2015 with UCRT claims that snprintf and friends are C99 compliant,\n+\t# so we don't need this:\n+\t#\n+\t#   SNPRINTF_RETURNS_BOGUS = YesPlease\n \tNO_SVN_TESTS = YesPlease\n \tRUNTIME_PREFIX = YesPlease\n \tHAVE_WPGMPTR = YesWeDo\n@@ -385,7 +418,6 @@ ifeq ($(uname_S),Windows)\n \tNO_REGEX = YesPlease\n \tNO_GETTEXT = YesPlease\n \tNO_PYTHON = YesPlease\n-\tBLK_SHA1 = YesPlease\n \tETAGS_TARGET = ETAGS\n \tNO_POSIX_GOODIES = UnfortunatelyYes\n \tNATIVE_CRLF = YesPlease\n@@ -394,24 +426,44 @@ ifeq ($(uname_S),Windows)\n \tCC = compat/vcbuild/scripts/clink.pl\n \tAR = compat/vcbuild/scripts/lib.pl\n \tCFLAGS =\n-\tBASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE\n+\tBASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE\n \tCOMPAT_OBJS = compat/msvc.o compat/winansi.o \\\n \t\tcompat/win32/path-utils.o \\\n \t\tcompat/win32/pthread.o compat/win32/syslog.o \\\n \t\tcompat/win32/trace2_win32_process_info.o \\\n \t\tcompat/win32/dirent.o\n-\tCOMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\\\".exe\\\"\n+\tCOMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\\\".exe\\\"\n \tBASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE\n-\tEXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj\n+\t# invalidcontinue.obj allows Git's source code to close the same file\n+\t# handle twice, or to access the osfhandle of an already-closed stdout\n+\t# See https://msdn.microsoft.com/en-us/library/ms235330.aspx\n+\tEXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib\n \tPTHREAD_LIBS =\n \tlib =\n+\tBASIC_CFLAGS += $(vcpkg_inc) $(sdk_includes) $(msvc_includes)\n+ifndef DEBUG\n+\tBASIC_CFLAGS += $(vcpkg_rel_lib)\n+else\n+\tBASIC_CFLAGS += $(vcpkg_dbg_lib)\n+endif\n+\tBASIC_CFLAGS += $(sdk_libs) $(msvc_libs)\n+\n \tBASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1\n+\t# Always give \"-Zi\" to the compiler and \"-debug\" to linker (even in\n+\t# release mode) to force a PDB to be generated (like RelWithDebInfo).\n+\tBASIC_CFLAGS += -Zi\n+\tBASIC_LDFLAGS += -debug -Zf\n+\n+ifdef NO_SAFESEH\n+\tLDFLAGS += -SAFESEH:NO\n+endif\n+\n ifndef DEBUG\n-\tBASIC_CFLAGS += -GL -Os -MD\n-\tBASIC_LDFLAGS += -LTCG\n+\tBASIC_CFLAGS += -GL -Gy -O2 -Oy- -MD -DNDEBUG\n+\tBASIC_LDFLAGS += -release -LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:CV,FIXUP\n \tAR += -LTCG\n else\n-\tBASIC_CFLAGS += -Zi -MDd\n+\tBASIC_CFLAGS += -MDd -DDEBUG -D_DEBUG\n endif\n \tX = .exe\n \n-- \ngitgitgadget\n\n"},{"id":"378015","messageId":"42f5b8cee8a850a68966de52bf0e588018bbf058.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 17/20] msvc: add pragmas for common warnings","fromName":"Philip Oakley via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:40Z","receivedAt":"2019-06-25T14:49:48Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: Philip Oakley <philipoakley@iee.org>\n\nMSVC can be overzealous about some warnings. Disable them.\n\nSigned-off-by: Philip Oakley <philipoakley@iee.org>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/msvc.h | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/compat/msvc.h b/compat/msvc.h\nindex d7525cf61d..1d7a8c6145 100644\n--- a/compat/msvc.h\n+++ b/compat/msvc.h\n@@ -6,6 +6,10 @@\n #include <malloc.h>\n #include <io.h>\n \n+#pragma warning(disable: 4018) /* signed/unsigned comparison */\n+#pragma warning(disable: 4244) /* type conversion, possible loss of data */\n+#pragma warning(disable: 4090) /* 'function' : different 'const' qualifiers (ALLOC_GROW etc.)*/\n+\n /* porting function */\n #define inline __inline\n #define __inline__ __inline\n-- \ngitgitgadget\n\n"},{"id":"378017","messageId":"7cb0434fac0cd73bd624571f90eed77e93181858.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 19/20] msvc: avoid debug assertion windows in Debug Mode","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:42Z","receivedAt":"2019-06-25T14:49:49Z","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\nFor regular debugging, it is pretty helpful when a debug assertion in a\nrunning application triggers a window that offers to start the debugger.\n\nHowever, when running the test suite, it is not so helpful, in\nparticular when the debug assertions are then suppressed anyway because\nwe disable the invalid parameter checking (via invalidcontinue.obj, see\nthe comment in config.mak.uname about that object for more information).\n\nSo let's simply disable that window in Debug Mode (it is already\ndisabled in Release Mode).\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex d01e88c2f8..433838391f 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2437,6 +2437,10 @@ int wmain(int argc, const wchar_t **wargv)\n \ttrace2_initialize_clock();\n \n #ifdef _MSC_VER\n+#ifdef _DEBUG\n+\t_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);\n+#endif\n+\n #ifdef USE_MSVC_CRTDBG\n \t_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);\n #endif\n-- \ngitgitgadget\n\n"},{"id":"378019","messageId":"4a7ceb21725f18f48593085ea22decfb6fc153b3.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 20/20] msvc: ignore .dll and incremental compile output","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:42Z","receivedAt":"2019-06-25T14:49:50Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nIgnore .dll files copied into the top-level directory.\nIgnore MSVC incremental compiler output files.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .gitignore | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/.gitignore b/.gitignore\nindex 2374f77a1a..ba0e52c4d1 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -226,6 +226,11 @@\n *.user\n *.idb\n *.pdb\n+*.ilk\n+*.iobj\n+*.ipdb\n+*.dll\n+.vs/\n /Debug/\n /Release/\n *.dSYM\n-- \ngitgitgadget\n"},{"id":"378016","messageId":"7cfd0fc9b42eee9bac026f7541b6cceec215000b.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 12/20] msvc: define ftello()","fromName":"Jeff Hostetler via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:37Z","receivedAt":"2019-06-25T14:49:52Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nIt is just called differently in MSVC's headers.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/msvc.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/compat/msvc.h b/compat/msvc.h\nindex d336d80670..d7525cf61d 100644\n--- a/compat/msvc.h\n+++ b/compat/msvc.h\n@@ -18,6 +18,8 @@\n \n #undef ERROR\n \n+#define ftello _ftelli64\n+\n typedef int sigset_t;\n /* open for reading, writing, or both (not in fcntl.h) */\n #define O_ACCMODE     (_O_RDONLY | _O_WRONLY | _O_RDWR)\n-- \ngitgitgadget\n\n"},{"id":"378018","messageId":"99a2939cc2d4501d37e806de9273c8f9832b7849.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 09/20] msvc: define O_ACCMODE","fromName":"Philip Oakley via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:35Z","receivedAt":"2019-06-25T14:49:53Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: Philip Oakley <philipoakley@iee.org>\n\nThis constant is not defined in MSVC's headers.\n\nIn UCRT's fcntl.h, _O_RDONLY, _O_WRONLY and _O_RDWR are defined as 0, 1\nand 2, respectively. Yes, that means that UCRT breaks with the tradition\nthat O_RDWR == O_RDONLY | O_WRONLY.\n\nIt is a perfectly legal way to define those constants, though, therefore\nwe need to take care of defining O_ACCMODE accordingly.\n\nThis is particularly important in order to keep our \"open() can set\nerrno to EISDIR\" emulation working: it tests that (flags & O_ACCMODE) is\nnot identical to O_RDONLY before going on to test specifically whether\nthe file for which open() reported EACCES is, in fact, a directory.\n\nSigned-off-by: Philip Oakley <philipoakley@iee.org>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/msvc.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/compat/msvc.h b/compat/msvc.h\nindex 04b4750b87..d336d80670 100644\n--- a/compat/msvc.h\n+++ b/compat/msvc.h\n@@ -19,6 +19,8 @@\n #undef ERROR\n \n typedef int sigset_t;\n+/* open for reading, writing, or both (not in fcntl.h) */\n+#define O_ACCMODE     (_O_RDONLY | _O_WRONLY | _O_RDWR)\n \n #include \"compat/mingw.h\"\n \n-- \ngitgitgadget\n\n"},{"id":"378020","messageId":"71d85b58b66af94b6e85776f74a63774bfb91845.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 05/20] obstack: fix compiler warning","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:32Z","receivedAt":"2019-06-25T14:50:02Z","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\nMS Visual C suggests that the construct\n\n\tcondition ? (int) i : (ptrdiff_t) d\n\nis incorrect. Let's fix this by casting to ptrdiff_t also for the\npositive arm of the conditional.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/obstack.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/obstack.h b/compat/obstack.h\nindex ced94d0118..ae36ed6a66 100644\n--- a/compat/obstack.h\n+++ b/compat/obstack.h\n@@ -496,7 +496,7 @@ __extension__\t\t\t\t\t\t\t\t\\\n ( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk,\t\t\\\n   ((((h)->temp.tempint > 0\t\t\t\t\t\t\\\n     && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk))\t\\\n-   ? (int) ((h)->next_free = (h)->object_base\t\t\t\t\\\n+   ? (ptrdiff_t) ((h)->next_free = (h)->object_base\t\t\t\t\\\n \t    = (h)->temp.tempint + (char *) (h)->chunk)\t\t\t\\\n    : (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))\n \n-- \ngitgitgadget\n\n"},{"id":"378021","messageId":"0a2985dc3c096023928ef81eea6da05ed1cd73f7.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 08/20] msvc: include sigset_t definition","fromName":"Philip Oakley via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:34Z","receivedAt":"2019-06-25T14:50:02Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: Philip Oakley <philipoakley@iee.org>\n\nOn MSVC (VS2008) sigset_t is not defined.\n\nSigned-off-by: Philip Oakley <philipoakley@iee.org>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/msvc.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/compat/msvc.h b/compat/msvc.h\nindex 29a8ce8204..04b4750b87 100644\n--- a/compat/msvc.h\n+++ b/compat/msvc.h\n@@ -18,6 +18,8 @@\n \n #undef ERROR\n \n+typedef int sigset_t;\n+\n #include \"compat/mingw.h\"\n \n #endif\n-- \ngitgitgadget\n\n"},{"id":"378022","messageId":"02f618464f85c0d61921f22948369f76b630e1e0.1561474167.git.gitgitgadget@gmail.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 06/20] mingw: replace mingw_startup() hack","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-25T14:49:33Z","receivedAt":"2019-06-25T14:50:03Z","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\nGit for Windows has special code to retrieve the command-line parameters\n(and even the environment) in UTF-16 encoding, so that they can be\nconverted to UTF-8. This is necessary because Git for Windows wants to\nuse UTF-8 encoded strings throughout its code, and the main() function\ndoes not get the parameters in that encoding.\n\nTo do that, we used the __wgetmainargs() function, which is not even a\nWin32 API function, but provided by the MINGW \"runtime\" instead.\n\nObviously, this method would not work with any compiler other than GCC,\nand in preparation for compiling with Visual C++, we would like to avoid\nprecisely that.\n\nLucky us, there is a much more elegant way: we can simply implement the\nUTF-16 variant of `main()`: `wmain()`.\n\nTo make that work, we need to link with -municode. The command-line\nparameters are passed to `wmain()` encoded in UTF-16, as desired, and\nthis method also works with GCC, and also with Visual C++ after\nadjusting the MSVC linker flags to force it to use `wmain()`.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.c   | 53 +++++++++++++++++++++++++++++++-----------------\n compat/mingw.h   | 22 ++++++++++----------\n config.mak.uname |  3 ++-\n 3 files changed, 47 insertions(+), 31 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 9b6d2400e1..0d8713e515 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2301,18 +2301,13 @@ static void setup_windows_environment(void)\n \t\tsetenv(\"TERM\", \"cygwin\", 1);\n }\n \n+#if !defined(_MSC_VER)\n /*\n  * Disable MSVCRT command line wildcard expansion (__getmainargs called from\n  * mingw startup code, see init.c in mingw runtime).\n  */\n int _CRT_glob = 0;\n-\n-typedef struct {\n-\tint newmode;\n-} _startupinfo;\n-\n-extern int __wgetmainargs(int *argc, wchar_t ***argv, wchar_t ***env, int glob,\n-\t\t_startupinfo *si);\n+#endif\n \n static NORETURN void die_startup(void)\n {\n@@ -2390,22 +2385,25 @@ static void maybe_redirect_std_handles(void)\n \t\t\t\t  GENERIC_WRITE, FILE_FLAG_NO_BUFFERING);\n }\n \n-void mingw_startup(void)\n+/*\n+ * We implement wmain() and compile with -municode, which would\n+ * normally ignore main(), but we call the latter from the former\n+ * so that we can handle non-ASCII command-line parameters\n+ * appropriately.\n+ *\n+ * To be more compatible with the core git code, we convert\n+ * argv into UTF8 and pass them directly to main().\n+ */\n+int wmain(int argc, const wchar_t **wargv)\n {\n-\tint i, maxlen, argc;\n-\tchar *buffer;\n-\twchar_t **wenv, **wargv;\n-\t_startupinfo si;\n+\tint i, maxlen, exit_status;\n+\tchar *buffer, **save;\n+\tconst char **argv;\n \n \ttrace2_initialize_clock();\n \n \tmaybe_redirect_std_handles();\n \n-\t/* get wide char arguments and environment */\n-\tsi.newmode = 0;\n-\tif (__wgetmainargs(&argc, &wargv, &wenv, _CRT_glob, &si) < 0)\n-\t\tdie_startup();\n-\n \t/* determine size of argv and environ conversion buffer */\n \tmaxlen = wcslen(wargv[0]);\n \tfor (i = 1; i < argc; i++)\n@@ -2415,9 +2413,16 @@ void mingw_startup(void)\n \tmaxlen = 3 * maxlen + 1;\n \tbuffer = malloc_startup(maxlen);\n \n-\t/* convert command line arguments and environment to UTF-8 */\n+\t/*\n+\t * Create a UTF-8 version of w_argv. Also create a \"save\" copy\n+\t * to remember all the string pointers because parse_options()\n+\t * will remove claimed items from the argv that we pass down.\n+\t */\n+\tALLOC_ARRAY(argv, argc + 1);\n+\tALLOC_ARRAY(save, argc + 1);\n \tfor (i = 0; i < argc; i++)\n-\t\t__argv[i] = wcstoutfdup_startup(buffer, wargv[i], maxlen);\n+\t\targv[i] = save[i] = wcstoutfdup_startup(buffer, wargv[i], maxlen);\n+\targv[i] = save[i] = NULL;\n \tfree(buffer);\n \n \t/* fix Windows specific environment settings */\n@@ -2436,6 +2441,16 @@ void mingw_startup(void)\n \n \t/* initialize Unicode console */\n \twinansi_init();\n+\n+\t/* invoke the real main() using our utf8 version of argv. */\n+\texit_status = main(argc, argv);\n+\n+\tfor (i = 0; i < argc; i++)\n+\t\tfree(save[i]);\n+\tfree(save);\n+\tfree(argv);\n+\n+\treturn exit_status;\n }\n \n int uname(struct utsname *buf)\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 593bdbffe6..210f1b01a8 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -562,18 +562,18 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen);\n extern CRITICAL_SECTION pinfo_cs;\n \n /*\n- * A replacement of main() that adds win32 specific initialization.\n+ * Git, like most portable C applications, implements a main() function. On\n+ * Windows, this main() function would receive parameters encoded in the\n+ * current locale, but Git for Windows would prefer UTF-8 encoded  parameters.\n+ *\n+ * To make that happen, we still declare main() here, and then declare and\n+ * implement wmain() (which is the Unicode variant of main()) and compile with\n+ * -municode. This wmain() function reencodes the parameters from UTF-16 to\n+ * UTF-8 format, sets up a couple of other things as required on Windows, and\n+ * then hands off to the main() function.\n  */\n-\n-void mingw_startup(void);\n-#define main(c,v) dummy_decl_mingw_main(void); \\\n-static int mingw_main(c,v); \\\n-int main(int argc, const char **argv) \\\n-{ \\\n-\tmingw_startup(); \\\n-\treturn mingw_main(__argc, (void *)__argv); \\\n-} \\\n-static int mingw_main(c,v)\n+int wmain(int argc, const wchar_t **w_argv);\n+int main(int argc, const char **argv);\n \n /*\n  * Used by Pthread API implementation for Windows\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 9fc053cac0..6ddece0350 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -401,7 +401,7 @@ ifeq ($(uname_S),Windows)\n \t\tcompat/win32/trace2_win32_process_info.o \\\n \t\tcompat/win32/dirent.o\n \tCOMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\\\".exe\\\"\n-\tBASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE\n+\tBASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE\n \tEXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj\n \tPTHREAD_LIBS =\n \tlib =\n@@ -548,6 +548,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tETAGS_TARGET = ETAGS\n \tNO_POSIX_GOODIES = UnfortunatelyYes\n \tDEFAULT_HELP_FORMAT = html\n+\tBASIC_LDFLAGS += -municode\n \tCOMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32\n \tCOMPAT_CFLAGS += -DSTRIP_EXTENSION=\\\".exe\\\"\n \tCOMPAT_OBJS += compat/mingw.o compat/winansi.o \\\n-- \ngitgitgadget\n\n"},{"id":"378030","messageId":"xmqqmui5fta9.fsf@gitster-ct.c.googlers.com","threadId":"51332","inReplyTo":"pull.149.v3.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 00/20] Fix MSVC support, at long last","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-06-25T17:50:54Z","receivedAt":"2019-06-25T17:51:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> Philip Oakley and Jeff Hostetler worked quite a bit on getting Git to\n> compile with MS Visual C again, and this patch series is the culmination of\n> those efforts.\n\nThanks, all.  Relative to the previous round, it seems there is only\none patch changed, which is a sign that it is stabilizing rather\nquickly ;-).\n\n> Please also note that this patch series is part 1 of 3 in a bigger story:\n> the next patch series will add support to build Git in Microsoft Visual\n> Studio, and the third patch series will add Continuous Testing by adding an\n> MSVC build and a corresponding parallelized test job to our Azure Pipeline.\n>\n> Changes since v2:\n>\n>  * Fixed the incorrect split-out of the \"msvc: update Makefile to allow for\n>    spaces in the compiler path\" patch: I had accidentally reverted that\n>    change in a later patch in the series.\n\nYup.  BROKEN_PATH_FIX stuff appears only once now in the series ;-)\n\nWill queue.  Again, thanks all.\n"}]}