{"thread":{"id":"54295","subject":"[PATCH 00/10] CMake and Visual Studio","startedAt":"2020-09-25T14:28:43Z","lastAt":"2020-09-30T23:09:02Z","messageCount":70,"participants":["Johannes Schindelin via GitGitGadget","Sibi Siddharthan","Junio C Hamano","Eric Sunshine","Johannes Schindelin","Junio C Hamano via GitGitGadget","Đoàn Trần Công Danh","Øystein Walle"],"isPatch":true,"patchVersion":1,"patchTotal":10},"messages":[{"id":"406335","messageId":"pull.738.git.1601044118.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":null,"subject":"[PATCH 00/10] CMake and Visual Studio","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-25T14:28:28Z","receivedAt":"2020-09-25T14:28:43Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"The intention of this patch series is to make it as easy as possible for a\nVisual Studio user to start building Git from scratch. The idea is to\n\n * clone Git's source code,\n * open it in Visual Studio via File>Open>Folder...\n * let CMake configure things (and vcpkg build the dependencies, which will\n   take a while), and\n * start the build.\n\nIt does require a Git for Windows to be installed (so that the source can be\ncloned, but also to run the shell script parts of the CMake configuration),\nand also to run the tests.\n\nThis patch series replaces the patch \"Ignore files generated by CMake\" I\nsent via https://github.com/gitgitgadget/git/pull/735.\n\nJohannes Schindelin (10):\n  cmake: ignore files generated by CMake as run in Visual Studio\n  cmake: do find Git for Windows' shell interpreter\n  cmake: ensure that the `vcpkg` packages are found on Windows\n  cmake: fall back to using `vcpkg`'s `msgfmt.exe` on Windows\n  cmake: quote the path accurately when editing `test-lib.sh`\n  cmake (Windows): let the `.dll` files are found when running the tests\n  cmake (Windows): complain when encountering an unknown compiler\n  cmake (Windows): initialize vcpkg/build dependencies automatically\n  cmake (Windows): recommend using Visual Studio's built-in CMake\n    support\n  hashmap_for_each_entry(): work around MSVC's run-time check failure #3\n\n .gitignore                          |  1 +\n attr.c                              |  2 +-\n blame.c                             |  4 +--\n bloom.c                             |  2 +-\n builtin/describe.c                  |  2 +-\n builtin/difftool.c                  |  2 +-\n builtin/fast-import.c               |  2 +-\n builtin/sparse-checkout.c           |  6 ++--\n config.c                            |  2 +-\n contrib/buildsystems/CMakeLists.txt | 43 +++++++++++++++++++++++++----\n merge-recursive.c                   | 10 +++----\n name-hash.c                         |  2 +-\n revision.c                          |  4 +--\n submodule-config.c                  |  2 +-\n t/helper/test-hashmap.c             |  2 +-\n t/helper/test-lazy-init-name-hash.c |  4 +--\n 16 files changed, 62 insertions(+), 28 deletions(-)\n\n\nbase-commit: e1cfff676549cdcd702cbac105468723ef2722f4\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-738%2Fdscho%2Fcmake-and-visual-studio-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-738/dscho/cmake-and-visual-studio-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/738\n-- \ngitgitgadget\n"},{"id":"406336","messageId":"ba314373e9cb867c1c36eea6fed655be27133872.1601044118.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.git.1601044118.gitgitgadget@gmail.com","subject":"[PATCH 01/10] cmake: ignore files generated by CMake as run in Visual Studio","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-25T14:28:29Z","receivedAt":"2020-09-25T14:28:44Z","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\nAs of recent Visual Studio versions, CMake support is built-in:\nhttps://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=vs-2019\n\nAll that needs to be done is to open the worktree as a folder, and\nVisual Studio will find the `CMakeLists.txt` file and automatically\ngenerate the project files.\n\nLet's ignore the entirety of those generated files.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .gitignore | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/.gitignore b/.gitignore\nindex d0f692a355..6521f3cf22 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -241,3 +241,4 @@ Release/\n /git.VC.VC.opendb\n /git.VC.db\n *.dSYM\n+/contrib/buildsystems/out\n-- \ngitgitgadget\n\n"},{"id":"406337","messageId":"05b4b69fee2b8c32769dd72dea182cfb72a14876.1601044118.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.git.1601044118.gitgitgadget@gmail.com","subject":"[PATCH 02/10] cmake: do find Git for Windows' shell interpreter","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-25T14:28:30Z","receivedAt":"2020-09-25T14:28:45Z","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\nBy default, Git for Windows does not install its `sh.exe` into the\n`PATH`. However, our current `CMakeLists.txt` expects to find a shell\ninterpreter in the `PATH`.\n\nSo let's fall back to looking in the default location where Git for\nWindows _does_ install a relatively convenient `sh.exe`:\n`C:\\Program Files\\Git\\bin\\sh.exe`\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 5007f173f1..d14fa4f3dc 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -43,8 +43,11 @@ set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n \n find_program(SH_EXE sh)\n if(NOT SH_EXE)\n-\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n-\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n+\tset(SH_EXE \"C:/Program Files/Git/bin/sh.exe\")\n+\tif(NOT EXISTS ${SH_EXE})\n+\t\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n+\t\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n+\tendif()\n endif()\n \n #Create GIT-VERSION-FILE using GIT-VERSION-GEN\n-- \ngitgitgadget\n\n"},{"id":"406338","messageId":"5967822a0c69b9f822d3a4f6412c626c4a43cc35.1601044118.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.git.1601044118.gitgitgadget@gmail.com","subject":"[PATCH 03/10] cmake: ensure that the `vcpkg` packages are found on Windows","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-25T14:28:31Z","receivedAt":"2020-09-25T14:28:47Z","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\nOn Windows, we use the `vcpkg` project to manage the dependencies, via\n`compat/vcbuild/`. Let's make sure that these dependencies are found by\ndefault.\n\nThis is needed because we are about to recommend loading the Git\nworktree as a folder into Visual Studio, relying on the automatic CMake\nsupport (which would make it relatively cumbersome to adjust the search\npath used by CMake manually).\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex d14fa4f3dc..16014ac4f7 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -40,6 +40,13 @@ cmake_minimum_required(VERSION 3.14)\n \n #set the source directory to root of git\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n+if(WIN32)\n+\tset(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n+\tlist(APPEND CMAKE_PREFIX_PATH \"${VCPKG_DIR}/installed/x64-windows\")\n+\n+\t# In the vcpkg edition, we need this to be able to link to libcurl\n+\tset(CURL_NO_CURL_CMAKE ON)\n+endif()\n \n find_program(SH_EXE sh)\n if(NOT SH_EXE)\n-- \ngitgitgadget\n\n"},{"id":"406339","messageId":"dddfa3a9b48fa24466a20952d485be1a7f515019.1601044118.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.git.1601044118.gitgitgadget@gmail.com","subject":"[PATCH 07/10] cmake (Windows): complain when encountering an unknown compiler","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-25T14:28:35Z","receivedAt":"2020-09-25T14:28: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\nWe have some custom handling regarding the link options, which are\nspecific to each compiler.\n\nTherefore: let's not just continue without setting the link options when\nconfiguring for a currently unhandled compiler, but error out.\n\nNote: for some reason, the `invalidcontinue.obj` trick seems not to work\nin this developer's hands when building Git in Debug mode: the assertion\ndialog that is supposed to be suppressed still pops up, complaining\nabout the `entry` variable being uninitialized when it is used in\n`config.c`'s line 1961.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 5a4e0ccb01..d21849b730 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -620,6 +620,8 @@ if(WIN32)\n \t\ttarget_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)\n \telseif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n \t\ttarget_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)\n+\telse()\n+\t\tmessage(FATAL_ERROR \"Unhandled compiler: ${CMAKE_C_COMPILER_ID}\")\n \tendif()\n elseif(UNIX)\n \ttarget_link_libraries(common-main pthread rt)\n-- \ngitgitgadget\n\n"},{"id":"406340","messageId":"bb8f122cdec94e1ec77b37ed16a7151f5e35a93a.1601044118.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.git.1601044118.gitgitgadget@gmail.com","subject":"[PATCH 06/10] cmake (Windows): let the `.dll` files are found when running the tests","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-25T14:28:34Z","receivedAt":"2020-09-25T14:28:50Z","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\nContrary to Unix-ish platforms, the dependencies' shared libraries are\nnot usually found in one central place. In our case, since we use\n`vcpkg`, they are to be found inside the `compat/vcbuild/vcpkg/` tree.\n\nLet's make sure that they are in the search path when running the tests.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex e66ae137c2..5a4e0ccb01 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -942,6 +942,9 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X='${EXE_EXTENSION}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n+if(WIN32)\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PATH=\\\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\\\"\\n\")\n+endif()\n \n #Make the tests work when building out of the source tree\n get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)\n-- \ngitgitgadget\n\n"},{"id":"406341","messageId":"8b3500a07c67d07e0928e8d6638d618ab118e1eb.1601044118.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.git.1601044118.gitgitgadget@gmail.com","subject":"[PATCH 05/10] cmake: quote the path accurately when editing `test-lib.sh`","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-25T14:28:33Z","receivedAt":"2020-09-25T14:28:51Z","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\nBy default, the build directory will be called something like\n`contrib/buildsystems/out/build/x64-Debug (default)` (note the space and\nthe parentheses). We need to make sure that such a path is quoted\nproperly when editing the assignment of the `GIT_BUILD_DIR` variable.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex acb197fba5..e66ae137c2 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -952,7 +952,7 @@ if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})\n \tfile(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake\n \t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \\\"GIT_BUILD_DIR=(.*)\\\")\\n\"\n \t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\\n\"\n-\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY\\\\\\\"/../${BUILD_DIR_RELATIVE}\\\" content \\\"\\${content}\\\")\\n\"\n+\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY/../${BUILD_DIR_RELATIVE}\\\\\\\"\\\" content \\\"\\${content}\\\")\\n\"\n \t\t\"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \\${content})\")\n \t#misc copies\n \tfile(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)\n-- \ngitgitgadget\n\n"},{"id":"406342","messageId":"3a07bd4916c3949eadaa10fde142fba0acaa974b.1601044118.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.git.1601044118.gitgitgadget@gmail.com","subject":"[PATCH 08/10] cmake (Windows): initialize vcpkg/build dependencies automatically","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-25T14:28:36Z","receivedAt":"2020-09-25T14:28:53Z","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 idea of having CMake support in Git's source tree is to enable\ncontributors on Windows to start contributing with little effort. To\nthat end, we just added some sensible defaults that will let users open\nthe worktree in Visual Studio and start building.\n\nThis expects the dependencies (such as zlib) to be available already,\nthough. If they are not available, we expect the user to run\n`compat/vcbuild/vcpkg_install.bat`.\n\nRather than requiring this step to be manual, detect the situation and\nrun it as part of the CMake configuration step.\n\nThis concludes our journey to make it as effortless as possible to start\ndeveloping Git in Visual Studio: all the developer needs to do is to\nclone Git's repository, open the worktree via `File>Open>Folder...` and\nwait for CMake to finish configuring.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex d21849b730..1eaeb8b8e0 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n if(WIN32)\n \tset(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n+\tif(NOT EXISTS ${VCPKG_DIR})\n+\t\tmessage(\"Initializinge vcpkg and building the Git's dependencies (this will take a while...)\")\n+\t\texecute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat)\n+\tendif()\n \tlist(APPEND CMAKE_PREFIX_PATH \"${VCPKG_DIR}/installed/x64-windows\")\n \n \t# In the vcpkg edition, we need this to be able to link to libcurl\n-- \ngitgitgadget\n\n"},{"id":"406343","messageId":"f07e4216669bcda728668d8c5cc99081bfca9f49.1601044119.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.git.1601044118.gitgitgadget@gmail.com","subject":"[PATCH 09/10] cmake (Windows): recommend using Visual Studio's built-in CMake support","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-25T14:28:37Z","receivedAt":"2020-09-25T14:28:53Z","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\nIt is a lot more convenient to use than having to specify the\nconfiguration in CMake manually (does not matter whether using the\ncommand-line or CMake's GUI).\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 12 +++++++++++-\n 1 file changed, 11 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 1eaeb8b8e0..442b4e69ad 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -4,7 +4,17 @@\n \n #[[\n \n-Instructions to run CMake:\n+Instructions how to use this in Visual Studio:\n+\n+Open the worktree as a folder. Visual Studio 2019 and later will detect\n+the CMake configuration automatically and set everything up for you,\n+ready to build. You can then run the tests in `t/` via a regular Git Bash.\n+\n+Note: Visual Studio also has the option of opening the CMake configuration\n+directly; Using this option, Visual Studio will not find the source code,\n+though, therefore the `File>Open>Folder...` option is preferred.\n+\n+Instructions to run CMake manually:\n \n cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n Eg.\n-- \ngitgitgadget\n\n"},{"id":"406344","messageId":"dc46d39611df4ebd90d9308364d887e638c1bc30.1601044119.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.git.1601044118.gitgitgadget@gmail.com","subject":"[PATCH 10/10] hashmap_for_each_entry(): work around MSVC's run-time check failure #3","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-25T14:28:38Z","receivedAt":"2020-09-25T14:28:55Z","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 compiling Git in Visual C, we do not have the luxury of\nsupport for `typeof()`, and therefore `OFFSETOF_VAR()` unfortunately\nhas to fall back to pointer arithmetic.\n\nWhen compiling code using the `hashmap_for_each_entry()` macro in Debug\nmode, this leads to the \"run-time check failure #3\" because the variable\npassed as `var` are not initialized, yet we calculate the pointer\ndifference `&(var->member)-var`.\n\nThis \"run-time check failure\" causes a scary dialog to pop up.\n\nWork around this by initializing the respective variables.\n\nNote: according to the C standard, performing pointer arithmetic\nwith `NULL` is not exactly well-defined, but it seems to work\nhere, and it is at least better than performing pointer arithmetic\nwith an uninitialized pointer.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n attr.c                              |  2 +-\n blame.c                             |  4 ++--\n bloom.c                             |  2 +-\n builtin/describe.c                  |  2 +-\n builtin/difftool.c                  |  2 +-\n builtin/fast-import.c               |  2 +-\n builtin/sparse-checkout.c           |  6 +++---\n config.c                            |  2 +-\n merge-recursive.c                   | 10 +++++-----\n name-hash.c                         |  2 +-\n revision.c                          |  4 ++--\n submodule-config.c                  |  2 +-\n t/helper/test-hashmap.c             |  2 +-\n t/helper/test-lazy-init-name-hash.c |  4 ++--\n 14 files changed, 23 insertions(+), 23 deletions(-)\n\ndiff --git a/attr.c b/attr.c\nindex a826b2ef1f..b4fde37877 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -160,7 +160,7 @@ static void all_attrs_init(struct attr_hashmap *map, struct attr_check *check)\n \t * field and fill each entry with its corresponding git_attr.\n \t */\n \tif (size != check->all_attrs_nr) {\n-\t\tstruct attr_hash_entry *e;\n+\t\tstruct attr_hash_entry *e = NULL;\n \t\tstruct hashmap_iter iter;\n \n \t\tREALLOC_ARRAY(check->all_attrs, size);\ndiff --git a/blame.c b/blame.c\nindex b475bfa1c0..e9879a772e 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -450,7 +450,7 @@ static int fingerprint_similarity(struct fingerprint *a, struct fingerprint *b)\n {\n \tint intersection = 0;\n \tstruct hashmap_iter iter;\n-\tconst struct fingerprint_entry *entry_a, *entry_b;\n+\tconst struct fingerprint_entry *entry_a, *entry_b = NULL;\n \n \thashmap_for_each_entry(&b->map, &iter, entry_b,\n \t\t\t\tentry /* member name */) {\n@@ -469,7 +469,7 @@ static void fingerprint_subtract(struct fingerprint *a, struct fingerprint *b)\n {\n \tstruct hashmap_iter iter;\n \tstruct fingerprint_entry *entry_a;\n-\tconst struct fingerprint_entry *entry_b;\n+\tconst struct fingerprint_entry *entry_b = NULL;\n \n \thashmap_iter_init(&b->map, &iter);\n \ndiff --git a/bloom.c b/bloom.c\nindex 1a573226e7..ee45e9ccce 100644\n--- a/bloom.c\n+++ b/bloom.c\n@@ -221,7 +221,7 @@ struct bloom_filter *get_bloom_filter(struct repository *r,\n \n \tif (diffopt.num_changes <= max_changes) {\n \t\tstruct hashmap pathmap;\n-\t\tstruct pathmap_hash_entry *e;\n+\t\tstruct pathmap_hash_entry *e = NULL;\n \t\tstruct hashmap_iter iter;\n \t\thashmap_init(&pathmap, pathmap_cmp, NULL, 0);\n \ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 7668591d57..8b281cf426 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -332,7 +332,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)\n \tif (!have_util) {\n \t\tstruct hashmap_iter iter;\n \t\tstruct commit *c;\n-\t\tstruct commit_name *n;\n+\t\tstruct commit_name *n = NULL;\n \n \t\tinit_commit_names(&commit_names);\n \t\thashmap_for_each_entry(&names, &iter, n,\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex 7ac432b881..a1527ea01c 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -344,7 +344,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,\n \tFILE *fp;\n \tstruct hashmap working_tree_dups, submodules, symlinks2;\n \tstruct hashmap_iter iter;\n-\tstruct pair_entry *entry;\n+\tstruct pair_entry *entry = NULL;\n \tstruct index_state wtindex;\n \tstruct checkout lstate, rstate;\n \tint rc, flags = RUN_GIT_CMD, err = 0;\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 1bf50a73dc..72154383c3 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -498,7 +498,7 @@ static void invalidate_pack_id(unsigned int id)\n \tunsigned long lu;\n \tstruct tag *t;\n \tstruct hashmap_iter iter;\n-\tstruct object_entry *e;\n+\tstruct object_entry *e = NULL;\n \n \thashmap_for_each_entry(&object_table, &iter, e, ent) {\n \t\tif (e->pack_id == id)\ndiff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c\nindex 4003f4d13a..fcd87da036 100644\n--- a/builtin/sparse-checkout.c\n+++ b/builtin/sparse-checkout.c\n@@ -67,7 +67,7 @@ static int sparse_checkout_list(int argc, const char **argv)\n \n \tif (pl.use_cone_patterns) {\n \t\tint i;\n-\t\tstruct pattern_entry *pe;\n+\t\tstruct pattern_entry *pe = NULL;\n \t\tstruct hashmap_iter iter;\n \t\tstruct string_list sl = STRING_LIST_INIT_DUP;\n \n@@ -153,7 +153,7 @@ static char *escaped_pattern(char *pattern)\n static void write_cone_to_file(FILE *fp, struct pattern_list *pl)\n {\n \tint i;\n-\tstruct pattern_entry *pe;\n+\tstruct pattern_entry *pe = NULL;\n \tstruct hashmap_iter iter;\n \tstruct string_list sl = STRING_LIST_INIT_DUP;\n \tstruct strbuf parent_pattern = STRBUF_INIT;\n@@ -465,7 +465,7 @@ static void add_patterns_cone_mode(int argc, const char **argv,\n \t\t\t\t   struct pattern_list *pl)\n {\n \tstruct strbuf buffer = STRBUF_INIT;\n-\tstruct pattern_entry *pe;\n+\tstruct pattern_entry *pe = NULL;\n \tstruct hashmap_iter iter;\n \tstruct pattern_list existing;\n \tchar *sparse_filename = get_sparse_checkout_filename();\ndiff --git a/config.c b/config.c\nindex 2bdff4457b..83c72dd6e6 100644\n--- a/config.c\n+++ b/config.c\n@@ -1953,7 +1953,7 @@ void git_configset_init(struct config_set *cs)\n \n void git_configset_clear(struct config_set *cs)\n {\n-\tstruct config_set_element *entry;\n+\tstruct config_set_element *entry = NULL;\n \tstruct hashmap_iter iter;\n \tif (!cs->hash_initialized)\n \t\treturn;\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex d0214335a7..11ea550b0d 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -2151,8 +2151,8 @@ static void handle_directory_level_conflicts(struct merge_options *opt,\n \t\t\t\t\t     struct tree *merge)\n {\n \tstruct hashmap_iter iter;\n-\tstruct dir_rename_entry *head_ent;\n-\tstruct dir_rename_entry *merge_ent;\n+\tstruct dir_rename_entry *head_ent = NULL;\n+\tstruct dir_rename_entry *merge_ent = NULL;\n \n \tstruct string_list remove_from_head = STRING_LIST_INIT_NODUP;\n \tstruct string_list remove_from_merge = STRING_LIST_INIT_NODUP;\n@@ -2221,7 +2221,7 @@ static struct hashmap *get_directory_renames(struct diff_queue_struct *pairs)\n {\n \tstruct hashmap *dir_renames;\n \tstruct hashmap_iter iter;\n-\tstruct dir_rename_entry *entry;\n+\tstruct dir_rename_entry *entry = NULL;\n \tint i;\n \n \t/*\n@@ -2590,7 +2590,7 @@ static struct string_list *get_renames(struct merge_options *opt,\n \tint i;\n \tstruct hashmap collisions;\n \tstruct hashmap_iter iter;\n-\tstruct collision_entry *e;\n+\tstruct collision_entry *e = NULL;\n \tstruct string_list *renames;\n \n \tcompute_collisions(&collisions, dir_renames, pairs);\n@@ -2862,7 +2862,7 @@ static void initial_cleanup_rename(struct diff_queue_struct *pairs,\n \t\t\t\t   struct hashmap *dir_renames)\n {\n \tstruct hashmap_iter iter;\n-\tstruct dir_rename_entry *e;\n+\tstruct dir_rename_entry *e = NULL;\n \n \thashmap_for_each_entry(dir_renames, &iter, e,\n \t\t\t\tent /* member name */) {\ndiff --git a/name-hash.c b/name-hash.c\nindex fb526a3775..a3f710b2f8 100644\n--- a/name-hash.c\n+++ b/name-hash.c\n@@ -706,7 +706,7 @@ void adjust_dirname_case(struct index_state *istate, char *name)\n \n struct cache_entry *index_file_exists(struct index_state *istate, const char *name, int namelen, int icase)\n {\n-\tstruct cache_entry *ce;\n+\tstruct cache_entry *ce = NULL;\n \tunsigned int hash = memihash(name, namelen);\n \n \tlazy_init_name_hash(istate);\ndiff --git a/revision.c b/revision.c\nindex 067030e64c..232de3f6f5 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -132,7 +132,7 @@ static void paths_and_oids_init(struct hashmap *map)\n static void paths_and_oids_clear(struct hashmap *map)\n {\n \tstruct hashmap_iter iter;\n-\tstruct path_and_oids_entry *entry;\n+\tstruct path_and_oids_entry *entry = NULL;\n \n \thashmap_for_each_entry(map, &iter, entry, ent /* member name */) {\n \t\toidset_clear(&entry->trees);\n@@ -215,7 +215,7 @@ void mark_trees_uninteresting_sparse(struct repository *r,\n \tunsigned has_interesting = 0, has_uninteresting = 0;\n \tstruct hashmap map;\n \tstruct hashmap_iter map_iter;\n-\tstruct path_and_oids_entry *entry;\n+\tstruct path_and_oids_entry *entry = NULL;\n \tstruct object_id *oid;\n \tstruct oidset_iter iter;\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex c569e22aa3..662b9d9c09 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -89,7 +89,7 @@ static void free_one_config(struct submodule_entry *entry)\n static void submodule_cache_clear(struct submodule_cache *cache)\n {\n \tstruct hashmap_iter iter;\n-\tstruct submodule_entry *entry;\n+\tstruct submodule_entry *entry = NULL;\n \n \tif (!cache->initialized)\n \t\treturn;\ndiff --git a/t/helper/test-hashmap.c b/t/helper/test-hashmap.c\nindex f38706216f..2bde90309b 100644\n--- a/t/helper/test-hashmap.c\n+++ b/t/helper/test-hashmap.c\n@@ -162,7 +162,7 @@ int cmd__hashmap(int argc, const char **argv)\n \twhile (strbuf_getline(&line, stdin) != EOF) {\n \t\tchar *cmd, *p1 = NULL, *p2 = NULL;\n \t\tunsigned int hash = 0;\n-\t\tstruct test_entry *entry;\n+\t\tstruct test_entry *entry = NULL;\n \n \t\t/* break line into command and up to two parameters */\n \t\tcmd = strtok(line.buf, DELIM);\ndiff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c\nindex cd1b4c9736..2cb1fa3d8c 100644\n--- a/t/helper/test-lazy-init-name-hash.c\n+++ b/t/helper/test-lazy-init-name-hash.c\n@@ -29,8 +29,8 @@ static void dump_run(void)\n \t\tchar name[FLEX_ARRAY];\n \t};\n \n-\tstruct dir_entry *dir;\n-\tstruct cache_entry *ce;\n+\tstruct dir_entry *dir = NULL;\n+\tstruct cache_entry *ce = NULL;\n \n \tread_cache();\n \tif (single) {\n-- \ngitgitgadget\n"},{"id":"406345","messageId":"efc93f1dd972614d197b919e17693a910e568736.1601044118.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.git.1601044118.gitgitgadget@gmail.com","subject":"[PATCH 04/10] cmake: fall back to using `vcpkg`'s `msgfmt.exe` on Windows","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-25T14:28:32Z","receivedAt":"2020-09-25T14:28:58Z","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\nWe are already relying on `vcpkg` to manage our dependencies, including\n`libiconv`. Let's also use the `msgfmt.exe` from there.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 16014ac4f7..acb197fba5 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -155,7 +155,11 @@ endif()\n \n find_program(MSGFMT_EXE msgfmt)\n if(NOT MSGFMT_EXE)\n-\tmessage(WARNING \"Text Translations won't be build\")\n+\tset(MSGFMT_EXE ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg/downloads/tools/msys2/msys64/usr/bin/msgfmt.exe)\n+\tif(NOT EXISTS ${MSGFMT_EXE})\n+\t\tmessage(WARNING \"Text Translations won't be build\")\n+\t\tunset(MSGFMT_EXE)\n+\tendif()\n endif()\n \n #Force all visual studio outputs to CMAKE_BINARY_DIR\n-- \ngitgitgadget\n\n"},{"id":"406346","messageId":"CAKiG+9V=BGX4k_dM-5JzYmko0cZfYXuSxEk5-UuHZpAqaWoU_A@mail.gmail.com","threadId":"54295","inReplyTo":"05b4b69fee2b8c32769dd72dea182cfb72a14876.1601044118.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 02/10] cmake: do find Git for Windows' shell interpreter","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-09-25T16:25:28Z","receivedAt":"2020-09-25T16:25:42Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> index 5007f173f1..d14fa4f3dc 100644\n> --- a/contrib/buildsystems/CMakeLists.txt\n> +++ b/contrib/buildsystems/CMakeLists.txt\n> @@ -43,8 +43,11 @@ set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n>\n>  find_program(SH_EXE sh)\n>  if(NOT SH_EXE)\n> -       message(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n> -                       \"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n> +       set(SH_EXE \"C:/Program Files/Git/bin/sh.exe\")\n> +       if(NOT EXISTS ${SH_EXE})\n> +               message(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n> +                               \"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n> +       endif()\n>  endif()\n>\nLet's not point SH_EXE to the 'program files' directory.\nfind_program() searches 'PATH' for sh.\nSince the Git-for-windows installer does append\n'your_installation_directory'/Git/bin to the PATH variable, it should\nbe fine.\n\nI personally don't install my dev tools(except Visual Studio) to\nProgram Files(because of the _space_), it messes up the Makefiles.\n\nThank You,\nSibi Siddharthan\n"},{"id":"406364","messageId":"CAKiG+9XqJ92rjVczBG9ByVK_KRfJeToO0pFb3RhFpom2ChFE-g@mail.gmail.com","threadId":"54295","inReplyTo":"dddfa3a9b48fa24466a20952d485be1a7f515019.1601044118.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 07/10] cmake (Windows): complain when encountering an unknown compiler","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-09-25T17:29:29Z","receivedAt":"2020-09-25T17:29:43Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Fri, Sep 25, 2020 at 7:58 PM Johannes Schindelin via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n>\n> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> We have some custom handling regarding the link options, which are\n> specific to each compiler.\n>\n> Therefore: let's not just continue without setting the link options when\n> configuring for a currently unhandled compiler, but error out.\n>\n> Note: for some reason, the `invalidcontinue.obj` trick seems not to work\n> in this developer's hands when building Git in Debug mode: the assertion\n> dialog that is supposed to be suppressed still pops up, complaining\n> about the `entry` variable being uninitialized when it is used in\n> `config.c`'s line 1961.\n\nDoes this happen when running Git under the Visual Studio debugger?\nIf so this might help\n_CrtSetReportMode(_CRT_ASSERT,0);\n\nAfter digging a bit more I found out that _CRTDBG_MODE_DEBUG is\nenvironment sensitive.\nIt depends on how the debugger handles DbgPrintEx().\n\nThank You,\nSibi Siddharthan\n"},{"id":"406374","messageId":"xmqqd029lnr3.fsf@gitster.c.googlers.com","threadId":"54295","inReplyTo":"f07e4216669bcda728668d8c5cc99081bfca9f49.1601044119.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 09/10] cmake (Windows): recommend using Visual Studio's built-in CMake support","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-09-25T18:22:56Z","receivedAt":"2020-09-25T18:23:04Z","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> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> It is a lot more convenient to use than having to specify the\n> configuration in CMake manually (does not matter whether using the\n> command-line or CMake's GUI).\n>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n>  contrib/buildsystems/CMakeLists.txt | 12 +++++++++++-\n>  1 file changed, 11 insertions(+), 1 deletion(-)\n>\n> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> index 1eaeb8b8e0..442b4e69ad 100644\n> --- a/contrib/buildsystems/CMakeLists.txt\n> +++ b/contrib/buildsystems/CMakeLists.txt\n> @@ -4,7 +4,17 @@\n>  \n>  #[[\n>  \n> -Instructions to run CMake:\n> +Instructions how to use this in Visual Studio:\n> +\n> +Open the worktree as a folder. Visual Studio 2019 and later will detect\n> +the CMake configuration automatically and set everything up for you,\n> +ready to build. You can then run the tests in `t/` via a regular Git Bash.\n> +\n> +Note: Visual Studio also has the option of opening the CMake configuration\n> +directly; Using this option, Visual Studio will not find the source code,\n> +though, therefore the `File>Open>Folder...` option is preferred.\n> +\n> +Instructions to run CMake manually:\n>  \n>  cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n>  Eg.\n\nHaving the primary case upfront is a good idea.  As we discussed,\nour source tree structure (especially the .gitignore we ship) only\nsupports an separate-dir build in contrib/buildsystems/out, so we\nshould update the \"manually\" part of the instruction to guide users\nto use the same location.  Perhaps something along the line of the\nattached.\n\nAlso, after the post-context of the attached patch, there are\nmentions of Visual Studio.  Please double check if they need\nadjustment, or more preferrably the above paragraph the patch in\nquestion added is all that is needed by Visual Studio users, in\nwhich case perhaps it would be a good idea to remove all mention of\nVisual Studio there to avoid sending confusing choices to the\nreaders.\n\nThanks.\n\n contrib/buildsystems/CMakeLists.txt | 16 +++++++---------\n 1 file changed, 7 insertions(+), 9 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 442b4e69ad..0c748949f9 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -16,15 +16,13 @@ though, therefore the `File>Open>Folder...` option is preferred.\n \n Instructions to run CMake manually:\n \n-cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n-Eg.\n-From the root of git source tree\n-\t`cmake contrib/buildsystems/ `\n-This will build the git binaries at the root\n-\n-For out of source builds, say build in 'git/git-build/'\n-\t`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`\n-This will build the git binaries in git-build directory\n+    mkdir -p contrib/buildsystems/out\n+    cd contrib/buildsystems/out\n+    cmake ../ -DCMAKE_BUILD_TYPE=Release\n+\n+This will build the git binaries in contrib/buildsystems/out\n+directory (our top-level .gitignore file knows to ignore contents of\n+this directory).\n \n Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n compiler flags\n"},{"id":"406376","messageId":"xmqq8scxln10.fsf@gitster.c.googlers.com","threadId":"54295","inReplyTo":"dc46d39611df4ebd90d9308364d887e638c1bc30.1601044119.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 10/10] hashmap_for_each_entry(): work around MSVC's run-time check failure #3","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-09-25T18:38:35Z","receivedAt":"2020-09-25T18:38:45Z","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> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> When compiling Git in Visual C, we do not have the luxury of\n> support for `typeof()`, and therefore `OFFSETOF_VAR()` unfortunately\n> has to fall back to pointer arithmetic.\n\nSigh.\n\nShort of changing the signature of hashmap_put_entry() and friends\nto also take the type of these variables, I do not see any kosher\nway to reimplement the users of OFFSETOF_VAR() to help compilers\nwithout typeof() offhand.  As a one-time annotation, the unfortunate\nnoise we see in this patch may be tolerable, but what may make this\napproach unsustainable is that average programmers would not know,\nwithout compiling with that particular compiler, if their new\nvariable that points at a hash_entry needs to have an oterwise\nunnecessary initialization.  Also the variables that are left\nuninitialized by this patch may later require such an initialization.\n\nOf course, it does not help that this workaround relies on an\nundefined behaviour, as you pointed out.\n\n> When compiling code using the `hashmap_for_each_entry()` macro in Debug\n> mode, this leads to the \"run-time check failure #3\" because the variable\n> passed as `var` are not initialized, yet we calculate the pointer\n> difference `&(var->member)-var`.\n\nWhoa, wait.  If it is just that macro, can we perhaps do something\nlike the attached patch?\n\n>\n> This \"run-time check failure\" causes a scary dialog to pop up.\n>\n> Work around this by initializing the respective variables.\n>\n> Note: according to the C standard, performing pointer arithmetic\n> with `NULL` is not exactly well-defined, but it seems to work\n> here, and it is at least better than performing pointer arithmetic\n> with an uninitialized pointer.\n\n hashmap.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/hashmap.h b/hashmap.h\nindex ef220de4c6..49cd8a8e92 100644\n--- a/hashmap.h\n+++ b/hashmap.h\n@@ -449,7 +449,7 @@ static inline struct hashmap_entry *hashmap_iter_first(struct hashmap *map,\n  * containing a @member which is a \"struct hashmap_entry\"\n  */\n #define hashmap_for_each_entry(map, iter, var, member) \\\n-\tfor (var = hashmap_iter_first_entry_offset(map, iter, \\\n+\tfor (var = NULL, var = hashmap_iter_first_entry_offset(map, iter, \\\n \t\t\t\t\t\tOFFSETOF_VAR(var, member)); \\\n \t\tvar; \\\n \t\tvar = hashmap_iter_next_entry_offset(iter, \\\n"},{"id":"406386","messageId":"CAPig+cTPi1yi7WQf_eWa+bFRJEdtULFO3yYqJh3nm=_CtEe6CQ@mail.gmail.com","threadId":"54295","inReplyTo":"bb8f122cdec94e1ec77b37ed16a7151f5e35a93a.1601044118.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 06/10] cmake (Windows): let the `.dll` files are found when running the tests","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2020-09-25T19:48:08Z","receivedAt":"2020-09-25T20:35:44Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Sep 25, 2020 at 10:28 AM Johannes Schindelin via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n> cmake (Windows): let the `.dll` files are found when running the tests\n\nI'm having trouble parsing this. Maybe you want s/let/ensure/ ?\n"},{"id":"406430","messageId":"xmqqy2kwiimi.fsf@gitster.c.googlers.com","threadId":"54295","inReplyTo":"xmqq8scxln10.fsf@gitster.c.googlers.com","subject":"Re: [PATCH 10/10] hashmap_for_each_entry(): work around MSVC's run-time check failure #3","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-09-26T16:54:13Z","receivedAt":"2020-09-26T16:54:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Whoa, wait.  If it is just that macro, can we perhaps do something\n> like the attached patch?\n\nI looked at all the uses of OFFSETOF_VAR() and I think the one used\nfor hashmap_for_each_entry() is the only instance that 'var' given\nto it can legitimately be uninitialized, if typeof() were available.\n\nHere are the findings.\n\n#define hashmap_put_entry(map, keyvar, member) \\\n\tcontainer_of_or_null_offset(hashmap_put(map, &(keyvar)->member), \\\n\t\t\t\tOFFSETOF_VAR(keyvar, member))\n\nThe keyvar is a pointer to the entry being placed in the map; it\nmust hold a valid one so the pointer-diff implementation of\nOFFSETOF_VAR() should work fine, or we are putting garbage in to the\nmap.\n\n#define hashmap_remove_entry(map, keyvar, member, keydata) \\\n\tcontainer_of_or_null_offset( \\\n\t\t\thashmap_remove(map, &(keyvar)->member, keydata), \\\n\t\t\tOFFSETOF_VAR(keyvar, member))\n\nThe keyvar is used to match against an existing entry in the map to\nbe removed---it must have a valid value.\n\n#define hashmap_for_each_entry(map, iter, var, member) \\\n\tfor (var = hashmap_iter_first_entry_offset(map, iter, \\\n\t\t\t\t\t\tOFFSETOF_VAR(var, member)); \\\n\t\tvar; \\\n\t\tvar = hashmap_iter_next_entry_offset(iter, \\\n\t\t\t\t\t\tOFFSETOF_VAR(var, member)))\n\nThis, as you discovered, can be fed an uninitialized var and the\nfirst thing it does is to use OFFSETOF_VAR() on it in order to call\nhashmap_iter_first_entry_offset().  After that, i.e. when we called\nthat function to start the loop, var is defined and we would be OK.\n\nThe trick I suggested is to initialize var to NULL before making the\ncall to hashmap_iter_first_entry_offset(), i.e.\n\n\tfor (var = NULL, \\\n\t     var = hashmap_iter_first_entry_offset(map, iter, \\\n\t\t\t\t\t\tOFFSETOF_VAR(var, member)); \\\n\n#define hashmap_get_entry(map, keyvar, member, keydata) \\\n\tcontainer_of_or_null_offset( \\\n\t\t\t\thashmap_get(map, &(keyvar)->member, keydata), \\\n\t\t\t\tOFFSETOF_VAR(keyvar, member))\n\nMust be OK for the same reason _put_entry() is OK.\n\n#define hashmap_get_next_entry(map, var, member) \\\n\tcontainer_of_or_null_offset(hashmap_get_next(map, &(var)->member), \\\n\t\t\t\tOFFSETOF_VAR(var, member))\n\nThis tries to go to the next-equal-pointer starting from var, so var\nmust be valid already.\n\nSo, perhaps the attached may be a viable replacement that would be\nmore futureproof with less maintenance cost, I suspect.\n\nThanks.\n\n--- >8 ----- cut here ----- >8 ---\nSubject: hashmap_for_each_entry(): workaround MSVC's runtime check failure #3\n\nThe OFFSETOF_VAR(var, member) macro is implemented in terms of\noffsetof(typeof(*var), member) with compilers that know typeof(),\nbut its fallback implemenation compares &(var->member) and (var) and\ncount the distance in bytes, i.e.\n\n    ((uintptr_t)&(var)->member - (uintptr_t)(var))\n\nMSVC's runtime check, when fed an uninitialized 'var', flags this as\na use of an uninitialized variable (and that is legit---uninitialized\ncontents of 'var' is subtracted) in a debug build.\n\nAfter auditing all 6 uses of OFFSETOF_VAR(), 1 of them does feed a\npotentially uninitialized 'var' to the macro in the beginning of the\nfor() loop:\n\n    #define hashmap_for_each_entry(map, iter, var, member) \\\n            for (var = hashmap_iter_first_entry_offset(map, iter, \\\n                                                    OFFSETOF_VAR(var, member)); \\\n                    var; \\\n                    var = hashmap_iter_next_entry_offset(iter, \\\n                                                    OFFSETOF_VAR(var, member)))\n\nWe can work around this by making sure that var has _some_ value\nwhen OFFSETOF_VAR() is called.  Strictly speaking, it invites\nundefined behaviour to use NULL here if we end up with pointer\ncomparison, but MSVC runtime seems to be happy with it, and most\nother systems have typeof() and don't even need pointer comparison\nfallback code.\n\n---\n hashmap.h | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git c/hashmap.h w/hashmap.h\nindex ef220de4c6..b011b394fe 100644\n--- c/hashmap.h\n+++ w/hashmap.h\n@@ -449,7 +449,8 @@ static inline struct hashmap_entry *hashmap_iter_first(struct hashmap *map,\n  * containing a @member which is a \"struct hashmap_entry\"\n  */\n #define hashmap_for_each_entry(map, iter, var, member) \\\n-\tfor (var = hashmap_iter_first_entry_offset(map, iter, \\\n+\tfor (var = NULL, /* for systems without typeof */ \\\n+\t     var = hashmap_iter_first_entry_offset(map, iter, \\\n \t\t\t\t\t\tOFFSETOF_VAR(var, member)); \\\n \t\tvar; \\\n \t\tvar = hashmap_iter_next_entry_offset(iter, \\\n"},{"id":"406436","messageId":"nycvar.QRO.7.76.6.2009260821260.50@tvgsbejvaqbjf.bet","threadId":"54295","inReplyTo":"CAKiG+9V=BGX4k_dM-5JzYmko0cZfYXuSxEk5-UuHZpAqaWoU_A@mail.gmail.com","subject":"Re: [PATCH 02/10] cmake: do find Git for Windows' shell interpreter","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-09-26T20:32:25Z","receivedAt":"2020-09-26T20:32:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Sibi,\n\nOn Fri, 25 Sep 2020, Sibi Siddharthan wrote:\n\n> > diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> > index 5007f173f1..d14fa4f3dc 100644\n> > --- a/contrib/buildsystems/CMakeLists.txt\n> > +++ b/contrib/buildsystems/CMakeLists.txt\n> > @@ -43,8 +43,11 @@ set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n> >\n> >  find_program(SH_EXE sh)\n> >  if(NOT SH_EXE)\n> > -       message(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n> > -                       \"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n> > +       set(SH_EXE \"C:/Program Files/Git/bin/sh.exe\")\n> > +       if(NOT EXISTS ${SH_EXE})\n> > +               message(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n> > +                               \"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n> > +       endif()\n> >  endif()\n> >\n> Let's not point SH_EXE to the 'program files' directory.\n\nIt is not doing that, except as a fall-back in case the `sh` program\nwas not found in the `PATH`.\n\n> find_program() searches 'PATH' for sh.\n\nRight.\n\n> Since the Git-for-windows installer does append\n> 'your_installation_directory'/Git/bin to the PATH variable, it should\n> be fine.\n\nNo, it does not. Quite purposefully so.\n\nThe `/bin/` directory is kind of a hack to reinstate _some_ level of\nsupport for use cases that relied on Git for Windows v1.x installing its\nbinaries into that directory (v2.x distributes them between `/usr/bin/`\nand `/mingw64/bin/`).\n\nWhat _does_ get appended, at least by default, is the `/cmd/` directory\n(which does _not_ contain `sh.exe`).\n\nNow, there _is_ an option in the Git for Windows installer to append all\nof its Unix tools to the `PATH`, but it is highly discouraged to do so.\n\n> I personally don't install my dev tools(except Visual Studio) to\n> Program Files(because of the _space_), it messes up the Makefiles.\n\nSure, and that's your prerogative. There's unfortunately no good way to\nsupport your use case.\n\nLuckily, the vast majority of Git for Windows' users do not change the\ndefault location, and this patch is for them. (And \"them\" in this case\nincludes me, personally ;-))\n\nCiao,\nDscho\n"},{"id":"406437","messageId":"nycvar.QRO.7.76.6.2009262232560.50@tvgsbejvaqbjf.bet","threadId":"54295","inReplyTo":"CAKiG+9XqJ92rjVczBG9ByVK_KRfJeToO0pFb3RhFpom2ChFE-g@mail.gmail.com","subject":"Re: [PATCH 07/10] cmake (Windows): complain when encountering an unknown compiler","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-09-26T20:33:46Z","receivedAt":"2020-09-26T20:33:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Sibi,\n\nOn Fri, 25 Sep 2020, Sibi Siddharthan wrote:\n\n> On Fri, Sep 25, 2020 at 7:58 PM Johannes Schindelin via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n> >\n> > From: Johannes Schindelin <johannes.schindelin@gmx.de>\n> >\n> > We have some custom handling regarding the link options, which are\n> > specific to each compiler.\n> >\n> > Therefore: let's not just continue without setting the link options when\n> > configuring for a currently unhandled compiler, but error out.\n> >\n> > Note: for some reason, the `invalidcontinue.obj` trick seems not to work\n> > in this developer's hands when building Git in Debug mode: the assertion\n> > dialog that is supposed to be suppressed still pops up, complaining\n> > about the `entry` variable being uninitialized when it is used in\n> > `config.c`'s line 1961.\n>\n> Does this happen when running Git under the Visual Studio debugger?\n\nWhoops. I meant to remove this paragraph after addressing that `run-time\ncheck failure #3` problem.\n\nWill remove it before sending the next iteration.\n\nThanks,\nDscho\n\n> If so this might help\n> _CrtSetReportMode(_CRT_ASSERT,0);\n>\n> After digging a bit more I found out that _CRTDBG_MODE_DEBUG is\n> environment sensitive.\n> It depends on how the debugger handles DbgPrintEx().\n>\n> Thank You,\n> Sibi Siddharthan\n>\n>\n"},{"id":"406438","messageId":"nycvar.QRO.7.76.6.2009262243410.50@tvgsbejvaqbjf.bet","threadId":"54295","inReplyTo":"xmqqd029lnr3.fsf@gitster.c.googlers.com","subject":"Re: [PATCH 09/10] cmake (Windows): recommend using Visual Studio's built-in CMake support","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-09-26T20:45:46Z","receivedAt":"2020-09-26T20:47:00Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Fri, 25 Sep 2020, Junio C Hamano wrote:\n\n> \"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\n> writes:\n>\n> > From: Johannes Schindelin <johannes.schindelin@gmx.de>\n> >\n> > It is a lot more convenient to use than having to specify the\n> > configuration in CMake manually (does not matter whether using the\n> > command-line or CMake's GUI).\n> >\n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > ---\n> >  contrib/buildsystems/CMakeLists.txt | 12 +++++++++++-\n> >  1 file changed, 11 insertions(+), 1 deletion(-)\n> >\n> > diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> > index 1eaeb8b8e0..442b4e69ad 100644\n> > --- a/contrib/buildsystems/CMakeLists.txt\n> > +++ b/contrib/buildsystems/CMakeLists.txt\n> > @@ -4,7 +4,17 @@\n> >\n> >  #[[\n> >\n> > -Instructions to run CMake:\n> > +Instructions how to use this in Visual Studio:\n> > +\n> > +Open the worktree as a folder. Visual Studio 2019 and later will detect\n> > +the CMake configuration automatically and set everything up for you,\n> > +ready to build. You can then run the tests in `t/` via a regular Git Bash.\n> > +\n> > +Note: Visual Studio also has the option of opening the CMake configuration\n> > +directly; Using this option, Visual Studio will not find the source code,\n> > +though, therefore the `File>Open>Folder...` option is preferred.\n> > +\n> > +Instructions to run CMake manually:\n> >\n> >  cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n> >  Eg.\n>\n> Having the primary case upfront is a good idea.  As we discussed,\n> our source tree structure (especially the .gitignore we ship) only\n> supports an separate-dir build in contrib/buildsystems/out, so we\n> should update the \"manually\" part of the instruction to guide users\n> to use the same location.  Perhaps something along the line of the\n> attached.\n\nI squashed your changes into the patch.\n\n> Also, after the post-context of the attached patch, there are\n> mentions of Visual Studio.  Please double check if they need\n> adjustment, or more preferrably the above paragraph the patch in\n> question added is all that is needed by Visual Studio users, in\n> which case perhaps it would be a good idea to remove all mention of\n> Visual Studio there to avoid sending confusing choices to the\n> readers.\n\nThe parts that still mention Visual Studio are in the part that talks\nabout running CMake manually, in which case they strike me as helpful,\nstill.\n\nThank you,\nDscho\n\n>\n> Thanks.\n>\n>  contrib/buildsystems/CMakeLists.txt | 16 +++++++---------\n>  1 file changed, 7 insertions(+), 9 deletions(-)\n>\n> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> index 442b4e69ad..0c748949f9 100644\n> --- a/contrib/buildsystems/CMakeLists.txt\n> +++ b/contrib/buildsystems/CMakeLists.txt\n> @@ -16,15 +16,13 @@ though, therefore the `File>Open>Folder...` option is preferred.\n>\n>  Instructions to run CMake manually:\n>\n> -cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n> -Eg.\n> -From the root of git source tree\n> -\t`cmake contrib/buildsystems/ `\n> -This will build the git binaries at the root\n> -\n> -For out of source builds, say build in 'git/git-build/'\n> -\t`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`\n> -This will build the git binaries in git-build directory\n> +    mkdir -p contrib/buildsystems/out\n> +    cd contrib/buildsystems/out\n> +    cmake ../ -DCMAKE_BUILD_TYPE=Release\n> +\n> +This will build the git binaries in contrib/buildsystems/out\n> +directory (our top-level .gitignore file knows to ignore contents of\n> +this directory).\n>\n>  Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n>  compiler flags\n>\n>\n"},{"id":"406439","messageId":"nycvar.QRO.7.76.6.2009262254310.50@tvgsbejvaqbjf.bet","threadId":"54295","inReplyTo":"xmqqy2kwiimi.fsf@gitster.c.googlers.com","subject":"Re: [PATCH 10/10] hashmap_for_each_entry(): work around MSVC's run-time check failure #3","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-09-26T20:57:09Z","receivedAt":"2020-09-26T20:57:20Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Sat, 26 Sep 2020, Junio C Hamano wrote:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n> > Whoa, wait.  If it is just that macro, can we perhaps do something\n> > like the attached patch?\n>\n> I looked at all the uses of OFFSETOF_VAR() and I think the one used\n> for hashmap_for_each_entry() is the only instance that 'var' given\n> to it can legitimately be uninitialized, if typeof() were available.\n\nThank you for doing all that leg work. TBH I didn't even think about\nlooking further, after having run a couple tests manually that I thought\nwere exhaustive in exercising this type of code pattern.\n\n> Here are the findings.\n>\n> #define hashmap_put_entry(map, keyvar, member) \\\n> \tcontainer_of_or_null_offset(hashmap_put(map, &(keyvar)->member), \\\n> \t\t\t\tOFFSETOF_VAR(keyvar, member))\n>\n> The keyvar is a pointer to the entry being placed in the map; it\n> must hold a valid one so the pointer-diff implementation of\n> OFFSETOF_VAR() should work fine, or we are putting garbage in to the\n> map.\n>\n> #define hashmap_remove_entry(map, keyvar, member, keydata) \\\n> \tcontainer_of_or_null_offset( \\\n> \t\t\thashmap_remove(map, &(keyvar)->member, keydata), \\\n> \t\t\tOFFSETOF_VAR(keyvar, member))\n>\n> The keyvar is used to match against an existing entry in the map to\n> be removed---it must have a valid value.\n>\n> #define hashmap_for_each_entry(map, iter, var, member) \\\n> \tfor (var = hashmap_iter_first_entry_offset(map, iter, \\\n> \t\t\t\t\t\tOFFSETOF_VAR(var, member)); \\\n> \t\tvar; \\\n> \t\tvar = hashmap_iter_next_entry_offset(iter, \\\n> \t\t\t\t\t\tOFFSETOF_VAR(var, member)))\n>\n> This, as you discovered, can be fed an uninitialized var and the\n> first thing it does is to use OFFSETOF_VAR() on it in order to call\n> hashmap_iter_first_entry_offset().  After that, i.e. when we called\n> that function to start the loop, var is defined and we would be OK.\n>\n> The trick I suggested is to initialize var to NULL before making the\n> call to hashmap_iter_first_entry_offset(), i.e.\n>\n> \tfor (var = NULL, \\\n> \t     var = hashmap_iter_first_entry_offset(map, iter, \\\n> \t\t\t\t\t\tOFFSETOF_VAR(var, member)); \\\n>\n> #define hashmap_get_entry(map, keyvar, member, keydata) \\\n> \tcontainer_of_or_null_offset( \\\n> \t\t\t\thashmap_get(map, &(keyvar)->member, keydata), \\\n> \t\t\t\tOFFSETOF_VAR(keyvar, member))\n>\n> Must be OK for the same reason _put_entry() is OK.\n>\n> #define hashmap_get_next_entry(map, var, member) \\\n> \tcontainer_of_or_null_offset(hashmap_get_next(map, &(var)->member), \\\n> \t\t\t\tOFFSETOF_VAR(var, member))\n>\n> This tries to go to the next-equal-pointer starting from var, so var\n> must be valid already.\n>\n> So, perhaps the attached may be a viable replacement that would be\n> more futureproof with less maintenance cost, I suspect.\n\nDefinitely much nicer to maintain, and easier to verify. In my hands, this\nworks better than my manual touch-ups of _all_ the call sites. So I\nreplaced my patch with yours (adding your SOB).\n\nCiao,\nDscho\n\n> Thanks.\n>\n> --- >8 ----- cut here ----- >8 ---\n> Subject: hashmap_for_each_entry(): workaround MSVC's runtime check failure #3\n>\n> The OFFSETOF_VAR(var, member) macro is implemented in terms of\n> offsetof(typeof(*var), member) with compilers that know typeof(),\n> but its fallback implemenation compares &(var->member) and (var) and\n> count the distance in bytes, i.e.\n>\n>     ((uintptr_t)&(var)->member - (uintptr_t)(var))\n>\n> MSVC's runtime check, when fed an uninitialized 'var', flags this as\n> a use of an uninitialized variable (and that is legit---uninitialized\n> contents of 'var' is subtracted) in a debug build.\n>\n> After auditing all 6 uses of OFFSETOF_VAR(), 1 of them does feed a\n> potentially uninitialized 'var' to the macro in the beginning of the\n> for() loop:\n>\n>     #define hashmap_for_each_entry(map, iter, var, member) \\\n>             for (var = hashmap_iter_first_entry_offset(map, iter, \\\n>                                                     OFFSETOF_VAR(var, member)); \\\n>                     var; \\\n>                     var = hashmap_iter_next_entry_offset(iter, \\\n>                                                     OFFSETOF_VAR(var, member)))\n>\n> We can work around this by making sure that var has _some_ value\n> when OFFSETOF_VAR() is called.  Strictly speaking, it invites\n> undefined behaviour to use NULL here if we end up with pointer\n> comparison, but MSVC runtime seems to be happy with it, and most\n> other systems have typeof() and don't even need pointer comparison\n> fallback code.\n>\n> ---\n>  hashmap.h | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n>\n> diff --git c/hashmap.h w/hashmap.h\n> index ef220de4c6..b011b394fe 100644\n> --- c/hashmap.h\n> +++ w/hashmap.h\n> @@ -449,7 +449,8 @@ static inline struct hashmap_entry *hashmap_iter_first(struct hashmap *map,\n>   * containing a @member which is a \"struct hashmap_entry\"\n>   */\n>  #define hashmap_for_each_entry(map, iter, var, member) \\\n> -\tfor (var = hashmap_iter_first_entry_offset(map, iter, \\\n> +\tfor (var = NULL, /* for systems without typeof */ \\\n> +\t     var = hashmap_iter_first_entry_offset(map, iter, \\\n>  \t\t\t\t\t\tOFFSETOF_VAR(var, member)); \\\n>  \t\tvar; \\\n>  \t\tvar = hashmap_iter_next_entry_offset(iter, \\\n>\n>\n"},{"id":"406440","messageId":"nycvar.QRO.7.76.6.2009262300060.50@tvgsbejvaqbjf.bet","threadId":"54295","inReplyTo":"CAPig+cTPi1yi7WQf_eWa+bFRJEdtULFO3yYqJh3nm=_CtEe6CQ@mail.gmail.com","subject":"Re: [PATCH 06/10] cmake (Windows): let the `.dll` files are found when running the tests","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-09-26T21:00:37Z","receivedAt":"2020-09-26T21:00:43Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Eric,\n\nOn Fri, 25 Sep 2020, Eric Sunshine wrote:\n\n> On Fri, Sep 25, 2020 at 10:28 AM Johannes Schindelin via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n> > cmake (Windows): let the `.dll` files are found when running the tests\n>\n> I'm having trouble parsing this. Maybe you want s/let/ensure/ ?\n\nRight, that does not parse at all. I did `s/are/be/` instead.\n\nThanks,\nDscho\n"},{"id":"406448","messageId":"pull.738.v2.git.1601155970.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.git.1601044118.gitgitgadget@gmail.com","subject":"[PATCH v2 00/10] CMake and Visual Studio","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-26T21:32:39Z","receivedAt":"2020-09-26T21:32:54Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"The intention of this patch series is to make it as easy as possible for a\nVisual Studio user to start building Git from scratch. The idea is to\n\n * clone Git's source code,\n * open it in Visual Studio via File>Open>Folder...\n * let CMake configure things (and vcpkg build the dependencies, which will\n   take a while), and\n * start the build.\n\nIt does require a Git for Windows to be installed (so that the source can be\ncloned, but also to run the shell script parts of the CMake configuration),\nand also to run the tests.\n\nThis patch series replaces the patch \"Ignore files generated by CMake\" I\nsent via https://github.com/gitgitgadget/git/pull/735.\n\nChanges since v1:\n\n * Touched up a couple commit messages in response to reviewer comments\n * Adjusted the instructions at the top of CMakeLists.txt so that the part\n   talking about running CMake manually also talks about using \n   contrib/buildsystems/out/ as build directory (in line with the part\n   talking about Visual Studio's out-of-the-box experience)\n * Replaced patch 10/10 with Junio's much more elegant solution of editing\n   the hashmap_for_each_entry() macro instead of all of its callers.\n\nJohannes Schindelin (9):\n  cmake: ignore files generated by CMake as run in Visual Studio\n  cmake: do find Git for Windows' shell interpreter\n  cmake: ensure that the `vcpkg` packages are found on Windows\n  cmake: fall back to using `vcpkg`'s `msgfmt.exe` on Windows\n  cmake: quote the path accurately when editing `test-lib.sh`\n  cmake (Windows): let the `.dll` files be found when running the tests\n  cmake (Windows): complain when encountering an unknown compiler\n  cmake (Windows): initialize vcpkg/build dependencies automatically\n  cmake (Windows): recommend using Visual Studio's built-in CMake\n    support\n\nJunio C Hamano (1):\n  hashmap_for_each_entry(): workaround MSVC's runtime check failure #3\n\n .gitignore                          |  1 +\n contrib/buildsystems/CMakeLists.txt | 57 ++++++++++++++++++++++-------\n hashmap.h                           |  3 +-\n 3 files changed, 47 insertions(+), 14 deletions(-)\n\n\nbase-commit: e1cfff676549cdcd702cbac105468723ef2722f4\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-738%2Fdscho%2Fcmake-and-visual-studio-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-738/dscho/cmake-and-visual-studio-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/738\n\nRange-diff vs v1:\n\n  1:  ba314373e9 =  1:  ba314373e9 cmake: ignore files generated by CMake as run in Visual Studio\n  2:  05b4b69fee =  2:  05b4b69fee cmake: do find Git for Windows' shell interpreter\n  3:  5967822a0c =  3:  5967822a0c cmake: ensure that the `vcpkg` packages are found on Windows\n  4:  efc93f1dd9 =  4:  efc93f1dd9 cmake: fall back to using `vcpkg`'s `msgfmt.exe` on Windows\n  5:  8b3500a07c =  5:  8b3500a07c cmake: quote the path accurately when editing `test-lib.sh`\n  6:  bb8f122cde !  6:  88abbd9a78 cmake (Windows): let the `.dll` files are found when running the tests\n     @@ Metadata\n      Author: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n      \n       ## Commit message ##\n     -    cmake (Windows): let the `.dll` files are found when running the tests\n     +    cmake (Windows): let the `.dll` files be found when running the tests\n      \n          Contrary to Unix-ish platforms, the dependencies' shared libraries are\n          not usually found in one central place. In our case, since we use\n  7:  dddfa3a9b4 !  7:  26ebeecb14 cmake (Windows): complain when encountering an unknown compiler\n     @@ Commit message\n          We have some custom handling regarding the link options, which are\n          specific to each compiler.\n      \n     -    Therefore: let's not just continue without setting the link options when\n     +    Therefore: let's not just continue without setting the link options if\n          configuring for a currently unhandled compiler, but error out.\n      \n     -    Note: for some reason, the `invalidcontinue.obj` trick seems not to work\n     -    in this developer's hands when building Git in Debug mode: the assertion\n     -    dialog that is supposed to be suppressed still pops up, complaining\n     -    about the `entry` variable being uninitialized when it is used in\n     -    `config.c`'s line 1961.\n     -\n          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n      \n       ## contrib/buildsystems/CMakeLists.txt ##\n  8:  3a07bd4916 =  8:  3587ee5e8d cmake (Windows): initialize vcpkg/build dependencies automatically\n  9:  f07e421666 !  9:  68a7d984ec cmake (Windows): recommend using Visual Studio's built-in CMake support\n     @@ Commit message\n          configuration in CMake manually (does not matter whether using the\n          command-line or CMake's GUI).\n      \n     +    While at it, recommend using `contrib/buildsystems/out/` as build\n     +    directory also in the part that talks about running CMake manually.\n     +\n     +    Helped-by: Junio C Hamano <gitster@pobox.com>\n          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n      \n       ## contrib/buildsystems/CMakeLists.txt ##\n     @@ contrib/buildsystems/CMakeLists.txt\n       \n      -Instructions to run CMake:\n      +Instructions how to use this in Visual Studio:\n     -+\n     + \n     +-cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n     +-Eg.\n     +-From the root of git source tree\n     +-\t`cmake contrib/buildsystems/ `\n     +-This will build the git binaries at the root\n      +Open the worktree as a folder. Visual Studio 2019 and later will detect\n      +the CMake configuration automatically and set everything up for you,\n      +ready to build. You can then run the tests in `t/` via a regular Git Bash.\n     -+\n     -+Note: Visual Studio also has the option of opening the CMake configuration\n     + \n     +-For out of source builds, say build in 'git/git-build/'\n     +-\t`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`\n     +-This will build the git binaries in git-build directory\n     ++Note: Visual Studio also has the option of opening `CMakeLists.txt`\n      +directly; Using this option, Visual Studio will not find the source code,\n      +though, therefore the `File>Open>Folder...` option is preferred.\n      +\n      +Instructions to run CMake manually:\n     ++\n     ++    mkdir -p contrib/buildsystems/out\n     ++    cd contrib/buildsystems/out\n     ++    cmake ../ -DCMAKE_BUILD_TYPE=Release\n     ++\n     ++This will build the git binaries in contrib/buildsystems/out\n     ++directory (our top-level .gitignore file knows to ignore contents of\n     ++this directory).\n       \n     - cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n     - Eg.\n     + Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n     + compiler flags\n 10:  dc46d39611 <  -:  ---------- hashmap_for_each_entry(): work around MSVC's run-time check failure #3\n  -:  ---------- > 10:  152705bbc6 hashmap_for_each_entry(): workaround MSVC's runtime check failure #3\n\n-- \ngitgitgadget\n"},{"id":"406449","messageId":"ba314373e9cb867c1c36eea6fed655be27133872.1601155970.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v2.git.1601155970.gitgitgadget@gmail.com","subject":"[PATCH v2 01/10] cmake: ignore files generated by CMake as run in Visual Studio","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-26T21:32:40Z","receivedAt":"2020-09-26T21:32:55Z","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\nAs of recent Visual Studio versions, CMake support is built-in:\nhttps://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=vs-2019\n\nAll that needs to be done is to open the worktree as a folder, and\nVisual Studio will find the `CMakeLists.txt` file and automatically\ngenerate the project files.\n\nLet's ignore the entirety of those generated files.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .gitignore | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/.gitignore b/.gitignore\nindex d0f692a355..6521f3cf22 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -241,3 +241,4 @@ Release/\n /git.VC.VC.opendb\n /git.VC.db\n *.dSYM\n+/contrib/buildsystems/out\n-- \ngitgitgadget\n\n"},{"id":"406450","messageId":"8b3500a07c67d07e0928e8d6638d618ab118e1eb.1601155970.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v2.git.1601155970.gitgitgadget@gmail.com","subject":"[PATCH v2 05/10] cmake: quote the path accurately when editing `test-lib.sh`","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-26T21:32:44Z","receivedAt":"2020-09-26T21:33: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\nBy default, the build directory will be called something like\n`contrib/buildsystems/out/build/x64-Debug (default)` (note the space and\nthe parentheses). We need to make sure that such a path is quoted\nproperly when editing the assignment of the `GIT_BUILD_DIR` variable.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex acb197fba5..e66ae137c2 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -952,7 +952,7 @@ if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})\n \tfile(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake\n \t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \\\"GIT_BUILD_DIR=(.*)\\\")\\n\"\n \t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\\n\"\n-\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY\\\\\\\"/../${BUILD_DIR_RELATIVE}\\\" content \\\"\\${content}\\\")\\n\"\n+\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY/../${BUILD_DIR_RELATIVE}\\\\\\\"\\\" content \\\"\\${content}\\\")\\n\"\n \t\t\"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \\${content})\")\n \t#misc copies\n \tfile(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)\n-- \ngitgitgadget\n\n"},{"id":"406451","messageId":"5967822a0c69b9f822d3a4f6412c626c4a43cc35.1601155970.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v2.git.1601155970.gitgitgadget@gmail.com","subject":"[PATCH v2 03/10] cmake: ensure that the `vcpkg` packages are found on Windows","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-26T21:32:42Z","receivedAt":"2020-09-26T21:33: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\nOn Windows, we use the `vcpkg` project to manage the dependencies, via\n`compat/vcbuild/`. Let's make sure that these dependencies are found by\ndefault.\n\nThis is needed because we are about to recommend loading the Git\nworktree as a folder into Visual Studio, relying on the automatic CMake\nsupport (which would make it relatively cumbersome to adjust the search\npath used by CMake manually).\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex d14fa4f3dc..16014ac4f7 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -40,6 +40,13 @@ cmake_minimum_required(VERSION 3.14)\n \n #set the source directory to root of git\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n+if(WIN32)\n+\tset(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n+\tlist(APPEND CMAKE_PREFIX_PATH \"${VCPKG_DIR}/installed/x64-windows\")\n+\n+\t# In the vcpkg edition, we need this to be able to link to libcurl\n+\tset(CURL_NO_CURL_CMAKE ON)\n+endif()\n \n find_program(SH_EXE sh)\n if(NOT SH_EXE)\n-- \ngitgitgadget\n\n"},{"id":"406452","messageId":"efc93f1dd972614d197b919e17693a910e568736.1601155970.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v2.git.1601155970.gitgitgadget@gmail.com","subject":"[PATCH v2 04/10] cmake: fall back to using `vcpkg`'s `msgfmt.exe` on Windows","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-26T21:32:43Z","receivedAt":"2020-09-26T21:33: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\nWe are already relying on `vcpkg` to manage our dependencies, including\n`libiconv`. Let's also use the `msgfmt.exe` from there.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 16014ac4f7..acb197fba5 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -155,7 +155,11 @@ endif()\n \n find_program(MSGFMT_EXE msgfmt)\n if(NOT MSGFMT_EXE)\n-\tmessage(WARNING \"Text Translations won't be build\")\n+\tset(MSGFMT_EXE ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg/downloads/tools/msys2/msys64/usr/bin/msgfmt.exe)\n+\tif(NOT EXISTS ${MSGFMT_EXE})\n+\t\tmessage(WARNING \"Text Translations won't be build\")\n+\t\tunset(MSGFMT_EXE)\n+\tendif()\n endif()\n \n #Force all visual studio outputs to CMAKE_BINARY_DIR\n-- \ngitgitgadget\n\n"},{"id":"406453","messageId":"05b4b69fee2b8c32769dd72dea182cfb72a14876.1601155970.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v2.git.1601155970.gitgitgadget@gmail.com","subject":"[PATCH v2 02/10] cmake: do find Git for Windows' shell interpreter","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-26T21:32:41Z","receivedAt":"2020-09-26T21:33:04Z","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\nBy default, Git for Windows does not install its `sh.exe` into the\n`PATH`. However, our current `CMakeLists.txt` expects to find a shell\ninterpreter in the `PATH`.\n\nSo let's fall back to looking in the default location where Git for\nWindows _does_ install a relatively convenient `sh.exe`:\n`C:\\Program Files\\Git\\bin\\sh.exe`\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 5007f173f1..d14fa4f3dc 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -43,8 +43,11 @@ set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n \n find_program(SH_EXE sh)\n if(NOT SH_EXE)\n-\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n-\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n+\tset(SH_EXE \"C:/Program Files/Git/bin/sh.exe\")\n+\tif(NOT EXISTS ${SH_EXE})\n+\t\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n+\t\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n+\tendif()\n endif()\n \n #Create GIT-VERSION-FILE using GIT-VERSION-GEN\n-- \ngitgitgadget\n\n"},{"id":"406454","messageId":"152705bbc6a105411d0be0f76b18757c8ab0f893.1601155970.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v2.git.1601155970.gitgitgadget@gmail.com","subject":"[PATCH v2 10/10] hashmap_for_each_entry(): workaround MSVC's runtime check failure #3","fromName":"Junio C Hamano via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-26T21:32:49Z","receivedAt":"2020-09-26T21:33:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n\nThe OFFSETOF_VAR(var, member) macro is implemented in terms of\noffsetof(typeof(*var), member) with compilers that know typeof(),\nbut its fallback implemenation compares &(var->member) and (var) and\ncount the distance in bytes, i.e.\n\n    ((uintptr_t)&(var)->member - (uintptr_t)(var))\n\nMSVC's runtime check, when fed an uninitialized 'var', flags this as\na use of an uninitialized variable (and that is legit---uninitialized\ncontents of 'var' is subtracted) in a debug build.\n\nAfter auditing all 6 uses of OFFSETOF_VAR(), 1 of them does feed a\npotentially uninitialized 'var' to the macro in the beginning of the\nfor() loop:\n\n    #define hashmap_for_each_entry(map, iter, var, member) \\\n            for (var = hashmap_iter_first_entry_offset(map, iter, \\\n                                                    OFFSETOF_VAR(var, member)); \\\n                    var; \\\n                    var = hashmap_iter_next_entry_offset(iter, \\\n                                                    OFFSETOF_VAR(var, member)))\n\nWe can work around this by making sure that var has _some_ value\nwhen OFFSETOF_VAR() is called.  Strictly speaking, it invites\nundefined behaviour to use NULL here if we end up with pointer\ncomparison, but MSVC runtime seems to be happy with it, and most\nother systems have typeof() and don't even need pointer comparison\nfallback code.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n hashmap.h | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/hashmap.h b/hashmap.h\nindex ef220de4c6..b011b394fe 100644\n--- a/hashmap.h\n+++ b/hashmap.h\n@@ -449,7 +449,8 @@ static inline struct hashmap_entry *hashmap_iter_first(struct hashmap *map,\n  * containing a @member which is a \"struct hashmap_entry\"\n  */\n #define hashmap_for_each_entry(map, iter, var, member) \\\n-\tfor (var = hashmap_iter_first_entry_offset(map, iter, \\\n+\tfor (var = NULL, /* for systems without typeof */ \\\n+\t     var = hashmap_iter_first_entry_offset(map, iter, \\\n \t\t\t\t\t\tOFFSETOF_VAR(var, member)); \\\n \t\tvar; \\\n \t\tvar = hashmap_iter_next_entry_offset(iter, \\\n-- \ngitgitgadget\n"},{"id":"406455","messageId":"68a7d984ec225f08486a4faf2b8d5bd2df2d5083.1601155970.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v2.git.1601155970.gitgitgadget@gmail.com","subject":"[PATCH v2 09/10] cmake (Windows): recommend using Visual Studio's built-in CMake support","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-26T21:32:48Z","receivedAt":"2020-09-26T21:33: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\nIt is a lot more convenient to use than having to specify the\nconfiguration in CMake manually (does not matter whether using the\ncommand-line or CMake's GUI).\n\nWhile at it, recommend using `contrib/buildsystems/out/` as build\ndirectory also in the part that talks about running CMake manually.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 26 +++++++++++++++++---------\n 1 file changed, 17 insertions(+), 9 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 1eaeb8b8e0..de92e4fe2d 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -4,17 +4,25 @@\n \n #[[\n \n-Instructions to run CMake:\n+Instructions how to use this in Visual Studio:\n \n-cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n-Eg.\n-From the root of git source tree\n-\t`cmake contrib/buildsystems/ `\n-This will build the git binaries at the root\n+Open the worktree as a folder. Visual Studio 2019 and later will detect\n+the CMake configuration automatically and set everything up for you,\n+ready to build. You can then run the tests in `t/` via a regular Git Bash.\n \n-For out of source builds, say build in 'git/git-build/'\n-\t`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`\n-This will build the git binaries in git-build directory\n+Note: Visual Studio also has the option of opening `CMakeLists.txt`\n+directly; Using this option, Visual Studio will not find the source code,\n+though, therefore the `File>Open>Folder...` option is preferred.\n+\n+Instructions to run CMake manually:\n+\n+    mkdir -p contrib/buildsystems/out\n+    cd contrib/buildsystems/out\n+    cmake ../ -DCMAKE_BUILD_TYPE=Release\n+\n+This will build the git binaries in contrib/buildsystems/out\n+directory (our top-level .gitignore file knows to ignore contents of\n+this directory).\n \n Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n compiler flags\n-- \ngitgitgadget\n\n"},{"id":"406456","messageId":"3587ee5e8d119b19fb3a4ff626c092acd5bd35ef.1601155970.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v2.git.1601155970.gitgitgadget@gmail.com","subject":"[PATCH v2 08/10] cmake (Windows): initialize vcpkg/build dependencies automatically","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-26T21:32:47Z","receivedAt":"2020-09-26T21:33: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 idea of having CMake support in Git's source tree is to enable\ncontributors on Windows to start contributing with little effort. To\nthat end, we just added some sensible defaults that will let users open\nthe worktree in Visual Studio and start building.\n\nThis expects the dependencies (such as zlib) to be available already,\nthough. If they are not available, we expect the user to run\n`compat/vcbuild/vcpkg_install.bat`.\n\nRather than requiring this step to be manual, detect the situation and\nrun it as part of the CMake configuration step.\n\nThis concludes our journey to make it as effortless as possible to start\ndeveloping Git in Visual Studio: all the developer needs to do is to\nclone Git's repository, open the worktree via `File>Open>Folder...` and\nwait for CMake to finish configuring.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex d21849b730..1eaeb8b8e0 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n if(WIN32)\n \tset(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n+\tif(NOT EXISTS ${VCPKG_DIR})\n+\t\tmessage(\"Initializinge vcpkg and building the Git's dependencies (this will take a while...)\")\n+\t\texecute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat)\n+\tendif()\n \tlist(APPEND CMAKE_PREFIX_PATH \"${VCPKG_DIR}/installed/x64-windows\")\n \n \t# In the vcpkg edition, we need this to be able to link to libcurl\n-- \ngitgitgadget\n\n"},{"id":"406457","messageId":"88abbd9a788091f869ae297f33e0fa5a6ea535a8.1601155970.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v2.git.1601155970.gitgitgadget@gmail.com","subject":"[PATCH v2 06/10] cmake (Windows): let the `.dll` files be found when running the tests","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-26T21:32:45Z","receivedAt":"2020-09-26T21:33:09Z","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\nContrary to Unix-ish platforms, the dependencies' shared libraries are\nnot usually found in one central place. In our case, since we use\n`vcpkg`, they are to be found inside the `compat/vcbuild/vcpkg/` tree.\n\nLet's make sure that they are in the search path when running the tests.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex e66ae137c2..5a4e0ccb01 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -942,6 +942,9 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X='${EXE_EXTENSION}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n+if(WIN32)\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PATH=\\\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\\\"\\n\")\n+endif()\n \n #Make the tests work when building out of the source tree\n get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)\n-- \ngitgitgadget\n\n"},{"id":"406458","messageId":"26ebeecb140e26938ecea04e2df2b8c000888162.1601155970.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v2.git.1601155970.gitgitgadget@gmail.com","subject":"[PATCH v2 07/10] cmake (Windows): complain when encountering an unknown compiler","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-26T21:32:46Z","receivedAt":"2020-09-26T21:33:12Z","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\nWe have some custom handling regarding the link options, which are\nspecific to each compiler.\n\nTherefore: let's not just continue without setting the link options if\nconfiguring for a currently unhandled compiler, but error out.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 5a4e0ccb01..d21849b730 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -620,6 +620,8 @@ if(WIN32)\n \t\ttarget_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)\n \telseif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n \t\ttarget_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)\n+\telse()\n+\t\tmessage(FATAL_ERROR \"Unhandled compiler: ${CMAKE_C_COMPILER_ID}\")\n \tendif()\n elseif(UNIX)\n \ttarget_link_libraries(common-main pthread rt)\n-- \ngitgitgadget\n\n"},{"id":"406465","messageId":"20200927022543.GD20935@danh.dev","threadId":"54295","inReplyTo":"nycvar.QRO.7.76.6.2009260821260.50@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 02/10] cmake: do find Git for Windows' shell interpreter","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-09-27T02:25:43Z","receivedAt":"2020-09-27T02:26:19Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-09-26 22:32:25+0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > Since the Git-for-windows installer does append\n> > 'your_installation_directory'/Git/bin to the PATH variable, it should\n> > be fine.\n> \n> No, it does not. Quite purposefully so.\n> \n> The `/bin/` directory is kind of a hack to reinstate _some_ level of\n> support for use cases that relied on Git for Windows v1.x installing its\n> binaries into that directory (v2.x distributes them between `/usr/bin/`\n> and `/mingw64/bin/`).\n> \n> What _does_ get appended, at least by default, is the `/cmd/` directory\n> (which does _not_ contain `sh.exe`).\n> \n> Now, there _is_ an option in the Git for Windows installer to append all\n> of its Unix tools to the `PATH`, but it is highly discouraged to do so.\n\nI agree with this decision.\n\n> \n> > I personally don't install my dev tools(except Visual Studio) to\n> > Program Files(because of the _space_), it messes up the Makefiles.\n> \n> Sure, and that's your prerogative. There's unfortunately no good way to\n> support your use case.\n> \n> Luckily, the vast majority of Git for Windows' users do not change the\n> default location, and this patch is for them. (And \"them\" in this case\n> includes me, personally ;-))\n\nThis doesn't fit into my view of Git for Windows' users\nFor some users that have the Administrator right, it's the default\nlocation if they grant the Administrator right for the installer.\n\nFor those poor souls that works for enterprise companies, and thoses\nthat not feel comfortable give Administrator right to _another_\ninstaller, the installer will install into (hopeful, I type it right):\n\n\t%USERPROFILE%/AppData/Local/Programs/Git\n\nI think it's better to offer SH_EXE as an OPTION, let user specify it\nas will. And we'll search in PATH if it's not specified, fallback to\n2 default value if not found.\n\n-- \nDanh\n"},{"id":"406528","messageId":"20200928111748.4122-1-oystwa@gmail.com","threadId":"54295","inReplyTo":"05b4b69fee2b8c32769dd72dea182cfb72a14876.1601155970.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 02/10] cmake: do find Git for Windows' shell interpreter","fromName":"Øystein Walle","fromEmail":"oystwa@gmail.com","sentAt":"2020-09-28T11:17:48Z","receivedAt":"2020-09-28T11:18:00Z","isPatch":true,"sender":{"key":"oystwa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/794585?v=4"},"body":">  find_program(SH_EXE sh)\n>  if(NOT SH_EXE)\n> -\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n> -\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n> +\tset(SH_EXE \"C:/Program Files/Git/bin/sh.exe\")\n> +\tif(NOT EXISTS ${SH_EXE})\n> +\t\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n> +\t\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n> +\tendif()\n>  endif()\n\nYou can write the find_program() command more succinctly as:\n\n\tfind_program(SH_EXE sh PATHS \"C:/Program Files/Git/bin\")\n\nPATHS is is a list of extra directories to search, which are usually hard-coded\nguesses[1]. This way we avoid an extra check and indentation level.\n\nI found my Visual Studio installation already contains a sh.exe.  I think it\nships with VS by default; I can't even find a way to remove it. It's located\nat:\n\nC:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\Git\\usr\\bin\\sh.exe\n\nWhen I started writing this up I figured that could serve as an additional\nfallback. However, if I use that shell I have to add (...)/usr/bin to PATH as\nthe various scripts need expr and sed among other things. I get the same result\nif I search \"C:/Program Files/Git/usr/bin\", but there is no equivalent\n(...)/bin in the Git included with VS for some reason.\n\nFor the curious I have attached the patch that ended up working, but I doubt\nit's worth including (except the simplified if(NOT...) logic).\n\nØsse.\n\n[1]: https://cmake.org/cmake/help/latest/command/find_program.html\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 5007f173f1..baa46e4e97 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -41,10 +41,17 @@ cmake_minimum_required(VERSION 3.14)\n #set the source directory to root of git\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n \n-find_program(SH_EXE sh)\n+find_program(SH_EXE sh\n+    PATHS  \"C:/Program Files/Git/bin\"\n+           \"$ENV{VSINSTALLDIR}/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/Git/usr/bin\"\n+ )\n if(NOT SH_EXE)\n \tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n \t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n+else()\n+    # Make sure various utilities are available in PATH\n+    get_filename_component(dir \"${SH_EXE}\" DIRECTORY)\n+    set(ENV{PATH} \"$ENV{PATH};${dir}\")\n endif()\n \n #Create GIT-VERSION-FILE using GIT-VERSION-GEN\n\n"},{"id":"406535","messageId":"nycvar.QRO.7.76.6.2009281553520.50@tvgsbejvaqbjf.bet","threadId":"54295","inReplyTo":"20200927022543.GD20935@danh.dev","subject":"Re: [PATCH 02/10] cmake: do find Git for Windows' shell interpreter","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-09-28T13:56:13Z","receivedAt":"2020-09-28T13:56:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Danh,\n\nOn Sun, 27 Sep 2020, Đoàn Trần Công Danh wrote:\n\n> On 2020-09-26 22:32:25+0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>\n> > > I personally don't install my dev tools(except Visual Studio) to\n> > > Program Files(because of the _space_), it messes up the Makefiles.\n> >\n> > Sure, and that's your prerogative. There's unfortunately no good way to\n> > support your use case.\n> >\n> > Luckily, the vast majority of Git for Windows' users do not change the\n> > default location, and this patch is for them. (And \"them\" in this case\n> > includes me, personally ;-))\n>\n> This doesn't fit into my view of Git for Windows' users\n> For some users that have the Administrator right, it's the default\n> location if they grant the Administrator right for the installer.\n>\n> For those poor souls that works for enterprise companies, and thoses\n> that not feel comfortable give Administrator right to _another_\n> installer, the installer will install into (hopeful, I type it right):\n>\n> \t%USERPROFILE%/AppData/Local/Programs/Git\n\nThose poor souls that work for enterprise companies often have Git for\nWindows installed by default. And of course, that default would be in\n`C:\\Program Files\\Git`.\n\n> I think it's better to offer SH_EXE as an OPTION, let user specify it\n> as will. And we'll search in PATH if it's not specified, fallback to\n> 2 default value if not found.\n\nThat's exactly as it is right now. You can specify `SH_EXE` (but only if\nrunning CMake manually, not via Visual Studio). If you don't, it searches\n`PATH`, and with my patch it then falls back to trying to find `sh.exe` in\nGit for Windows' default location.\n\nSo I think we're in agreement here?\n\nCiao,\nDscho\n"},{"id":"406560","messageId":"nycvar.QRO.7.76.6.2009281557390.50@tvgsbejvaqbjf.bet","threadId":"54295","inReplyTo":"20200928111748.4122-1-oystwa@gmail.com","subject":"Re: [PATCH v2 02/10] cmake: do find Git for Windows' shell interpreter","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-09-28T19:39:30Z","receivedAt":"2020-09-28T19:39:36Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Øystein,\n\nOn Mon, 28 Sep 2020, Øystein Walle wrote:\n\n> >  find_program(SH_EXE sh)\n> >  if(NOT SH_EXE)\n> > -\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n> > -\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n> > +\tset(SH_EXE \"C:/Program Files/Git/bin/sh.exe\")\n> > +\tif(NOT EXISTS ${SH_EXE})\n> > +\t\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n> > +\t\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n> > +\tendif()\n> >  endif()\n>\n> You can write the find_program() command more succinctly as:\n>\n> \tfind_program(SH_EXE sh PATHS \"C:/Program Files/Git/bin\")\n>\n> PATHS is is a list of extra directories to search, which are usually hard-coded\n> guesses[1]. This way we avoid an extra check and indentation level.\n\nThank you, I was not aware of this neat feature.\n\n> I found my Visual Studio installation already contains a sh.exe.  I think it\n> ships with VS by default; I can't even find a way to remove it. It's located\n> at:\n>\n> C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\Git\\usr\\bin\\sh.exe\n>\n> When I started writing this up I figured that could serve as an additional\n> fallback. However, if I use that shell I have to add (...)/usr/bin to PATH as\n> the various scripts need expr and sed among other things. I get the same result\n> if I search \"C:/Program Files/Git/usr/bin\", but there is no equivalent\n> (...)/bin in the Git included with VS for some reason.\n\nIndeed. This is what I get in that case:\n\n-- snip --\n1> [CMake] Generating  GIT-VERSION-FILE\n1> [CMake] C:/git-sdk-64/usr/src/vs2017-test/contrib/buildsystems/../../GIT-VERSION-GEN: line 24: sed: command not found\n1> [CMake] C:/git-sdk-64/usr/src/vs2017-test/contrib/buildsystems/../../GIT-VERSION-GEN: line 29: expr: command not found\n1> [CMake] GIT_VERSION =\n1> [CMake] CMake Error at C:\\git-sdk-64\\usr\\src\\vs2017-test\\contrib\\buildsystems\\CMakeLists.txt:79 (string):\n1> [CMake]   string sub-command FIND requires 3 or 4 parameters.\n1> [CMake]\n1> [CMake]\n1> [CMake] CMake Error at C:\\git-sdk-64\\usr\\src\\vs2017-test\\contrib\\buildsystems\\CMakeLists.txt:83 (string):\n1> [CMake]   string sub-command REGEX, mode MATCH needs at least 5 arguments total to\n1> [CMake]   command.\n1> [CMake]\n1> [CMake]\n1> [CMake] CMake Error at C:\\git-sdk-64\\usr\\src\\vs2017-test\\contrib\\buildsystems\\CMakeLists.txt:87 (project):\n1> [CMake]   VERSION \".0\" format invalid.\n-- snap --\n\nThe explanation is pretty simple: you cannot just call into `sh.exe` via\nan absolute path and expect it to add its containing directory to the\n`PATH`. It does not, and the symptom is that neither `sed` nor `expr` are\nfound.\n\nOne solution is to add it to the `PATH` manually, which is the original\nexpectation in our `CMakeLists.txt` version.\n\nAnother solution is to point it to `C:\\Program Files\\Git\\bin\\sh.exe` which\nis not, in fact, a shell, but a small wrapper executable whose job it is\nto set up a couple environment variables (`PATH` being one of them) and\nthen spawning the _actual_ `sh.exe`. The source code for that wrapper:\nhttps://github.com/git-for-windows/MINGW-packages/blob/main/mingw-w64-git/git-wrapper.c\n\nAs you figured out, it is _not_ enough to use `...\\usr\\bin\\sh.exe`\ndirectly without adjusting the `PATH`.\n\nCiao,\nDscho\n"},{"id":"406570","messageId":"9c7a96451937c752899eb0e2aeaa0e6fc49cc62e.1601327357.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v3.git.1601327357.gitgitgadget@gmail.com","subject":"[PATCH v3 01/11] cmake: ignore files generated by CMake as run in Visual Studio","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-28T21:09:06Z","receivedAt":"2020-09-28T21:09:23Z","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\nAs of recent Visual Studio versions, CMake support is built-in:\nhttps://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=vs-2019\n\nAll that needs to be done is to open the worktree as a folder, and\nVisual Studio will find the `CMakeLists.txt` file and automatically\ngenerate the project files.\n\nLet's ignore the entirety of those generated files.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .gitignore | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/.gitignore b/.gitignore\nindex 800b812c6a..6232d33924 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -242,3 +242,4 @@ Release/\n /git.VC.VC.opendb\n /git.VC.db\n *.dSYM\n+/contrib/buildsystems/out\n-- \ngitgitgadget\n\n"},{"id":"406571","messageId":"a49b28e001ffaf73d290a6c75943ff7650f87eda.1601327357.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v3.git.1601327357.gitgitgadget@gmail.com","subject":"[PATCH v3 03/11] cmake: ensure that the `vcpkg` packages are found on Windows","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-28T21:09:08Z","receivedAt":"2020-09-28T21:09:27Z","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\nOn Windows, we use the `vcpkg` project to manage the dependencies, via\n`compat/vcbuild/`. Let's make sure that these dependencies are found by\ndefault.\n\nThis is needed because we are about to recommend loading the Git\nworktree as a folder into Visual Studio, relying on the automatic CMake\nsupport (which would make it relatively cumbersome to adjust the search\npath used by CMake manually).\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 1847a6fd58..12268f61ba 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -40,6 +40,13 @@ cmake_minimum_required(VERSION 3.14)\n \n #set the source directory to root of git\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n+if(WIN32)\n+\tset(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n+\tlist(APPEND CMAKE_PREFIX_PATH \"${VCPKG_DIR}/installed/x64-windows\")\n+\n+\t# In the vcpkg edition, we need this to be able to link to libcurl\n+\tset(CURL_NO_CURL_CMAKE ON)\n+endif()\n \n find_program(SH_EXE sh PATHS \"C:/Program Files/Git/bin\")\n if(NOT SH_EXE)\n-- \ngitgitgadget\n\n"},{"id":"406572","messageId":"pull.738.v3.git.1601327357.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v2.git.1601155970.gitgitgadget@gmail.com","subject":"[PATCH v3 00/11] CMake and Visual Studio","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-28T21:09:05Z","receivedAt":"2020-09-28T21:09:28Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"The intention of this patch series is to make it as easy as possible for a\nVisual Studio user to start building Git from scratch. The idea is to\n\n * clone Git's source code,\n * open it in Visual Studio via File>Open>Folder...\n * let CMake configure things (and vcpkg build the dependencies, which will\n   take a while), and\n * start the build.\n\nIt does require a Git for Windows to be installed so that the source can be\ncloned, but also to run the shell script parts of the CMake configuration,\nand also to run the tests.\n\nThis patch series replaces the patch \"Ignore files generated by CMake\" I\nsent via https://github.com/gitgitgadget/git/pull/735.\n\nChanges since v2:\n\n * Fixed a typo in the message when msgfmt.exe is not found.\n * Simplified the logic to find sh.exe (thanks Øystein).\n\nChanges since v1:\n\n * Touched up a couple commit messages in response to reviewer comments\n * Adjusted the instructions at the top of CMakeLists.txt so that the part\n   talking about running CMake manually also talks about using \n   contrib/buildsystems/out/ as build directory (in line with the part\n   talking about Visual Studio's out-of-the-box experience)\n * Replaced patch 10/10 with Junio's much more elegant solution of editing\n   the hashmap_for_each_entry() macro instead of all of its callers.\n\nJohannes Schindelin (10):\n  cmake: ignore files generated by CMake as run in Visual Studio\n  cmake: do find Git for Windows' shell interpreter\n  cmake: ensure that the `vcpkg` packages are found on Windows\n  cmake: fall back to using `vcpkg`'s `msgfmt.exe` on Windows\n  cmake: quote the path accurately when editing `test-lib.sh`\n  cmake (Windows): let the `.dll` files be found when running the tests\n  cmake (Windows): complain when encountering an unknown compiler\n  cmake (Windows): initialize vcpkg/build dependencies automatically\n  cmake (Windows): recommend using Visual Studio's built-in CMake\n    support\n  cmake: fix typo in message when `msgfmt` was not found\n\nJunio C Hamano (1):\n  hashmap_for_each_entry(): workaround MSVC's runtime check failure #3\n\n .gitignore                          |  1 +\n contrib/buildsystems/CMakeLists.txt | 52 ++++++++++++++++++++++-------\n hashmap.h                           |  3 +-\n 3 files changed, 43 insertions(+), 13 deletions(-)\n\n\nbase-commit: 9bc233ae1cf19a49e51842c7959d80a675dbd1c0\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-738%2Fdscho%2Fcmake-and-visual-studio-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-738/dscho/cmake-and-visual-studio-v3\nPull-Request: https://github.com/gitgitgadget/git/pull/738\n\nRange-diff vs v2:\n\n  1:  ba314373e9 =  1:  9c7a964519 cmake: ignore files generated by CMake as run in Visual Studio\n  2:  05b4b69fee <  -:  ---------- cmake: do find Git for Windows' shell interpreter\n  -:  ---------- >  2:  3b467360bb cmake: do find Git for Windows' shell interpreter\n  3:  5967822a0c !  3:  a49b28e001 cmake: ensure that the `vcpkg` packages are found on Windows\n     @@ contrib/buildsystems/CMakeLists.txt: cmake_minimum_required(VERSION 3.14)\n      +\tset(CURL_NO_CURL_CMAKE ON)\n      +endif()\n       \n     - find_program(SH_EXE sh)\n     + find_program(SH_EXE sh PATHS \"C:/Program Files/Git/bin\")\n       if(NOT SH_EXE)\n  4:  efc93f1dd9 =  4:  f1baf0f974 cmake: fall back to using `vcpkg`'s `msgfmt.exe` on Windows\n  5:  8b3500a07c =  5:  8380aa55ab cmake: quote the path accurately when editing `test-lib.sh`\n  6:  88abbd9a78 =  6:  f61c3ef442 cmake (Windows): let the `.dll` files be found when running the tests\n  7:  26ebeecb14 =  7:  7a4346a437 cmake (Windows): complain when encountering an unknown compiler\n  8:  3587ee5e8d =  8:  7c1601c7e3 cmake (Windows): initialize vcpkg/build dependencies automatically\n  9:  68a7d984ec =  9:  ec182738f0 cmake (Windows): recommend using Visual Studio's built-in CMake support\n 10:  152705bbc6 = 10:  38cef4deb5 hashmap_for_each_entry(): workaround MSVC's runtime check failure #3\n  -:  ---------- > 11:  c3e235fe39 cmake: fix typo in message when `msgfmt` was not found\n\n-- \ngitgitgadget\n"},{"id":"406573","messageId":"3b467360bbc2c03474a7f704d23b1fe1df56dc49.1601327357.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v3.git.1601327357.gitgitgadget@gmail.com","subject":"[PATCH v3 02/11] cmake: do find Git for Windows' shell interpreter","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-28T21:09:07Z","receivedAt":"2020-09-28T21:09:28Z","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\nBy default, Git for Windows does not install its `sh.exe` into the\n`PATH`. However, our current `CMakeLists.txt` expects to find a shell\ninterpreter in the `PATH`.\n\nSo let's fall back to looking in the default location where Git for\nWindows _does_ install a relatively convenient `sh.exe`:\n`C:\\Program Files\\Git\\bin\\sh.exe`\n\nHelped-by: Øystein Walle <oystwa@gmail.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 5007f173f1..1847a6fd58 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -41,7 +41,7 @@ cmake_minimum_required(VERSION 3.14)\n #set the source directory to root of git\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n \n-find_program(SH_EXE sh)\n+find_program(SH_EXE sh PATHS \"C:/Program Files/Git/bin\")\n if(NOT SH_EXE)\n \tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n \t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n-- \ngitgitgadget\n\n"},{"id":"406574","messageId":"8380aa55ab53aeb552de5eaf4bdae92bba71c958.1601327357.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v3.git.1601327357.gitgitgadget@gmail.com","subject":"[PATCH v3 05/11] cmake: quote the path accurately when editing `test-lib.sh`","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-28T21:09:10Z","receivedAt":"2020-09-28T21:09:29Z","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\nBy default, the build directory will be called something like\n`contrib/buildsystems/out/build/x64-Debug (default)` (note the space and\nthe parentheses). We need to make sure that such a path is quoted\nproperly when editing the assignment of the `GIT_BUILD_DIR` variable.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 683cf38263..1999db0c6b 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -949,7 +949,7 @@ if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})\n \tfile(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake\n \t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \\\"GIT_BUILD_DIR=(.*)\\\")\\n\"\n \t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\\n\"\n-\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY\\\\\\\"/../${BUILD_DIR_RELATIVE}\\\" content \\\"\\${content}\\\")\\n\"\n+\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY/../${BUILD_DIR_RELATIVE}\\\\\\\"\\\" content \\\"\\${content}\\\")\\n\"\n \t\t\"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \\${content})\")\n \t#misc copies\n \tfile(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)\n-- \ngitgitgadget\n\n"},{"id":"406575","messageId":"f1baf0f9740ccce202e6eb8b631c5cf9c6127817.1601327357.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v3.git.1601327357.gitgitgadget@gmail.com","subject":"[PATCH v3 04/11] cmake: fall back to using `vcpkg`'s `msgfmt.exe` on Windows","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-28T21:09:09Z","receivedAt":"2020-09-28T21:09:30Z","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\nWe are already relying on `vcpkg` to manage our dependencies, including\n`libiconv`. Let's also use the `msgfmt.exe` from there.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 12268f61ba..683cf38263 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -152,7 +152,11 @@ endif()\n \n find_program(MSGFMT_EXE msgfmt)\n if(NOT MSGFMT_EXE)\n-\tmessage(WARNING \"Text Translations won't be build\")\n+\tset(MSGFMT_EXE ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg/downloads/tools/msys2/msys64/usr/bin/msgfmt.exe)\n+\tif(NOT EXISTS ${MSGFMT_EXE})\n+\t\tmessage(WARNING \"Text Translations won't be build\")\n+\t\tunset(MSGFMT_EXE)\n+\tendif()\n endif()\n \n #Force all visual studio outputs to CMAKE_BINARY_DIR\n-- \ngitgitgadget\n\n"},{"id":"406576","messageId":"ec182738f0f8344f6fbea869990200aeb8e94e58.1601327357.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v3.git.1601327357.gitgitgadget@gmail.com","subject":"[PATCH v3 09/11] cmake (Windows): recommend using Visual Studio's built-in CMake support","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-28T21:09:14Z","receivedAt":"2020-09-28T21:09:36Z","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\nIt is a lot more convenient to use than having to specify the\nconfiguration in CMake manually (does not matter whether using the\ncommand-line or CMake's GUI).\n\nWhile at it, recommend using `contrib/buildsystems/out/` as build\ndirectory also in the part that talks about running CMake manually.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 26 +++++++++++++++++---------\n 1 file changed, 17 insertions(+), 9 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 6a92ec9763..4b16744847 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -4,17 +4,25 @@\n \n #[[\n \n-Instructions to run CMake:\n+Instructions how to use this in Visual Studio:\n \n-cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n-Eg.\n-From the root of git source tree\n-\t`cmake contrib/buildsystems/ `\n-This will build the git binaries at the root\n+Open the worktree as a folder. Visual Studio 2019 and later will detect\n+the CMake configuration automatically and set everything up for you,\n+ready to build. You can then run the tests in `t/` via a regular Git Bash.\n \n-For out of source builds, say build in 'git/git-build/'\n-\t`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`\n-This will build the git binaries in git-build directory\n+Note: Visual Studio also has the option of opening `CMakeLists.txt`\n+directly; Using this option, Visual Studio will not find the source code,\n+though, therefore the `File>Open>Folder...` option is preferred.\n+\n+Instructions to run CMake manually:\n+\n+    mkdir -p contrib/buildsystems/out\n+    cd contrib/buildsystems/out\n+    cmake ../ -DCMAKE_BUILD_TYPE=Release\n+\n+This will build the git binaries in contrib/buildsystems/out\n+directory (our top-level .gitignore file knows to ignore contents of\n+this directory).\n \n Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n compiler flags\n-- \ngitgitgadget\n\n"},{"id":"406577","messageId":"38cef4deb509e5b0c218abcc385232f98ef27863.1601327357.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v3.git.1601327357.gitgitgadget@gmail.com","subject":"[PATCH v3 10/11] hashmap_for_each_entry(): workaround MSVC's runtime check failure #3","fromName":"Junio C Hamano via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-28T21:09:15Z","receivedAt":"2020-09-28T21:09:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n\nThe OFFSETOF_VAR(var, member) macro is implemented in terms of\noffsetof(typeof(*var), member) with compilers that know typeof(),\nbut its fallback implemenation compares &(var->member) and (var) and\ncount the distance in bytes, i.e.\n\n    ((uintptr_t)&(var)->member - (uintptr_t)(var))\n\nMSVC's runtime check, when fed an uninitialized 'var', flags this as\na use of an uninitialized variable (and that is legit---uninitialized\ncontents of 'var' is subtracted) in a debug build.\n\nAfter auditing all 6 uses of OFFSETOF_VAR(), 1 of them does feed a\npotentially uninitialized 'var' to the macro in the beginning of the\nfor() loop:\n\n    #define hashmap_for_each_entry(map, iter, var, member) \\\n            for (var = hashmap_iter_first_entry_offset(map, iter, \\\n                                                    OFFSETOF_VAR(var, member)); \\\n                    var; \\\n                    var = hashmap_iter_next_entry_offset(iter, \\\n                                                    OFFSETOF_VAR(var, member)))\n\nWe can work around this by making sure that var has _some_ value\nwhen OFFSETOF_VAR() is called.  Strictly speaking, it invites\nundefined behaviour to use NULL here if we end up with pointer\ncomparison, but MSVC runtime seems to be happy with it, and most\nother systems have typeof() and don't even need pointer comparison\nfallback code.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n hashmap.h | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/hashmap.h b/hashmap.h\nindex ef220de4c6..b011b394fe 100644\n--- a/hashmap.h\n+++ b/hashmap.h\n@@ -449,7 +449,8 @@ static inline struct hashmap_entry *hashmap_iter_first(struct hashmap *map,\n  * containing a @member which is a \"struct hashmap_entry\"\n  */\n #define hashmap_for_each_entry(map, iter, var, member) \\\n-\tfor (var = hashmap_iter_first_entry_offset(map, iter, \\\n+\tfor (var = NULL, /* for systems without typeof */ \\\n+\t     var = hashmap_iter_first_entry_offset(map, iter, \\\n \t\t\t\t\t\tOFFSETOF_VAR(var, member)); \\\n \t\tvar; \\\n \t\tvar = hashmap_iter_next_entry_offset(iter, \\\n-- \ngitgitgadget\n\n"},{"id":"406578","messageId":"f61c3ef44228cd4a8dd85c4b9fda803f6a099ae5.1601327357.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v3.git.1601327357.gitgitgadget@gmail.com","subject":"[PATCH v3 06/11] cmake (Windows): let the `.dll` files be found when running the tests","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-28T21:09:11Z","receivedAt":"2020-09-28T21:09:37Z","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\nContrary to Unix-ish platforms, the dependencies' shared libraries are\nnot usually found in one central place. In our case, since we use\n`vcpkg`, they are to be found inside the `compat/vcbuild/vcpkg/` tree.\n\nLet's make sure that they are in the search path when running the tests.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 1999db0c6b..361fe3de6d 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -939,6 +939,9 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X='${EXE_EXTENSION}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n+if(WIN32)\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PATH=\\\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\\\"\\n\")\n+endif()\n \n #Make the tests work when building out of the source tree\n get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)\n-- \ngitgitgadget\n\n"},{"id":"406579","messageId":"7a4346a437b9bf1ebddafa5f3d92c118793c0078.1601327357.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v3.git.1601327357.gitgitgadget@gmail.com","subject":"[PATCH v3 07/11] cmake (Windows): complain when encountering an unknown compiler","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-28T21:09:12Z","receivedAt":"2020-09-28T21:09: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\nWe have some custom handling regarding the link options, which are\nspecific to each compiler.\n\nTherefore: let's not just continue without setting the link options if\nconfiguring for a currently unhandled compiler, but error out.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 361fe3de6d..13d958f5a6 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -617,6 +617,8 @@ if(WIN32)\n \t\ttarget_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)\n \telseif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n \t\ttarget_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)\n+\telse()\n+\t\tmessage(FATAL_ERROR \"Unhandled compiler: ${CMAKE_C_COMPILER_ID}\")\n \tendif()\n elseif(UNIX)\n \ttarget_link_libraries(common-main pthread rt)\n-- \ngitgitgadget\n\n"},{"id":"406580","messageId":"c3e235fe39b41b90a8a00d81220cb28e83580f13.1601327357.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v3.git.1601327357.gitgitgadget@gmail.com","subject":"[PATCH v3 11/11] cmake: fix typo in message when `msgfmt` was not found","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-28T21:09:16Z","receivedAt":"2020-09-28T21:09:39Z","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\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 4b16744847..b9fced682e 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -166,7 +166,7 @@ find_program(MSGFMT_EXE msgfmt)\n if(NOT MSGFMT_EXE)\n \tset(MSGFMT_EXE ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg/downloads/tools/msys2/msys64/usr/bin/msgfmt.exe)\n \tif(NOT EXISTS ${MSGFMT_EXE})\n-\t\tmessage(WARNING \"Text Translations won't be build\")\n+\t\tmessage(WARNING \"Text Translations won't be built\")\n \t\tunset(MSGFMT_EXE)\n \tendif()\n endif()\n-- \ngitgitgadget\n"},{"id":"406581","messageId":"7c1601c7e351855fd720df05efc44440374792ce.1601327357.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v3.git.1601327357.gitgitgadget@gmail.com","subject":"[PATCH v3 08/11] cmake (Windows): initialize vcpkg/build dependencies automatically","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-28T21:09:13Z","receivedAt":"2020-09-28T21:09:40Z","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 idea of having CMake support in Git's source tree is to enable\ncontributors on Windows to start contributing with little effort. To\nthat end, we just added some sensible defaults that will let users open\nthe worktree in Visual Studio and start building.\n\nThis expects the dependencies (such as zlib) to be available already,\nthough. If they are not available, we expect the user to run\n`compat/vcbuild/vcpkg_install.bat`.\n\nRather than requiring this step to be manual, detect the situation and\nrun it as part of the CMake configuration step.\n\nThis concludes our journey to make it as effortless as possible to start\ndeveloping Git in Visual Studio: all the developer needs to do is to\nclone Git's repository, open the worktree via `File>Open>Folder...` and\nwait for CMake to finish configuring.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 13d958f5a6..6a92ec9763 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n if(WIN32)\n \tset(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n+\tif(NOT EXISTS ${VCPKG_DIR})\n+\t\tmessage(\"Initializinge vcpkg and building the Git's dependencies (this will take a while...)\")\n+\t\texecute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat)\n+\tendif()\n \tlist(APPEND CMAKE_PREFIX_PATH \"${VCPKG_DIR}/installed/x64-windows\")\n \n \t# In the vcpkg edition, we need this to be able to link to libcurl\n-- \ngitgitgadget\n\n"},{"id":"406591","messageId":"xmqqtuvhk0vy.fsf@gitster.c.googlers.com","threadId":"54295","inReplyTo":"c3e235fe39b41b90a8a00d81220cb28e83580f13.1601327357.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 11/11] cmake: fix typo in message when `msgfmt` was not found","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-09-28T22:11:13Z","receivedAt":"2020-09-28T23:29:08Z","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> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n\nShouldn't this be squashed into the step being fixed, which is part\nof this series?  Would it be the \"fall back to using...\" step (4/11)?\n\n>  contrib/buildsystems/CMakeLists.txt | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> index 4b16744847..b9fced682e 100644\n> --- a/contrib/buildsystems/CMakeLists.txt\n> +++ b/contrib/buildsystems/CMakeLists.txt\n> @@ -166,7 +166,7 @@ find_program(MSGFMT_EXE msgfmt)\n>  if(NOT MSGFMT_EXE)\n>  \tset(MSGFMT_EXE ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg/downloads/tools/msys2/msys64/usr/bin/msgfmt.exe)\n>  \tif(NOT EXISTS ${MSGFMT_EXE})\n> -\t\tmessage(WARNING \"Text Translations won't be build\")\n> +\t\tmessage(WARNING \"Text Translations won't be built\")\n>  \t\tunset(MSGFMT_EXE)\n>  \tendif()\n>  endif()\n"},{"id":"406621","messageId":"CAKiG+9U2v+HYXU_xGzbAK11fo0zHSR7xGBWPq0=0e2rU-Z5W0g@mail.gmail.com","threadId":"54295","inReplyTo":"7c1601c7e351855fd720df05efc44440374792ce.1601327357.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 08/11] cmake (Windows): initialize vcpkg/build dependencies automatically","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-09-29T06:51:07Z","receivedAt":"2020-09-29T06:51:24Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":">  if(WIN32)\n>         set(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n> +       if(NOT EXISTS ${VCPKG_DIR})\n> +               message(\"Initializinge vcpkg and building the Git's dependencies (this will take a while...)\")\n         I think you meant Initializing. (Nitpicking :) )\n\nThank You,\nSibi Siddharthan\n"},{"id":"406623","messageId":"nycvar.QRO.7.76.6.2009291406310.50@tvgsbejvaqbjf.bet","threadId":"54295","inReplyTo":"CAKiG+9U2v+HYXU_xGzbAK11fo0zHSR7xGBWPq0=0e2rU-Z5W0g@mail.gmail.com","subject":"Re: [PATCH v3 08/11] cmake (Windows): initialize vcpkg/build dependencies automatically","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-09-29T12:07:02Z","receivedAt":"2020-09-29T13:04:52Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Sibi,\n\nOn Tue, 29 Sep 2020, Sibi Siddharthan wrote:\n\n> >  if(WIN32)\n> >         set(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n> > +       if(NOT EXISTS ${VCPKG_DIR})\n> > +               message(\"Initializinge vcpkg and building the Git's dependencies (this will take a while...)\")\n>          I think you meant Initializing. (Nitpicking :) )\n\nAw shucks! Thank you for being thorough,\nDscho\n"},{"id":"406624","messageId":"nycvar.QRO.7.76.6.2009291407130.50@tvgsbejvaqbjf.bet","threadId":"54295","inReplyTo":"xmqqtuvhk0vy.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v3 11/11] cmake: fix typo in message when `msgfmt` was not found","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-09-29T12:07:57Z","receivedAt":"2020-09-29T13:05:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Mon, 28 Sep 2020, Junio C Hamano wrote:\n\n> \"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\n> writes:\n>\n> > From: Johannes Schindelin <johannes.schindelin@gmx.de>\n> >\n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > ---\n>\n> Shouldn't this be squashed into the step being fixed, which is part\n> of this series?  Would it be the \"fall back to using...\" step (4/11)?\n\nOy. I did not even realize that it was _my_ typo. Fixed in my branch. I'll\nwait a little, just in case that anything else needs to be fixed, before\nsending the next iteration.\n\nCiao,\nDscho\n"},{"id":"406625","messageId":"20200929140400.GE20935@danh.dev","threadId":"54295","inReplyTo":"nycvar.QRO.7.76.6.2009281553520.50@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 02/10] cmake: do find Git for Windows' shell interpreter","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-09-29T14:04:13Z","receivedAt":"2020-09-29T14:04:21Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-09-28 15:56:13+0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> Hi Danh,\n> \n> On Sun, 27 Sep 2020, Đoàn Trần Công Danh wrote:\n> \n> > On 2020-09-26 22:32:25+0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> >\n> > > > I personally don't install my dev tools(except Visual Studio) to\n> > > > Program Files(because of the _space_), it messes up the Makefiles.\n> > >\n> > > Sure, and that's your prerogative. There's unfortunately no good way to\n> > > support your use case.\n> > >\n> > > Luckily, the vast majority of Git for Windows' users do not change the\n> > > default location, and this patch is for them. (And \"them\" in this case\n> > > includes me, personally ;-))\n> >\n> > This doesn't fit into my view of Git for Windows' users\n> > For some users that have the Administrator right, it's the default\n> > location if they grant the Administrator right for the installer.\n> >\n> > For those poor souls that works for enterprise companies, and thoses\n> > that not feel comfortable give Administrator right to _another_\n> > installer, the installer will install into (hopeful, I type it right):\n> >\n> > \t%USERPROFILE%/AppData/Local/Programs/Git\n> \n> Those poor souls that work for enterprise companies often have Git for\n> Windows installed by default. And of course, that default would be in\n> `C:\\Program Files\\Git`.\n\nYes, that's correct, but that Git is usually very old, and I'm not\nsure about its layout. Obviously, you know better in this regard :-p\n\n> \n> > I think it's better to offer SH_EXE as an OPTION, let user specify it\n> > as will. And we'll search in PATH if it's not specified, fallback to\n> > 2 default value if not found.\n> \n> That's exactly as it is right now. You can specify `SH_EXE` (but only if\n> running CMake manually, not via Visual Studio). If you don't, it searches\n> `PATH`, and with my patch it then falls back to trying to find `sh.exe` in\n> Git for Windows' default location.\n> \n> So I think we're in agreement here?\n\nYes, seems good.\n\n-- \nDanh\n"},{"id":"406638","messageId":"nycvar.QRO.7.76.6.2009292039200.50@tvgsbejvaqbjf.bet","threadId":"54295","inReplyTo":"20200929140400.GE20935@danh.dev","subject":"Re: [PATCH 02/10] cmake: do find Git for Windows' shell interpreter","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-09-29T18:42:10Z","receivedAt":"2020-09-29T19:40:04Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Danh,\n\nOn Tue, 29 Sep 2020, Đoàn Trần Công Danh wrote:\n\n> On 2020-09-28 15:56:13+0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>\n> > On Sun, 27 Sep 2020, Đoàn Trần Công Danh wrote:\n> >\n> > > On 2020-09-26 22:32:25+0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > >\n> > > > > I personally don't install my dev tools(except Visual Studio) to\n> > > > > Program Files(because of the _space_), it messes up the Makefiles.\n> > > >\n> > > > Sure, and that's your prerogative. There's unfortunately no good way to\n> > > > support your use case.\n> > > >\n> > > > Luckily, the vast majority of Git for Windows' users do not change the\n> > > > default location, and this patch is for them. (And \"them\" in this case\n> > > > includes me, personally ;-))\n> > >\n> > > This doesn't fit into my view of Git for Windows' users\n> > > For some users that have the Administrator right, it's the default\n> > > location if they grant the Administrator right for the installer.\n> > >\n> > > For those poor souls that works for enterprise companies, and thoses\n> > > that not feel comfortable give Administrator right to _another_\n> > > installer, the installer will install into (hopeful, I type it right):\n> > >\n> > > \t%USERPROFILE%/AppData/Local/Programs/Git\n> >\n> > Those poor souls that work for enterprise companies often have Git for\n> > Windows installed by default. And of course, that default would be in\n> > `C:\\Program Files\\Git`.\n>\n> Yes, that's correct, but that Git is usually very old, and I'm not\n> sure about its layout. Obviously, you know better in this regard :-p\n\nIn Git for Windows v1.x, it would have contained the real Bash (at least\nin 32-bit Windows; in 64-bit Windows, it would have been `C:\\Program Files\n(x86)\\Git\\bin`). But v1.x is long deprecated, it's over 5 years old.\n\nThe `C:\\Program Files\\Git\\bin\\sh.exe` stand-in is actually not _all_ that\nold, I only reintroduced it relatively recently. Nevertheless, it is the\nbest bet for a default fall-back that I can think of.\n\n> > > I think it's better to offer SH_EXE as an OPTION, let user specify it\n> > > as will. And we'll search in PATH if it's not specified, fallback to\n> > > 2 default value if not found.\n> >\n> > That's exactly as it is right now. You can specify `SH_EXE` (but only if\n> > running CMake manually, not via Visual Studio). If you don't, it searches\n> > `PATH`, and with my patch it then falls back to trying to find `sh.exe` in\n> > Git for Windows' default location.\n> >\n> > So I think we're in agreement here?\n>\n> Yes, seems good.\n\nExcellent!\nDscho\n"},{"id":"406657","messageId":"CAKiG+9W71vEd3bUOEq=vtgcaHuWsjmzGqAdg-rszMANrskQDzg@mail.gmail.com","threadId":"54295","inReplyTo":"3a07bd4916c3949eadaa10fde142fba0acaa974b.1601044118.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 08/10] cmake (Windows): initialize vcpkg/build dependencies automatically","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-09-30T05:05:55Z","receivedAt":"2020-09-30T05:06:10Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Fri, Sep 25, 2020 at 7:58 PM Johannes Schindelin via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n>\n> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> The idea of having CMake support in Git's source tree is to enable\n> contributors on Windows to start contributing with little effort. To\n> that end, we just added some sensible defaults that will let users open\n> the worktree in Visual Studio and start building.\n>\n> This expects the dependencies (such as zlib) to be available already,\n> though. If they are not available, we expect the user to run\n> `compat/vcbuild/vcpkg_install.bat`.\n>\n> Rather than requiring this step to be manual, detect the situation and\n> run it as part of the CMake configuration step.\n>\n> This concludes our journey to make it as effortless as possible to start\n> developing Git in Visual Studio: all the developer needs to do is to\n> clone Git's repository, open the worktree via `File>Open>Folder...` and\n> wait for CMake to finish configuring.\n>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n>  contrib/buildsystems/CMakeLists.txt | 4 ++++\n>  1 file changed, 4 insertions(+)\n>\n> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> index d21849b730..1eaeb8b8e0 100644\n> --- a/contrib/buildsystems/CMakeLists.txt\n> +++ b/contrib/buildsystems/CMakeLists.txt\n> @@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)\n>  set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n>  if(WIN32)\n>         set(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n> +       if(NOT EXISTS ${VCPKG_DIR})\n> +               message(\"Initializinge vcpkg and building the Git's dependencies (this will take a while...)\")\n> +               execute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat)\n> +       endif()\n>         list(APPEND CMAKE_PREFIX_PATH \"${VCPKG_DIR}/installed/x64-windows\")\n>\n>         # In the vcpkg edition, we need this to be able to link to libcurl\n> --\n> gitgitgadget\n>\n\nAfter reading the patch series I seem to get to feeling that people on\nWindows are being nudged to use Visual Studio and vcpkg.\nAlthough they are great tools, when I want to specify my own libraries\nI don't see an option here.\nI think we need to define a variable, which this conditional block\nuses, which is set to true if we are using a Visual Studio Generator.\nWe also need a way to override this option if needed.\nIf this variable(explained above) is not set or false or OFF, we defer\nbuilding vcpkg libraries. This can also save time in the case\nwhen we already have the dependencies(libraries) and just want to\npoint to them instead of building with vcpkg.\nI also see that people who use gcc(MinGW) are left out. I think we\nalso need to set the supported compiler(s) here before executing\nvcpkg_install.bat. People who use gcc would need to point to their own\nlibraries with CMAKE_PREFIX_PATH.\n\nThank You,\nSibi Siddharthan\n"},{"id":"406683","messageId":"nycvar.QRO.7.76.6.2009301722500.50@tvgsbejvaqbjf.bet","threadId":"54295","inReplyTo":"CAKiG+9W71vEd3bUOEq=vtgcaHuWsjmzGqAdg-rszMANrskQDzg@mail.gmail.com","subject":"Re: [PATCH 08/10] cmake (Windows): initialize vcpkg/build dependencies automatically","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-09-30T15:25:16Z","receivedAt":"2020-09-30T15:25:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Sibi,\n\nOn Wed, 30 Sep 2020, Sibi Siddharthan wrote:\n\n> On Fri, Sep 25, 2020 at 7:58 PM Johannes Schindelin via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n> >\n> > From: Johannes Schindelin <johannes.schindelin@gmx.de>\n> >\n> > The idea of having CMake support in Git's source tree is to enable\n> > contributors on Windows to start contributing with little effort. To\n> > that end, we just added some sensible defaults that will let users open\n> > the worktree in Visual Studio and start building.\n> >\n> > This expects the dependencies (such as zlib) to be available already,\n> > though. If they are not available, we expect the user to run\n> > `compat/vcbuild/vcpkg_install.bat`.\n> >\n> > Rather than requiring this step to be manual, detect the situation and\n> > run it as part of the CMake configuration step.\n> >\n> > This concludes our journey to make it as effortless as possible to start\n> > developing Git in Visual Studio: all the developer needs to do is to\n> > clone Git's repository, open the worktree via `File>Open>Folder...` and\n> > wait for CMake to finish configuring.\n> >\n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > ---\n> >  contrib/buildsystems/CMakeLists.txt | 4 ++++\n> >  1 file changed, 4 insertions(+)\n> >\n> > diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> > index d21849b730..1eaeb8b8e0 100644\n> > --- a/contrib/buildsystems/CMakeLists.txt\n> > +++ b/contrib/buildsystems/CMakeLists.txt\n> > @@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)\n> >  set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n> >  if(WIN32)\n> >         set(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n> > +       if(NOT EXISTS ${VCPKG_DIR})\n> > +               message(\"Initializinge vcpkg and building the Git's dependencies (this will take a while...)\")\n> > +               execute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat)\n> > +       endif()\n> >         list(APPEND CMAKE_PREFIX_PATH \"${VCPKG_DIR}/installed/x64-windows\")\n> >\n> >         # In the vcpkg edition, we need this to be able to link to libcurl\n> > --\n> > gitgitgadget\n> >\n>\n> After reading the patch series I seem to get to feeling that people on\n> Windows are being nudged to use Visual Studio and vcpkg.\n> Although they are great tools, when I want to specify my own libraries\n> I don't see an option here.\n> I think we need to define a variable, which this conditional block\n> uses, which is set to true if we are using a Visual Studio Generator.\n> We also need a way to override this option if needed.\n> If this variable(explained above) is not set or false or OFF, we defer\n> building vcpkg libraries. This can also save time in the case\n> when we already have the dependencies(libraries) and just want to\n> point to them instead of building with vcpkg.\n> I also see that people who use gcc(MinGW) are left out. I think we\n> also need to set the supported compiler(s) here before executing\n> vcpkg_install.bat. People who use gcc would need to point to their own\n> libraries with CMAKE_PREFIX_PATH.\n\nGood points, even if our current CMake push really tries to cater only to\nVisual Studio (or at least, MS Visual C) users.\n\nI added a further guard to the conditional: `MSVC` needs to be true. This\nmakes sense, as our current support for MSVC/Visual Studio hinges on\nhaving vcpkg build the dependencies, we simply do not support anything\nelse. (And it would be easy enough for a proficient Visual Studio user to\n_still_ override the vcpkg system with their own libraries, if they\nreally want to make that work.)\n\nThanks,\nDscho\n"},{"id":"406685","messageId":"cfedb1673ad1408c58eccddb365af5a0ab0ad93c.1601479585.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v4.git.1601479585.gitgitgadget@gmail.com","subject":"[PATCH v4 05/10] cmake: quote the path accurately when editing `test-lib.sh`","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-30T15:26:19Z","receivedAt":"2020-09-30T15:26:39Z","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\nBy default, the build directory will be called something like\n`contrib/buildsystems/out/build/x64-Debug (default)` (note the space and\nthe parentheses). We need to make sure that such a path is quoted\nproperly when editing the assignment of the `GIT_BUILD_DIR` variable.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 02241dcc77..3bb74337e1 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -949,7 +949,7 @@ if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})\n \tfile(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake\n \t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \\\"GIT_BUILD_DIR=(.*)\\\")\\n\"\n \t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\\n\"\n-\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY\\\\\\\"/../${BUILD_DIR_RELATIVE}\\\" content \\\"\\${content}\\\")\\n\"\n+\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY/../${BUILD_DIR_RELATIVE}\\\\\\\"\\\" content \\\"\\${content}\\\")\\n\"\n \t\t\"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \\${content})\")\n \t#misc copies\n \tfile(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)\n-- \ngitgitgadget\n\n"},{"id":"406684","messageId":"56cfdb2ee9de3c60baedb10496f4dc628c910a41.1601479585.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v4.git.1601479585.gitgitgadget@gmail.com","subject":"[PATCH v4 04/10] cmake: fall back to using `vcpkg`'s `msgfmt.exe` on Windows","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-30T15:26:18Z","receivedAt":"2020-09-30T15:26:40Z","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\nWe are already relying on `vcpkg` to manage our dependencies, including\n`libiconv`. Let's also use the `msgfmt.exe` from there.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 12268f61ba..02241dcc77 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -152,7 +152,11 @@ endif()\n \n find_program(MSGFMT_EXE msgfmt)\n if(NOT MSGFMT_EXE)\n-\tmessage(WARNING \"Text Translations won't be build\")\n+\tset(MSGFMT_EXE ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg/downloads/tools/msys2/msys64/usr/bin/msgfmt.exe)\n+\tif(NOT EXISTS ${MSGFMT_EXE})\n+\t\tmessage(WARNING \"Text Translations won't be built\")\n+\t\tunset(MSGFMT_EXE)\n+\tendif()\n endif()\n \n #Force all visual studio outputs to CMAKE_BINARY_DIR\n-- \ngitgitgadget\n\n"},{"id":"406687","messageId":"d402f721c2568486f2ed2c58341b9ebd4594356c.1601479585.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v4.git.1601479585.gitgitgadget@gmail.com","subject":"[PATCH v4 06/10] cmake (Windows): let the `.dll` files be found when running the tests","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-30T15:26:20Z","receivedAt":"2020-09-30T15:26:43Z","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\nContrary to Unix-ish platforms, the dependencies' shared libraries are\nnot usually found in one central place. In our case, since we use\n`vcpkg`, they are to be found inside the `compat/vcbuild/vcpkg/` tree.\n\nLet's make sure that they are in the search path when running the tests.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 3bb74337e1..55d0960002 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -939,6 +939,9 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X='${EXE_EXTENSION}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n+if(WIN32)\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PATH=\\\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\\\"\\n\")\n+endif()\n \n #Make the tests work when building out of the source tree\n get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)\n-- \ngitgitgadget\n\n"},{"id":"406688","messageId":"0e7fdfddb4105032226d7ff16447a8cdc3020f33.1601479585.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v4.git.1601479585.gitgitgadget@gmail.com","subject":"[PATCH v4 07/10] cmake (Windows): complain when encountering an unknown compiler","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-30T15:26:21Z","receivedAt":"2020-09-30T15:26:43Z","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\nWe have some custom handling regarding the link options, which are\nspecific to each compiler.\n\nTherefore: let's not just continue without setting the link options if\nconfiguring for a currently unhandled compiler, but error out.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 55d0960002..78b90abe5e 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -617,6 +617,8 @@ if(WIN32)\n \t\ttarget_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)\n \telseif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n \t\ttarget_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)\n+\telse()\n+\t\tmessage(FATAL_ERROR \"Unhandled compiler: ${CMAKE_C_COMPILER_ID}\")\n \tendif()\n elseif(UNIX)\n \ttarget_link_libraries(common-main pthread rt)\n-- \ngitgitgadget\n\n"},{"id":"406686","messageId":"14ddfc17815d68f2f32aebbc4b0ecb3ce6f25dc1.1601479585.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v4.git.1601479585.gitgitgadget@gmail.com","subject":"[PATCH v4 08/10] cmake (Windows): initialize vcpkg/build dependencies automatically","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-30T15:26:22Z","receivedAt":"2020-09-30T15:26:44Z","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 idea of having CMake support in Git's source tree is to enable\ncontributors on Windows to start contributing with little effort. To\nthat end, we just added some sensible defaults that will let users open\nthe worktree in Visual Studio and start building.\n\nThis expects the dependencies (such as zlib) to be available already,\nthough. If they are not available, we expect the user to run\n`compat/vcbuild/vcpkg_install.bat`.\n\nRather than requiring this step to be manual, detect the situation and\nrun it as part of the CMake configuration step.\n\nNote that this obviously only applies to the scenario when we want to\ncompile in Visual Studio (i.e. with MS Visual C), not with GCC.\nTherefore, we guard this new code block behind the `MSVC` conditional.\n\nThis concludes our journey to make it as effortless as possible to start\ndeveloping Git in Visual Studio: all the developer needs to do is to\nclone Git's repository, open the worktree via `File>Open>Folder...` and\nwait for CMake to finish configuring.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nsquash! cmake (Windows): initialize vcpkg/build dependencies automatically\n\nMSVC\n---\n contrib/buildsystems/CMakeLists.txt | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 78b90abe5e..ebadae2271 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n if(WIN32)\n \tset(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n+\tif(MSVC AND NOT EXISTS ${VCPKG_DIR})\n+\t\tmessage(\"Initializing vcpkg and building the Git's dependencies (this will take a while...)\")\n+\t\texecute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat)\n+\tendif()\n \tlist(APPEND CMAKE_PREFIX_PATH \"${VCPKG_DIR}/installed/x64-windows\")\n \n \t# In the vcpkg edition, we need this to be able to link to libcurl\n-- \ngitgitgadget\n\n"},{"id":"406689","messageId":"b239162eb2be6309b6aef7ab08cf100f4b63e3bf.1601479585.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v4.git.1601479585.gitgitgadget@gmail.com","subject":"[PATCH v4 09/10] cmake (Windows): recommend using Visual Studio's built-in CMake support","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-30T15:26:23Z","receivedAt":"2020-09-30T15:26:45Z","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\nIt is a lot more convenient to use than having to specify the\nconfiguration in CMake manually (does not matter whether using the\ncommand-line or CMake's GUI).\n\nWhile at it, recommend using `contrib/buildsystems/out/` as build\ndirectory also in the part that talks about running CMake manually.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 26 +++++++++++++++++---------\n 1 file changed, 17 insertions(+), 9 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex ebadae2271..df539a44fa 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -4,17 +4,25 @@\n \n #[[\n \n-Instructions to run CMake:\n+Instructions how to use this in Visual Studio:\n \n-cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n-Eg.\n-From the root of git source tree\n-\t`cmake contrib/buildsystems/ `\n-This will build the git binaries at the root\n+Open the worktree as a folder. Visual Studio 2019 and later will detect\n+the CMake configuration automatically and set everything up for you,\n+ready to build. You can then run the tests in `t/` via a regular Git Bash.\n \n-For out of source builds, say build in 'git/git-build/'\n-\t`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`\n-This will build the git binaries in git-build directory\n+Note: Visual Studio also has the option of opening `CMakeLists.txt`\n+directly; Using this option, Visual Studio will not find the source code,\n+though, therefore the `File>Open>Folder...` option is preferred.\n+\n+Instructions to run CMake manually:\n+\n+    mkdir -p contrib/buildsystems/out\n+    cd contrib/buildsystems/out\n+    cmake ../ -DCMAKE_BUILD_TYPE=Release\n+\n+This will build the git binaries in contrib/buildsystems/out\n+directory (our top-level .gitignore file knows to ignore contents of\n+this directory).\n \n Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n compiler flags\n-- \ngitgitgadget\n\n"},{"id":"406690","messageId":"7643a766b7dedb32bbe46689b01a9009e16277f9.1601479585.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v4.git.1601479585.gitgitgadget@gmail.com","subject":"[PATCH v4 10/10] hashmap_for_each_entry(): workaround MSVC's runtime check failure #3","fromName":"Junio C Hamano via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-30T15:26:24Z","receivedAt":"2020-09-30T15:26:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n\nThe OFFSETOF_VAR(var, member) macro is implemented in terms of\noffsetof(typeof(*var), member) with compilers that know typeof(),\nbut its fallback implemenation compares &(var->member) and (var) and\ncount the distance in bytes, i.e.\n\n    ((uintptr_t)&(var)->member - (uintptr_t)(var))\n\nMSVC's runtime check, when fed an uninitialized 'var', flags this as\na use of an uninitialized variable (and that is legit---uninitialized\ncontents of 'var' is subtracted) in a debug build.\n\nAfter auditing all 6 uses of OFFSETOF_VAR(), 1 of them does feed a\npotentially uninitialized 'var' to the macro in the beginning of the\nfor() loop:\n\n    #define hashmap_for_each_entry(map, iter, var, member) \\\n            for (var = hashmap_iter_first_entry_offset(map, iter, \\\n                                                    OFFSETOF_VAR(var, member)); \\\n                    var; \\\n                    var = hashmap_iter_next_entry_offset(iter, \\\n                                                    OFFSETOF_VAR(var, member)))\n\nWe can work around this by making sure that var has _some_ value\nwhen OFFSETOF_VAR() is called.  Strictly speaking, it invites\nundefined behaviour to use NULL here if we end up with pointer\ncomparison, but MSVC runtime seems to be happy with it, and most\nother systems have typeof() and don't even need pointer comparison\nfallback code.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n hashmap.h | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/hashmap.h b/hashmap.h\nindex ef220de4c6..b011b394fe 100644\n--- a/hashmap.h\n+++ b/hashmap.h\n@@ -449,7 +449,8 @@ static inline struct hashmap_entry *hashmap_iter_first(struct hashmap *map,\n  * containing a @member which is a \"struct hashmap_entry\"\n  */\n #define hashmap_for_each_entry(map, iter, var, member) \\\n-\tfor (var = hashmap_iter_first_entry_offset(map, iter, \\\n+\tfor (var = NULL, /* for systems without typeof */ \\\n+\t     var = hashmap_iter_first_entry_offset(map, iter, \\\n \t\t\t\t\t\tOFFSETOF_VAR(var, member)); \\\n \t\tvar; \\\n \t\tvar = hashmap_iter_next_entry_offset(iter, \\\n-- \ngitgitgadget\n"},{"id":"406691","messageId":"pull.738.v4.git.1601479585.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v3.git.1601327357.gitgitgadget@gmail.com","subject":"[PATCH v4 00/10] CMake and Visual Studio","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-30T15:26:14Z","receivedAt":"2020-09-30T15:27:05Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"The intention of this patch series is to make it as easy as possible for a\nVisual Studio user to start building Git from scratch. The idea is to\n\n * clone Git's source code,\n * open it in Visual Studio via File>Open>Folder...\n * let CMake configure things (and vcpkg build the dependencies, which will\n   take a while), and\n * start the build.\n\nIt does require a Git for Windows to be installed so that the source can be\ncloned, but also to run the shell script parts of the CMake configuration,\nand also to run the tests.\n\nThis patch series replaces the patch \"Ignore files generated by CMake\" I\nsent via https://github.com/gitgitgadget/git/pull/735.\n\nChanges since v3:\n\n * Squashed the typo fix into the correct commit (d'oh!)\n * Fixed another typo (thanks, Sibi!)\n * Guarded the code block that initializes vcpkg and builds the dependencies\n   behind the MSVC conditional (thanks, Sibi!)\n\nChanges since v2:\n\n * Fixed a typo in the message when msgfmt.exe is not found.\n * Simplified the logic to find sh.exe (thanks Øystein).\n\nChanges since v1:\n\n * Touched up a couple commit messages in response to reviewer comments\n * Adjusted the instructions at the top of CMakeLists.txt so that the part\n   talking about running CMake manually also talks about using \n   contrib/buildsystems/out/ as build directory (in line with the part\n   talking about Visual Studio's out-of-the-box experience)\n * Replaced patch 10/10 with Junio's much more elegant solution of editing\n   the hashmap_for_each_entry() macro instead of all of its callers.\n\nJohannes Schindelin (9):\n  cmake: ignore files generated by CMake as run in Visual Studio\n  cmake: do find Git for Windows' shell interpreter\n  cmake: ensure that the `vcpkg` packages are found on Windows\n  cmake: fall back to using `vcpkg`'s `msgfmt.exe` on Windows\n  cmake: quote the path accurately when editing `test-lib.sh`\n  cmake (Windows): let the `.dll` files be found when running the tests\n  cmake (Windows): complain when encountering an unknown compiler\n  cmake (Windows): initialize vcpkg/build dependencies automatically\n  cmake (Windows): recommend using Visual Studio's built-in CMake\n    support\n\nJunio C Hamano (1):\n  hashmap_for_each_entry(): workaround MSVC's runtime check failure #3\n\n .gitignore                          |  1 +\n contrib/buildsystems/CMakeLists.txt | 52 ++++++++++++++++++++++-------\n hashmap.h                           |  3 +-\n 3 files changed, 43 insertions(+), 13 deletions(-)\n\n\nbase-commit: 9bc233ae1cf19a49e51842c7959d80a675dbd1c0\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-738%2Fdscho%2Fcmake-and-visual-studio-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-738/dscho/cmake-and-visual-studio-v4\nPull-Request: https://github.com/gitgitgadget/git/pull/738\n\nRange-diff vs v3:\n\n  1:  9c7a964519 =  1:  9c7a964519 cmake: ignore files generated by CMake as run in Visual Studio\n  2:  3b467360bb =  2:  3b467360bb cmake: do find Git for Windows' shell interpreter\n  3:  a49b28e001 =  3:  a49b28e001 cmake: ensure that the `vcpkg` packages are found on Windows\n  4:  f1baf0f974 !  4:  56cfdb2ee9 cmake: fall back to using `vcpkg`'s `msgfmt.exe` on Windows\n     @@ contrib/buildsystems/CMakeLists.txt: endif()\n      -\tmessage(WARNING \"Text Translations won't be build\")\n      +\tset(MSGFMT_EXE ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg/downloads/tools/msys2/msys64/usr/bin/msgfmt.exe)\n      +\tif(NOT EXISTS ${MSGFMT_EXE})\n     -+\t\tmessage(WARNING \"Text Translations won't be build\")\n     ++\t\tmessage(WARNING \"Text Translations won't be built\")\n      +\t\tunset(MSGFMT_EXE)\n      +\tendif()\n       endif()\n  5:  8380aa55ab =  5:  cfedb1673a cmake: quote the path accurately when editing `test-lib.sh`\n  6:  f61c3ef442 =  6:  d402f721c2 cmake (Windows): let the `.dll` files be found when running the tests\n  7:  7a4346a437 =  7:  0e7fdfddb4 cmake (Windows): complain when encountering an unknown compiler\n  8:  7c1601c7e3 !  8:  14ddfc1781 cmake (Windows): initialize vcpkg/build dependencies automatically\n     @@ Commit message\n          Rather than requiring this step to be manual, detect the situation and\n          run it as part of the CMake configuration step.\n      \n     +    Note that this obviously only applies to the scenario when we want to\n     +    compile in Visual Studio (i.e. with MS Visual C), not with GCC.\n     +    Therefore, we guard this new code block behind the `MSVC` conditional.\n     +\n          This concludes our journey to make it as effortless as possible to start\n          developing Git in Visual Studio: all the developer needs to do is to\n          clone Git's repository, open the worktree via `File>Open>Folder...` and\n     @@ Commit message\n      \n          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n      \n     +    squash! cmake (Windows): initialize vcpkg/build dependencies automatically\n     +\n     +    MSVC\n     +\n       ## contrib/buildsystems/CMakeLists.txt ##\n      @@ contrib/buildsystems/CMakeLists.txt: cmake_minimum_required(VERSION 3.14)\n       set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n       if(WIN32)\n       \tset(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n     -+\tif(NOT EXISTS ${VCPKG_DIR})\n     -+\t\tmessage(\"Initializinge vcpkg and building the Git's dependencies (this will take a while...)\")\n     ++\tif(MSVC AND NOT EXISTS ${VCPKG_DIR})\n     ++\t\tmessage(\"Initializing vcpkg and building the Git's dependencies (this will take a while...)\")\n      +\t\texecute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat)\n      +\tendif()\n       \tlist(APPEND CMAKE_PREFIX_PATH \"${VCPKG_DIR}/installed/x64-windows\")\n  9:  ec182738f0 =  9:  b239162eb2 cmake (Windows): recommend using Visual Studio's built-in CMake support\n 10:  38cef4deb5 = 10:  7643a766b7 hashmap_for_each_entry(): workaround MSVC's runtime check failure #3\n 11:  c3e235fe39 <  -:  ---------- cmake: fix typo in message when `msgfmt` was not found\n\n-- \ngitgitgadget\n"},{"id":"406692","messageId":"3b467360bbc2c03474a7f704d23b1fe1df56dc49.1601479585.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v4.git.1601479585.gitgitgadget@gmail.com","subject":"[PATCH v4 02/10] cmake: do find Git for Windows' shell interpreter","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-30T15:26:16Z","receivedAt":"2020-09-30T15:27: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\nBy default, Git for Windows does not install its `sh.exe` into the\n`PATH`. However, our current `CMakeLists.txt` expects to find a shell\ninterpreter in the `PATH`.\n\nSo let's fall back to looking in the default location where Git for\nWindows _does_ install a relatively convenient `sh.exe`:\n`C:\\Program Files\\Git\\bin\\sh.exe`\n\nHelped-by: Øystein Walle <oystwa@gmail.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 5007f173f1..1847a6fd58 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -41,7 +41,7 @@ cmake_minimum_required(VERSION 3.14)\n #set the source directory to root of git\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n \n-find_program(SH_EXE sh)\n+find_program(SH_EXE sh PATHS \"C:/Program Files/Git/bin\")\n if(NOT SH_EXE)\n \tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n \t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n-- \ngitgitgadget\n\n"},{"id":"406693","messageId":"a49b28e001ffaf73d290a6c75943ff7650f87eda.1601479585.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v4.git.1601479585.gitgitgadget@gmail.com","subject":"[PATCH v4 03/10] cmake: ensure that the `vcpkg` packages are found on Windows","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-30T15:26:17Z","receivedAt":"2020-09-30T15:27:12Z","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\nOn Windows, we use the `vcpkg` project to manage the dependencies, via\n`compat/vcbuild/`. Let's make sure that these dependencies are found by\ndefault.\n\nThis is needed because we are about to recommend loading the Git\nworktree as a folder into Visual Studio, relying on the automatic CMake\nsupport (which would make it relatively cumbersome to adjust the search\npath used by CMake manually).\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/buildsystems/CMakeLists.txt | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 1847a6fd58..12268f61ba 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -40,6 +40,13 @@ cmake_minimum_required(VERSION 3.14)\n \n #set the source directory to root of git\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n+if(WIN32)\n+\tset(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n+\tlist(APPEND CMAKE_PREFIX_PATH \"${VCPKG_DIR}/installed/x64-windows\")\n+\n+\t# In the vcpkg edition, we need this to be able to link to libcurl\n+\tset(CURL_NO_CURL_CMAKE ON)\n+endif()\n \n find_program(SH_EXE sh PATHS \"C:/Program Files/Git/bin\")\n if(NOT SH_EXE)\n-- \ngitgitgadget\n\n"},{"id":"406694","messageId":"9c7a96451937c752899eb0e2aeaa0e6fc49cc62e.1601479585.git.gitgitgadget@gmail.com","threadId":"54295","inReplyTo":"pull.738.v4.git.1601479585.gitgitgadget@gmail.com","subject":"[PATCH v4 01/10] cmake: ignore files generated by CMake as run in Visual Studio","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-30T15:26:15Z","receivedAt":"2020-09-30T15:27:13Z","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\nAs of recent Visual Studio versions, CMake support is built-in:\nhttps://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=vs-2019\n\nAll that needs to be done is to open the worktree as a folder, and\nVisual Studio will find the `CMakeLists.txt` file and automatically\ngenerate the project files.\n\nLet's ignore the entirety of those generated files.\n\nHelped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .gitignore | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/.gitignore b/.gitignore\nindex 800b812c6a..6232d33924 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -242,3 +242,4 @@ Release/\n /git.VC.VC.opendb\n /git.VC.db\n *.dSYM\n+/contrib/buildsystems/out\n-- \ngitgitgadget\n\n"},{"id":"406698","messageId":"nycvar.QRO.7.76.6.2009302117220.50@tvgsbejvaqbjf.bet","threadId":"54295","inReplyTo":"14ddfc17815d68f2f32aebbc4b0ecb3ce6f25dc1.1601479585.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 08/10] cmake (Windows): initialize vcpkg/build dependencies automatically","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-09-30T19:17:56Z","receivedAt":"2020-09-30T19:18:03Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\n\nOn Wed, 30 Sep 2020, Johannes Schindelin via GitGitGadget wrote:\n\n> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> The idea of having CMake support in Git's source tree is to enable\n> contributors on Windows to start contributing with little effort. To\n> that end, we just added some sensible defaults that will let users open\n> the worktree in Visual Studio and start building.\n>\n> This expects the dependencies (such as zlib) to be available already,\n> though. If they are not available, we expect the user to run\n> `compat/vcbuild/vcpkg_install.bat`.\n>\n> Rather than requiring this step to be manual, detect the situation and\n> run it as part of the CMake configuration step.\n>\n> Note that this obviously only applies to the scenario when we want to\n> compile in Visual Studio (i.e. with MS Visual C), not with GCC.\n> Therefore, we guard this new code block behind the `MSVC` conditional.\n>\n> This concludes our journey to make it as effortless as possible to start\n> developing Git in Visual Studio: all the developer needs to do is to\n> clone Git's repository, open the worktree via `File>Open>Folder...` and\n> wait for CMake to finish configuring.\n>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> squash! cmake (Windows): initialize vcpkg/build dependencies automatically\n>\n> MSVC\n\nAaargh! This was of course meant to be deleted after rewording the commit\nmessage :-(\n\nSorry about that,\nDscho\n\n> ---\n>  contrib/buildsystems/CMakeLists.txt | 4 ++++\n>  1 file changed, 4 insertions(+)\n>\n> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> index 78b90abe5e..ebadae2271 100644\n> --- a/contrib/buildsystems/CMakeLists.txt\n> +++ b/contrib/buildsystems/CMakeLists.txt\n> @@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)\n>  set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n>  if(WIN32)\n>  \tset(VCPKG_DIR \"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg\")\n> +\tif(MSVC AND NOT EXISTS ${VCPKG_DIR})\n> +\t\tmessage(\"Initializing vcpkg and building the Git's dependencies (this will take a while...)\")\n> +\t\texecute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat)\n> +\tendif()\n>  \tlist(APPEND CMAKE_PREFIX_PATH \"${VCPKG_DIR}/installed/x64-windows\")\n>\n>  \t# In the vcpkg edition, we need this to be able to link to libcurl\n> --\n> gitgitgadget\n>\n>\n>\n"},{"id":"406731","messageId":"xmqqwo0aeuc0.fsf@gitster.c.googlers.com","threadId":"54295","inReplyTo":"nycvar.QRO.7.76.6.2009302117220.50@tvgsbejvaqbjf.bet","subject":"Re: [PATCH v4 08/10] cmake (Windows): initialize vcpkg/build dependencies automatically","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-09-30T23:08:31Z","receivedAt":"2020-09-30T23:09:02Z","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>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n>>\n>> squash! cmake (Windows): initialize vcpkg/build dependencies automatically\n>>\n>> MSVC\n>\n> Aaargh! This was of course meant to be deleted after rewording the commit\n> message :-(\n\nOK.  I noticed it and what got pushed out has them removed.\n\nHopefully we can merge this round down to 'next' after waiting for a\nday or two to see if anything new gets noticed.\n\nThanks.\n"}]}