GITFLAGS="--depth=1" makepkg should work for other branches
depth=1 works if the source is in the default branch. if not, it anyway checks out the default branch.
❯ grep source PKGBUILD
source=( git+https://github.com/apple/llvm-project#branch=swift/main )
❯ GITFLAGS="--depth=1" bash -x makepkg --syncdeps
...
+ printf ' -> Cloning %s %s repo...\n' llvm-project git
-> Cloning llvm-project git repo...
+ git clone --depth=1 https://github.com/apple/llvm-project /src/swift-llvm-git/llvm-project
Cloning into '/src/swift-llvm-git/llvm-project'...
a first MR which is no change yet, just moving the fragments earlier, to use them then, is here: !56 (diffs)