1. Switch local variables to lower-case and declare them local.

2. Cloning git trees from remote repos is often a very long operation.
Allow the user to specify a faster git cache as a prefix.

3. At the moment you can either check out a specific changeset or
"master", but you can't check out a different branch, because git
doesn't always look in origin/ for the branch.  If the initial git
checkout $tag fails, try checking out origin/$tag before giving up.

Signed-off-by: George Dunlap <george.dun...@eu.citrix.com>
---
CC: Stefano Stabellini <stefano.stabell...@citrix.com>
---
 defconfig           |  3 +++
 lib/git-checkout.sh | 33 ++++++++++++++++++++-------------
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/defconfig b/defconfig
index d3ef283..38c7455 100644
--- a/defconfig
+++ b/defconfig
@@ -35,3 +35,6 @@ QEMU_TRADITIONAL_REVISION="master"
 SEABIOS_REVISION="master"
 GRUB_REVISION="master"
 LIBVIRT_REVISION="master"
+
+# Git prefix.  Use this if you have a git caching proxy.
+#GIT_PREFIX=""
diff --git a/lib/git-checkout.sh b/lib/git-checkout.sh
index 2ca8f25..b033504 100755
--- a/lib/git-checkout.sh
+++ b/lib/git-checkout.sh
@@ -1,32 +1,39 @@
 #!/usr/bin/env bash
 
 function git-checkout() {
+    local tree
+    local tag
+    local dir
+
     if [[ $# -lt 3 ]]
     then
        echo "Usage: $0 <tree> <tag> <dir>"
        exit 1
     fi
 
-    TREE=$1
-    TAG=$2
-    DIR=$3
+    tree=$1
+    tag=$2
+    dir=$3
+
+    tree=${GIT_PREFIX}$tree
 
     set -e
 
-    if [[ ! -d $DIR-remote ]]
+    if [[ ! -d $dir-remote ]]
     then
-       rm -rf $DIR-remote $DIR-remote.tmp
-       mkdir -p $DIR-remote.tmp; rmdir $DIR-remote.tmp
-       $GIT clone $TREE $DIR-remote.tmp
-       if [[ "$TAG" ]]
+       rm -rf $dir-remote $dir-remote.tmp
+       mkdir -p $dir-remote.tmp; rmdir $dir-remote.tmp
+       $GIT clone $tree $dir-remote.tmp
+       if [[ "$tag" ]]
        then
-           cd $DIR-remote.tmp
+           cd $dir-remote.tmp
            $GIT branch -D dummy >/dev/null 2>&1 ||:
-           $GIT checkout -b dummy $TAG
+           $GIT checkout -b dummy $tag \
+               || $GIT checkout -b dummy origin/$tag
            cd ..
        fi
-       mv $DIR-remote.tmp $DIR-remote
+       mv $dir-remote.tmp $dir-remote
     fi
-    rm -f $DIR
-    ln -sf $DIR-remote $DIR
+    rm -f $dir
+    ln -sf $dir-remote $dir
 }
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to