]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Work around using shallow-since if not available
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 19 May 2018 12:46:20 +0000 (14:46 +0200)
committerMatthias Maier <tamiko@43-1.org>
Sat, 19 May 2018 14:18:35 +0000 (09:18 -0500)
contrib/utilities/compile_clang_format

index 120edf99d64a924f91e2adcae25172167268692c..f3920ad55cbcbba4440b9df539d5e140ed12214c 100755 (executable)
@@ -57,15 +57,41 @@ tmpdir="${TMPDIR:-/tmp}/dealiiclang${RANDOM}${RANDOM}"
 mkdir -p "${tmpdir}"
 cd "${tmpdir}"
 
+GIT_VERSION=$(git version)
+GIT_MAJOR_VERSION=$(echo "${GIT_VERSION}" | sed 's/^[^0-9]*\([0-9]*\).*$/\1/g')
+GIT_MINOR_VERSION=$(echo "${GIT_VERSION}" | sed 's/^[^0-9]*[0-9]*\.\([0-9]*\).*$/\1/g')
+
+if [ "$GIT_MAJOR_VERSION" -ge 2 ] && [ "$GIT_MINOR_VERSION" -ge 11 ]; then
+  GIT_SHALLOW_SINCE_AVAILABLE=true
+else
+  GIT_SHALLOW_SINCE_AVAILABLE=false
+fi
+
 git init
 git remote add origin "${LLVM_REPOSITORY}"
-git fetch --shallow-since="${RELEASE_DATE}" origin "${RELEASE_BRANCH}"
+if [ "$GIT_SHALLOW_SINCE_AVAILABLE" = true ]; then
+  git fetch --shallow-since="${RELEASE_DATE}" origin "${RELEASE_BRANCH}"
+else
+  git fetch --depth=1 origin "${RELEASE_BRANCH}"
+  i=1;
+  while ! git cat-file -e ${LLVM_COMMIT} 2> /dev/null; do
+    git fetch --depth=$((i+=10)) origin "${RELEASE_BRANCH}";
+  done
+fi
 git reset --hard "${LLVM_COMMIT}"
 
 git init tools/clang
 cd tools/clang
 git remote add origin "${CLANG_REPOSITORY}"
-git fetch --shallow-since="${RELEASE_DATE}" origin "${RELEASE_BRANCH}"
+if [ "$GIT_SHALLOW_SINCE_AVAILABLE" = true ]; then
+  git fetch --shallow-since="${RELEASE_DATE}" origin "${RELEASE_BRANCH}"
+else
+  git fetch --depth=1 origin "${RELEASE_BRANCH}"
+  i=1;
+  while ! git cat-file -e ${CLANG_COMMIT} 2> /dev/null; do
+    git fetch --depth=$((i+=10)) origin "${RELEASE_BRANCH}";
+  done
+fi
 git reset --hard "${CLANG_COMMIT}"
 
 cd ../../

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.