In arch linux - How to modify a PKGBUILD which uses git sources to pull only a shallow clone? - Unix & Linux Stack Exchange, the questioner asks how to make makepkg clone only the relevant commit needed to build the package, instead of the whole git history.
Starting from git 2.49.0, it is technically possible to git clone a single commit. However, there is an additional difficulty.
In summary, some package's PKGBUILD contains git describe command. For this to work, you need to fetch until the nearest tag.
Originally, /usr/share/makepkg/source/git.sh contains download_git and extract_git shell functions.