git.bzl: fall back to full clone if shallow options are not supported

The `--shallow-since` option of git was introduced only in version 2.11 of git. However,
some widely used distributions ship older versions of git. So fall back to fully cloning
or fetching a repository if the respective shallow option is not know to the ambient git
command used.

Change-Id: I8f0aa0a12e294ff9cc8325975bd9333f6bf50939
PiperOrigin-RevId: 197863797
diff --git a/tools/build_defs/repo/git.bzl b/tools/build_defs/repo/git.bzl
index 22026e8..c522956 100644
--- a/tools/build_defs/repo/git.bzl
+++ b/tools/build_defs/repo/git.bzl
@@ -46,10 +46,10 @@
 ( cd {working_dir} &&
     if ! ( cd '{dir_link}' && [[ "$(git rev-parse --git-dir)" == '.git' ]] ) >/dev/null 2>&1; then
       rm -rf '{directory}' '{dir_link}'
-      git clone {shallow} '{remote}' '{directory}'
+      git clone {shallow} '{remote}' '{directory}' || git clone '{remote}' '{directory}'
     fi
     cd '{directory}'
-    git reset --hard {ref} || (git fetch {shallow} origin {ref}:{ref} && git reset --hard {ref})
+    git reset --hard {ref} || ((git fetch {shallow} origin {ref}:{ref} || git fetch origin {ref}:{ref}) && git reset --hard {ref})
     git clean -xdf )
   """.format(
       working_dir=ctx.path('.').dirname,