FetchContent GIT_SHALLOW fetches more than just GIT_TAG specified
Currently GIT_SHALLOW option makes FetchContent add --depth=1 --no-single-branch
and the latter part is what makes it fetch all refs, which is pretty much not what shallow copy is.
Quote from Github blog:
Shallow clones use the --depth= parameter in git clone to truncate the commit history. Typically, --depth=1 signifies that we only care about the most recent commits. Shallow clones are best combined with the --single-branch --branch= options as well, to ensure we only download the data for the commit we plan to use immediately.
Easy to see in following experiment. Clone single tag with --depth=1 --no-single-branch
from curl pulls 28MiB:
$ git clone --depth=1 --no-single-branch --branch=curl-7_83_1 https://github.com/curl/curl curl.full
...
Receiving objects: 100% (45986/45986), 28.69 MiB | 291.00 KiB/s, done.
Same tag, but with --single-branch
pulls 3.8MiB:
git clone --depth=1 --single-branch --branch=curl-7_83_1 https://github.com/curl/curl curl.shallow
...
Receiving objects: 100% (3527/3527), 3.87 MiB | 197.00 KiB/s, done.
Edited by Maxim Ivanov