From: Junio C Hamano Date: Wed, 2 Nov 2005 06:19:36 +0000 (-0800) Subject: git-clone: do not forget to create origin branch. X-Git-Tag: v0.99.9c^2~13 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e125c1a717bb732319596d8b792a67c2b7b15ef7;p=git.git git-clone: do not forget to create origin branch. 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 --- diff --git a/git-clone.sh b/git-clone.sh index 18e692a67..c27a913b1 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -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