Fix "git fetch" lines to work in "detached head" state

This commit is contained in:
Tianon Gravi 2014-10-03 11:45:34 -06:00
parent 824cb8004f
commit dc633d25ba
1 changed files with 9 additions and 2 deletions

View File

@ -183,8 +183,15 @@ for repoTag in "${repos[@]}"; do
echo 'Cloned successfully!'
else
# if we don't have the "ref" specified, "git fetch" in the hopes that we get it
if ! ( cd "$gitRepo" && git rev-parse --verify "${gitRef}^{commit}" &> /dev/null ); then
( cd "$gitRepo" && git fetch -q && git fetch -q --tags )
if ! (
cd "$gitRepo"
git rev-parse --verify "${gitRef}^{commit}" &> /dev/null
); then
(
cd "$gitRepo"
git fetch -q --all
git fetch -q --tags
)
fi
fi