Browse code

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

Sean Dague authored on 2014/03/13 02:04:22
Showing 1 changed files
... ...
@@ -517,12 +517,14 @@ function git_clone {
517 517
     GIT_DEST=$2
518 518
     GIT_REF=$3
519 519
     RECLONE=$(trueorfalse False $RECLONE)
520
+    local orig_dir=`pwd`
520 521
 
521 522
     if [[ "$OFFLINE" = "True" ]]; then
522 523
         echo "Running in offline mode, clones already exist"
523 524
         # print out the results so we know what change was used in the logs
524 525
         cd $GIT_DEST
525 526
         git show --oneline | head -1
527
+        cd $orig_dir
526 528
         return
527 529
     fi
528 530
 
... ...
@@ -572,6 +574,7 @@ function git_clone {
572 572
     # print out the results so we know what change was used in the logs
573 573
     cd $GIT_DEST
574 574
     git show --oneline | head -1
575
+    cd $orig_dir
575 576
 }
576 577
 
577 578
 # git can sometimes get itself infinitely stuck with transient network