build-system: avoid checkout when unneeded

Checkout only if current checked out version differs from
expected.

Signed-off-by: Murillo Bernardes <mfbernardes@gmail.com>
This commit is contained in:
Murillo Bernardes 2018-06-16 18:27:35 +02:00 committed by Dirk Hohndel
parent 550b6f179f
commit 7d92f5f811

View file

@ -38,10 +38,15 @@ git_checkout_library() {
fi
pushd "$name"
git fetch origin
if ! git checkout "$version" ; then
echo "Can't find the right tag in $name - giving up"
return -1
local current_sha=$(git rev-parse HEAD)
local target_sha=$(git rev-parse "$version")
if [ ! "$current_sha" = "$target_sha" ] ; then
git fetch origin
if ! git checkout "$version" ; then
echo "Can't find the right tag in $name - giving up"
return -1
fi
fi
popd
}