Small bugfixes for http-push.c
[git.git] / git-clone.sh
index 7143131..4fdd652 100755 (executable)
@@ -53,7 +53,11 @@ Perhaps git-update-server-info needs to be run there?"
        while read sha1 refname
        do
                name=`expr "$refname" : 'refs/\(.*\)'` &&
-               git-http-fetch -v -a -w "$name" "$name" "$1/" || exit 1
+               case "$name" in
+               *^*)    ;;
+               *)
+                       git-http-fetch -v -a -w "$name" "$name" "$1/" || exit 1
+               esac
        done <"$clone_tmp/refs"
        rm -fr "$clone_tmp"
 }
@@ -122,8 +126,7 @@ yes,yes)
            fi &&
            rm -f "$D/.git/objects/sample" &&
            cd "$repo" &&
-           find objects -type f -print |
-           cpio -puamd$l "$D/.git/" || exit 1
+           find objects -depth -print | cpio -puamd$l "$D/.git/" || exit 1
            ;;
        yes)
            mkdir -p "$D/.git/objects/info"
@@ -192,10 +195,25 @@ 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 &&
+               find .git/refs/heads -type f -print |
+               while read ref
+               do
+                       head=`expr "$ref" : '.git/refs/heads/\(.*\)'` &&
+                       test "$head_points_at" = "$head" ||
+                       test "origin" = "$head" ||
+                       echo "Pull: ${head}:${head}"
+               done >>.git/remotes/origin
+       esac
+
        case "$no_checkout" in
        '')
                git checkout