make git_clone safer

the ensures that if the function returns early, we return to a
sane directory, and not hang out somewhere that a future git
call might modify a directory in a weird way. This is especially
important in the case of stable branches where were are hopping
between stable for servers and master for clients.

Change-Id: Ib8ebbc23b1813bc1bfb31d0a079f1b882135bd39
This commit is contained in:
Sean Dague 2014-03-12 13:04:22 -04:00
parent 63d06bcad9
commit 64bd01652e
1 changed files with 3 additions and 0 deletions

View File

@ -517,12 +517,14 @@ function git_clone {
GIT_DEST=$2
GIT_REF=$3
RECLONE=$(trueorfalse False $RECLONE)
local orig_dir=`pwd`
if [[ "$OFFLINE" = "True" ]]; then
echo "Running in offline mode, clones already exist"
# print out the results so we know what change was used in the logs
cd $GIT_DEST
git show --oneline | head -1
cd $orig_dir
return
fi
@ -572,6 +574,7 @@ function git_clone {
# print out the results so we know what change was used in the logs
cd $GIT_DEST
git show --oneline | head -1
cd $orig_dir
}
# git can sometimes get itself infinitely stuck with transient network