Bug 1388986 - Cleanup cloned projects before updating them, r=franziskus
authorMartin Thomson <martin.thomson@gmail.com>
Thu, 10 Aug 2017 15:49:32 +1000
changeset 13522 3e81bdac84491be5f6378bc2e7d08322350deddb
parent 13521 a719422c756d5842d19f354c357017bbff260c2c
child 13523 990be4e30bf8a5f5619e0e6630ef7cc0784905fb
push id2316
push usermartin.thomson@gmail.com
push dateThu, 10 Aug 2017 06:17:19 +0000
reviewersfranziskus
bugs1388986
Bug 1388986 - Cleanup cloned projects before updating them, r=franziskus
fuzz/config/git-copy.sh
--- a/fuzz/config/git-copy.sh
+++ b/fuzz/config/git-copy.sh
@@ -2,32 +2,33 @@
 
 set -e
 
 if [ $# -lt 3 ]; then
   echo "Usage: $0 <repo> <branch> <directory>" 1>&2
   exit 2
 fi
 
-REPO=$1
-COMMIT=$2
-DIR=$3
+REPO="$1"
+COMMIT="$2"
+DIR="$3"
 
 echo "Copy '$COMMIT' from '$REPO' to '$DIR'"
-if [ -f $DIR/.git-copy ]; then
-  CURRENT=$(cat $DIR/.git-copy)
-  if [ $(echo -n $COMMIT | wc -c) != "40" ]; then
+if [ -f "$DIR"/.git-copy ]; then
+  CURRENT=$(cat "$DIR"/.git-copy)
+  if [ $(echo -n "$COMMIT" | wc -c) != "40" ]; then
     # On the off chance that $COMMIT is a remote head.
-    ACTUAL=$(git ls-remote $REPO $COMMIT | cut -c 1-40 -)
+    ACTUAL=$(git ls-remote "$REPO" "$COMMIT" | cut -c 1-40 -)
   else
-    ACTUAL=$COMMIT
+    ACTUAL="$COMMIT"
   fi
   if [ "$CURRENT" = "$ACTUAL" ]; then
     echo "Up to date."
     exit
   fi
 fi
 
-git init -q $DIR
-git -C $DIR fetch -q --depth=1 $REPO $COMMIT:git-copy-tmp
-git -C $DIR reset --hard git-copy-tmp
-git -C $DIR rev-parse --verify HEAD > $DIR/.git-copy
-rm -rf $DIR/.git
+rm -rf "$DIR"
+git init -q "$DIR"
+git -C "$DIR" fetch -q --depth=1 "$REPO" "$COMMIT":git-copy-tmp
+git -C "$DIR" reset --hard git-copy-tmp
+git -C "$DIR" rev-parse --verify HEAD > "$DIR"/.git-copy
+rm -rf "$DIR"/.git