From: Daniel Arndt Date: Sat, 19 May 2018 12:46:20 +0000 (+0200) Subject: Work around using shallow-since if not available X-Git-Tag: v9.1.0-rc1~1126^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1f705fdbccef9db39341999445eb4bfb6584b9f;p=dealii.git Work around using shallow-since if not available --- diff --git a/contrib/utilities/compile_clang_format b/contrib/utilities/compile_clang_format index 120edf99d6..f3920ad55c 100755 --- a/contrib/utilities/compile_clang_format +++ b/contrib/utilities/compile_clang_format @@ -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 ../../