From 7d92f5f8115b53fdca918f847d863ef3701976d1 Mon Sep 17 00:00:00 2001 From: Murillo Bernardes Date: Sat, 16 Jun 2018 18:27:35 +0200 Subject: build-system: avoid checkout when unneeded Checkout only if current checked out version differs from expected. Signed-off-by: Murillo Bernardes --- scripts/get-dep-lib.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/get-dep-lib.sh b/scripts/get-dep-lib.sh index c951ec813..970569c6c 100755 --- a/scripts/get-dep-lib.sh +++ b/scripts/get-dep-lib.sh @@ -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 } -- cgit v1.2.3-70-g09d2