Bug 1378676 - Ensure that git-copy doesn't run every time, r=franziskus
authorMartin Thomson <martin.thomson@gmail.com>
Fri, 07 Jul 2017 09:21:18 +1000
changeset 13454 a6a5cf93a21e41c6d506708fde4f0791bee51b2e
parent 13452 7a6a93296c5294c9f32bf25e98ed12ccd5294940
child 13455 8d372f660ce9a611940d2ae4182568668de3935d
push id2265
push usermartin.thomson@gmail.com
push dateThu, 06 Jul 2017 23:21:33 +0000
reviewersfranziskus
bugs1378676
Bug 1378676 - Ensure that git-copy doesn't run every time, r=franziskus
fuzz/config/git-copy.sh
--- a/fuzz/config/git-copy.sh
+++ b/fuzz/config/git-copy.sh
@@ -1,32 +1,33 @@
-#!/bin/sh
+#!/usr/bin/env bash
 
 set -e
 
 if [ $# -lt 3 ]; then
   echo "Usage: $0 <repo> <branch> <directory>" 1>&2
   exit 2
 fi
 
 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
+    # On the off chance that $COMMIT is a remote head.
     ACTUAL=$(git ls-remote $REPO $COMMIT | cut -c 1-40 -)
   else
     ACTUAL=$COMMIT
   fi
-  if [ CURRENT = ACTUAL ]; then
+  if [ "$CURRENT" = "$ACTUAL" ]; then
     echo "Up to date."
+    exit
   fi
 fi
 
-mkdir -p $DIR
-git -C $DIR init -q
+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 show-ref HEAD | cut -c 1-40 - > $DIR/.git-copy
+git -C $DIR rev-parse --verify HEAD > $DIR/.git-copy
 rm -rf $DIR/.git