From: Fabio Fantoni Subject: scripts/git-checkout.sh fails in some cases Date: Thu, 15 Oct 2015 15:40:36 +0200 Message-ID: <561FACD4.3020401@m2r.biz> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "xen-devel@lists.xen.org" Cc: Ian Jackson , Wei Liu , Ian Campbell List-Id: xen-devel@lists.xenproject.org I already saw scripts/git-checkout.sh fails many times changing repo and/or tag for my tests, for example today: > GIT=git > /mnt/vm/source/xen/Xen/tools/firmware/../../scripts/git-checkout.sh > git://xenbits.xen.org/osstest/ovmf.git xen-tested-master ovmf-dir > Cloning into 'ovmf-dir-remote.tmp'... > remote: Counting objects: 203149, done. > remote: Compressing objects: 100% (49944/49944), done. > remote: Total 203149 (delta 153028), reused 196420 (delta 146807) > Ricezione degli oggetti: 100% (203149/203149), 194.95 MiB | 527.00 > KiB/s, done. > Risoluzione dei delta: 100% (153028/153028), done. > Checking connectivity... fatto. > warning: l'HEAD remoto si riferisce ad un ref inesistente, impossibile > eseguire il checkout. > fatal: Cannot update paths and switch to branch 'dummy' at the same time. > Did you intend to checkout 'xen-tested-master' which can not be > resolved as commit? > Makefile:23: set di istruzioni per l'obiettivo "ovmf-dir" non riuscito > make[3]: *** [ovmf-dir] Errore 128 I not understand why use a dummy branch even if directory is a "temp." I tried a very fast change and worked: > #!/bin/sh > > if test $# -lt 3; then > echo "Usage: $0 " > exit 1 > fi > > TREE=$1 > TAG=$2 > DIR=$3 > > set -e > > if test \! -d $DIR-remote; then > rm -rf $DIR-remote $DIR-remote.tmp > mkdir -p $DIR-remote.tmp; rmdir $DIR-remote.tmp > if test "$TAG" ; then > $GIT clone -b $TAG $TREE $DIR-remote.tmp > else > $GIT clone $TREE $DIR-remote.tmp > fi > mv $DIR-remote.tmp $DIR-remote > fi > rm -f $DIR > ln -sf $DIR-remote $DIR But probably a better improvement/solution is needed for a good script working with any branch (its head) or tag. Thanks for any reply and sorry for my bad english.