git-clone: do not forget to create origin branch.
authorJunio C Hamano <junkio@cox.net>
Wed, 2 Nov 2005 06:19:36 +0000 (22:19 -0800)
committerJunio C Hamano <junkio@cox.net>
Wed, 2 Nov 2005 06:19:36 +0000 (22:19 -0800)
The newly cloned repository by default had .git/remotes/origin
set up to track the remote master to origin, but forgot to
create the origin branch ourselves.  Also it hardcoded the
assumption that the remote HEAD points at "master", which may
not always be true.

Signed-off-by: Junio C Hamano <junkio@cox.net>
git-clone.sh

index 18e692a67b1515c57a20c8574ed53836fb53f2bd..c27a913b1ddf1474df4300dc68bebeeb06f145f1 100755 (executable)
@@ -196,10 +196,17 @@ cd $D || exit
 
 if test -f ".git/HEAD"
 then
-       mkdir -p .git/remotes || exit
-       echo >.git/remotes/origin \
-       "URL: $repo
-Pull: master:origin"
+       head_points_at=`git-symbolic-ref HEAD`
+       case "$head_points_at" in
+       refs/heads/*)
+               head_points_at=`expr "$head_points_at" : 'refs/heads/\(.*\)'`
+               mkdir -p .git/remotes &&
+               echo >.git/remotes/origin \
+               "URL: $repo
+Pull: $head_points_at:origin"
+               cp ".git/refs/heads/$head_points_at" .git/refs/heads/origin
+       esac
+
        case "$no_checkout" in
        '')
                git checkout