ExternalProject-gitupdate.cmake broken on Windows?
Since upgrading to cmake 3.20.3, I'm getting errors with projects that use ExternalProject-gitupdate.cmake. The exact error is from project expected, see https://github.com/TartanLlama/expected/issues/86 for the problem:
[...]
Your branch is up to date with 'origin/master'.
[2/9] cmd.exe /C "cd /D C:\data\Debug\expected\_deps\tl_cmake-src && C:\data\Tools\bin\cmake.exe -P C:/data/Debug/expected/_deps/tl_cmake-subbuild/tl_cmake-populate-prefix/tmp/tl_cmake-populate-gitupdate.cmake"
CMake Error at C:/data/Debug/expected/_deps/tl_cmake-subbuild/tl_cmake-populate-prefix/tmp/tl_cmake-populate-gitupdate.cmake:25 (message):
  Failed to get the hash for HEAD:
  fatal: ambiguous argument 'HEAD^commit': unknown revision or path not in
  the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'
FAILED: tl_cmake-populate-prefix/src/tl_cmake-populate-stamp/tl_cmake-populate-update 
cmd.exe /C "cd /D C:\data\Debug\expected\_deps\tl_cmake-src && C:\data\Tools\bin\cmake.exe -P C:/data/Debug/expected/_deps/tl_cmake-subbuild/tl_cmake-populate-prefix/tmp/tl_cmake-populate-gitupdate.cmake"
ninja: build stopped: subcommand failed.
CMake Error at C:/data/Tools/share/cmake-3.20/Modules/FetchContent.cmake:1012 (message):
  Build step for tl_cmake failed: 1
Call Stack (most recent call first):
  C:/data/Tools/share/cmake-3.20/Modules/FetchContent.cmake:1141:EVAL:2 (__FetchContent_directPopulate)
  C:/data/Tools/share/cmake-3.20/Modules/FetchContent.cmake:1141 (cmake_language)
  CMakeLists.txt:14 (FetchContent_Populate)
-- Configuring incomplete, errors occurred!I'm under the impression that this issue was caused when closing #22166 (closed) with !6109 (merged).
For some reason, the curly braces around {commit} are not passed to git, so instead of rev-parse "${ref}^{commit}" it will see rev-parse "${ref}^commit" which causes the above error. I've tested that removing ^{commit} solves the issue for us (but this is not a clean solution).
This problem only happens on Windows. Linux and MacOSX build the same project fine. It may be relevant that we are using cmake inside a CI that employs git from Cygwin?