From c89cc267d6b8b3b62db94ee9536c7e6264aeb810 Mon Sep 17 00:00:00 2001 From: BytesGalore Date: Wed, 4 Jan 2017 17:10:48 +0100 Subject: [PATCH] git-cache: consider if git_cache dir is present --- git-cache | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/git-cache b/git-cache index f876489..6dc5f3e 100755 --- a/git-cache +++ b/git-cache @@ -72,7 +72,11 @@ drop() { } _check_commit() { - git_cache cat-file -e ${1}^{commit} + if [ -d "${GIT_CACHE_DIR}" ]; then + git_cache cat-file -e ${1}^{commit} + else + false + fi } _remote_name() { @@ -98,7 +102,7 @@ clone() { git_cache tag commit$SHA1 $SHA1 || true # ignore possibly already existing tag git clone --reference "${GIT_CACHE_DIR}" "${GIT_CACHE_DIR}" "${TARGET_PATH}" --branch commit$SHA1 else - git clone --reference "${GIT_CACHE_DIR}" "${REMOTE}" "${TARGET_PATH}" + git clone "${REMOTE}" "${TARGET_PATH}" git -C "${TARGET_PATH}" checkout $SHA1 fi set +e