# GIT\_SHALLOW 1 should turn off automatically when GIT\_TAG is a hash in ExternalProject\_Add()

**URL:** https://discourse.cmake.org/t/git-shallow-1-should-turn-off-automatically-when-git-tag-is-a-hash-in-externalproject-add/10121
**Category:** Development
**Created:** [February 17, 2024, 7:56am UTC](https://discourse.cmake.org/t/git-shallow-1-should-turn-off-automatically-when-git-tag-is-a-hash-in-externalproject-add/10121 "2024-02-17T07:56:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Gonzalo\_Garramuno](https://discourse.cmake.org/user_avatar/discourse.cmake.org/gonzalo_garramuno/32/265_2.png) [@Gonzalo\_Garramuno](https://discourse.cmake.org/u/Gonzalo_Garramuno)
#### Post date: [February 17, 2024, 7:56am UTC](https://discourse.cmake.org/t/git-shallow-1-should-turn-off-automatically-when-git-tag-is-a-hash-in-externalproject-add/10121/1 "2024-02-17T07:56:31Z")

</div>

Using cmake 3.26.5, so this might have already changed.

ExternalProject\_Add(  
PROJECT  
GIT\_REPOSITORY …  
GIT\_TAG 2e34234  
GIT\_SHALLOW 1  
)

The above command will fail when the git tag is a hash, but it will succeed when the git tag is a branch. Cmake should be smart to detect that the tag is a hash and turn off git shallow automatically.

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [February 17, 2024, 11:49am UTC](https://discourse.cmake.org/t/git-shallow-1-should-turn-off-automatically-when-git-tag-is-a-hash-in-externalproject-add/10121/2 "2024-02-17T11:49:49Z")

</div>

Just curious: isn’t that rather a git bug?

How should CMake know that this is not your branch name?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 18, 2024, 3:05am UTC](https://discourse.cmake.org/t/git-shallow-1-should-turn-off-automatically-when-git-tag-is-a-hash-in-externalproject-add/10121/3 "2024-02-18T03:05:31Z")

</div>

Indeed; CMake has no idea how Git might interpret any given string. We might be able to _guess_, but it is better for this to be something specified at the call site directly.
