fix(cmake): don't use GIT_SHALLOW when a dependency is pinned to a commit#2146
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the CMake helper macro to conditionally enable shallow cloning only when the Git tag is not a commit hash, avoiding checkout failures. The feedback recommends quoting the variable in the CMake conditional check to prevent syntax errors if the variable is empty or contains special characters.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| # défaut ; si GIT_TAG est un hash de commit qui n'en est pas le sommet, | ||
| # le checkout échoue ("unable to read tree"). On ne l'active donc que | ||
| # pour les tags/branches nommés, pas pour les commits épinglés. | ||
| if(NOT _D_GIT_TAG MATCHES "^[0-9a-fA-F]+$") |
There was a problem hiding this comment.
In CMake, it is highly recommended to quote variables in if conditions when using MATCHES. If _D_GIT_TAG is empty, undefined, or contains special characters (such as spaces, semicolons, or parentheses), an unquoted variable expansion can lead to syntax errors or unexpected behavior during the CMake configuration step. Quoting it as "${_D_GIT_TAG}" ensures it is always safely evaluated as a single string.
if(NOT "${_D_GIT_TAG}" MATCHES "^[0-9a-fA-F]+$")
65c5371 to
fbbd39d
Compare
|
GIT_SHALLOW fetches only the default-branch tip, so a GIT_TAG that is a
commit hash not at that tip fails to check out ("unable to read tree").
This broke popsift and cctag. Enable GIT_SHALLOW only for named refs.
Regression introduced in 634581f.
fbbd39d to
3596651
Compare



Problem
av_add_cmake_dep(insrc/cmake/Helpers.cmake) enabledGIT_SHALLOW TRUEfor every git dependency.
A shallow clone (
git clone --depth 1) only fetches the tip of the remote'sdefault branch. When
GIT_TAGis a commit hash that is not that tip, thesubsequent checkout fails:
The commit is not actually missing — it is fetchable — but the shallow clone
never downloads it, so the checkout cannot find it.
Impact
This breaks
ALICEVISION_BUILD_DEPENDENCIESfor any dependency pinned to acommit that is not the default-branch tip. Concretely, the dependency build
fails on popsift and cctag. Dependencies pinned to a hash that happens
to be the default-branch tip only built by luck.
Dependencies referenced by a named branch/tag (
v4.5.1,main, …) areunaffected.
Fix
Enable
GIT_SHALLOWonly whenGIT_TAGis a named branch/tag, not a rawcommit hash:
Notes
Regression introduced in
634581fb4("modernize Docker/CMake infrastructure"),which added the unconditional
GIT_SHALLOW TRUE.Verified by a full
ALICEVISION_BUILD_DEPENDENCIESDocker build (Rocky 9 +CUDA 12.1.1): with this change, popsift and cctag clone and build correctly,
and the whole dependency set builds to completion.