Skip to content

ci: fix git version detection in the MSYS2 Windows job - #552

Merged
Sapd merged 1 commit into
masterfrom
fix-windows-git-version
Jul 30, 2026
Merged

ci: fix git version detection in the MSYS2 Windows job#552
Sapd merged 1 commit into
masterfrom
fix-windows-git-version

Conversation

@Sapd

@Sapd Sapd commented Jul 30, 2026

Copy link
Copy Markdown
Owner

The Windows build has been reporting 0.0.0-unknown, for two independent reasons. Both are verified on a real Windows 11 + MSYS2 MINGW64 box.

  1. The MSYS2 shell has no git at all. It is not part of base-devel, and the shell does not inherit Git for Windows from the runner PATH (confirmed: no "/Program Files/Git" entry in the MINGW64 PATH). So every git call in CMakeLists.txt failed. Fixed by installing the git package alongside the toolchain.

  2. Once git is available, the --show-toplevel guard added in Fix Git version detection when embedded #551 would still reject every Windows build, permanently pinning it to 0.0.0-unknown. MSYS2 git reports POSIX paths while CMake reports Windows ones, and get_filename_component(REALPATH) does not reconcile them:

    PROJECT_SOURCE_DIR = C:/Users/Denis/hc-vtest/probe/sub
    git --show-toplevel = /c/Users/Denis/hc-vtest/probe/sub

    so the STREQUAL can never match. Replaced with --show-prefix, which is empty exactly when the source dir is the root of a work tree. That is a plain string test needing no path normalisation, and it drops both REALPATH calls.

Measured on Windows with the same package set as CI: the old guard yields 0.0.0-unknown, the new one yields 4.0.0-11-g00ca695, a vendored copy correctly falls back to 0.0.0-unknown, and build + ctest pass.

Both reject paths now explain themselves and point at -DHEADSETCONTROL_VERSION. Also renames the reused GIT_RESULT to GIT_DESCRIBE_RESULT.

The Windows build has been reporting 0.0.0-unknown, for two independent
reasons. Both are verified on a real Windows 11 + MSYS2 MINGW64 box.

1. The MSYS2 shell has no git at all. It is not part of base-devel, and
   the shell does not inherit Git for Windows from the runner PATH
   (confirmed: no "/Program Files/Git" entry in the MINGW64 PATH). So
   every git call in CMakeLists.txt failed. Fixed by installing the git
   package alongside the toolchain.

2. Once git is available, the --show-toplevel guard added in #551 would
   still reject every Windows build, permanently pinning it to
   0.0.0-unknown. MSYS2 git reports POSIX paths while CMake reports
   Windows ones, and get_filename_component(REALPATH) does not reconcile
   them:

     PROJECT_SOURCE_DIR  = C:/Users/Denis/hc-vtest/probe/sub
     git --show-toplevel = /c/Users/Denis/hc-vtest/probe/sub

   so the STREQUAL can never match. Replaced with --show-prefix, which is
   empty exactly when the source dir is the root of a work tree. That is a
   plain string test needing no path normalisation, and it drops both
   REALPATH calls.

Measured on Windows with the same package set as CI: the old guard yields
0.0.0-unknown, the new one yields 4.0.0-11-g00ca695, a vendored copy
correctly falls back to 0.0.0-unknown, and build + ctest pass.

Both reject paths now explain themselves and point at
-DHEADSETCONTROL_VERSION. Also renames the reused GIT_RESULT to
GIT_DESCRIBE_RESULT.
@Sapd
Sapd merged commit ca2f7f0 into master Jul 30, 2026
5 checks passed
@claude

claude Bot commented Jul 30, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant