./all: checkout with no arg checks out the default branch
authorRudolf Polzer <divverent@alientrap.org>
Sat, 15 May 2010 20:59:07 +0000 (22:59 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Sat, 15 May 2010 20:59:07 +0000 (22:59 +0200)
all

diff --git a/all b/all
index 93578fc8bb32a1d1effe41d7b89c746da7100752..bdb93f26f2bc7025cc16a02acbc47cf49979e561 100755 (executable)
--- a/all
+++ b/all
@@ -252,12 +252,17 @@ case "$cmd" in
                exists=false
                for d in $repos; do
                        enter "$d0/$d" verbose
-                       if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
+                       if [ -z "$branch" ]; then
+                               b=`repobranch "$d"`
+                       else
+                               b=$branch
+                       fi
+                       if git rev-parse "refs/heads/$b" >/dev/null 2>&1; then
                                exists=true
-                               verbose git checkout "$branch"
-                       elif git rev-parse "refs/remotes/$remote/$branch" >/dev/null 2>&1; then
+                               verbose git checkout "$b"
+                       elif git rev-parse "refs/remotes/$remote/$b" >/dev/null 2>&1; then
                                exists=true
-                               verbose git checkout --track -b "$branch" "$remote/$branch"
+                               verbose git checkout --track -b "$b" "$remote/$b"
                        else
                                verbose git checkout "`repobranch "$d"`"
                        fi