]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
use shorthash to avoid race when using a branch name
authorMark Andrews <marka@isc.org>
Thu, 24 Mar 2016 01:58:18 +0000 (12:58 +1100)
committerMark Andrews <marka@isc.org>
Thu, 24 Mar 2016 01:58:18 +0000 (12:58 +1100)
util/kit.sh

index 1ab9b14976bc67f6424bcb1e7ebebf1502ee1539..b7adb0a8d0112657752cad15df11256def5d9c3e 100644 (file)
@@ -77,12 +77,21 @@ cd $tmpdir || {
        exit 1
 }
 
+shorthash=`git ls-remote $repo refs/heads/$tag | cut -c1-7`
+if [ -z "$shorthash" ]; then
+        shorthash=`git ls-remote $repo refs/tags/$tag | cut -c1-7`
+fi
+if [ -z "$shorthash" ]; then
+        echo "Unable to determine hash for $tag, aborting."
+        exit 1
+fi
+
 verdir=bind9-kit.$$
 mkdir $verdir || {
     echo "$0: could not create directory $tmpdir/$verdir" >&2
     exit 1
 }
-git archive --format=tar $remote $tag version | ( cd $verdir ;tar xf - )
+git archive --format=tar $remote $shorthash version | ( cd $verdir ;tar xf - )
 test -f $verdir/version || {
     echo "$0: could not get 'version' file" >&2
     exit 1
@@ -92,15 +101,6 @@ test -f $verdir/version || {
 rm $verdir/version
 rmdir $verdir
 
-shorthash=`git ls-remote $repo refs/heads/$tag | cut -c1-7`
-if [ -z "$shorthash" ]; then
-        shorthash=`git ls-remote $repo refs/tags/$tag | cut -c1-7`
-fi
-if [ -z "$shorthash" ]; then
-        echo "Unable to determine hash for $tag, aborting."
-        exit 1
-fi
-
 if $snapshot
 then
     RELEASETYPE=s
@@ -120,7 +120,7 @@ test ! -d $topdir || {
 
 mkdir $topdir || exit 1
 
-git archive --format=tar $remote $tag | ( cd $topdir; tar xf -)
+git archive --format=tar $remote $shorthash | ( cd $topdir; tar xf -)
 
 cd $topdir || exit 1