All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] raisin: Some git-checkout improvements
@ 2015-04-21 17:16 George Dunlap
  2015-04-22 14:11 ` Stefano Stabellini
  0 siblings, 1 reply; 7+ messages in thread
From: George Dunlap @ 2015-04-21 17:16 UTC (permalink / raw)
  To: xen-devel; +Cc: George Dunlap, Stefano Stabellini

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.dunlap@eu.citrix.com>
---
CC: Stefano Stabellini <stefano.stabellini@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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-04-22 15:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-21 17:16 [PATCH] raisin: Some git-checkout improvements George Dunlap
2015-04-22 14:11 ` Stefano Stabellini
2015-04-22 14:43   ` George Dunlap
2015-04-22 14:54     ` Stefano Stabellini
2015-04-22 15:05       ` George Dunlap
2015-04-22 15:15         ` Stefano Stabellini
2015-04-22 15:29     ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.