@matheusbsbs / matheus-bagliano / commits / e125c1a717
Fork 0

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 <junkio@cox.net>

Junio C Hamano committed Nov 1, 2005 at 22:19 UTC e125c1a717bb732319596d8b792a67c2b7b15ef7
1 file changed +11 -4
git-clone.sh
+11 -4
@@ -196,10 +196,17 @@ cd $D || exit
196
197 if test -f ".git/HEAD"
198 then
199 - mkdir -p .git/remotes || exit
200 - echo >.git/remotes/origin \
201 - "URL: $repo
202 -Pull: master:origin"
199 + head_points_at=`git-symbolic-ref HEAD`
200 + case "$head_points_at" in
201 + refs/heads/*)
202 + head_points_at=`expr "$head_points_at" : 'refs/heads/\(.*\)'`
203 + mkdir -p .git/remotes &&
204 + echo >.git/remotes/origin \
205 + "URL: $repo
206 +Pull: $head_points_at:origin"
207 + cp ".git/refs/heads/$head_points_at" .git/refs/heads/origin
208 + esac
209 +
210 case "$no_checkout" in
211 '')
212 git checkout