X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-clone.sh;h=377d59e62cecd305fc7cf69aa927b13225fdb3eb;hb=4dc00021f784697e6d196ec285c8689d0777c533;hp=e49028f684ffe2fd50012759f54475f0db7b4d68;hpb=0a8b4def9ae9e929a3310b536782a80a7c7644e7;p=git.git diff --git a/git-clone.sh b/git-clone.sh index e49028f6..377d59e6 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -9,7 +9,7 @@ unset CDPATH usage() { - echo >&2 "* git clone [-l [-s]] [-q] [-u ] [-n] []" + echo >&2 "Usage: $0 [-l [-s]] [-q] [-u ] [-o ] [-n] []" exit 1 } @@ -31,25 +31,11 @@ clone_dumb_http () { cd "$2" && clone_tmp='.git/clone-tmp' && mkdir -p "$clone_tmp" || exit 1 - http_fetch "$1/info/refs" "$clone_tmp/refs" && - http_fetch "$1/objects/info/packs" "$clone_tmp/packs" || { + http_fetch "$1/info/refs" "$clone_tmp/refs" || { echo >&2 "Cannot get remote repository information. Perhaps git-update-server-info needs to be run there?" exit 1; } - while read type name - do - case "$type" in - P) ;; - *) continue ;; - esac && - - idx=`expr "$name" : '\(.*\)\.pack'`.idx - http_fetch "$1/objects/pack/$name" ".git/objects/pack/$name" && - http_fetch "$1/objects/pack/$idx" ".git/objects/pack/$idx" && - git-verify-pack ".git/objects/pack/$idx" || exit 1 - done <"$clone_tmp/packs" - while read sha1 refname do name=`expr "$refname" : 'refs/\(.*\)'` && @@ -67,6 +53,7 @@ use_local=no local_shared=no no_checkout= upload_pack= +origin=origin while case "$#,$1" in 0,*) break ;; @@ -75,6 +62,14 @@ while *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) local_shared=yes; use_local=yes ;; *,-q|*,--quiet) quiet=-q ;; + 1,-o) usage;; + *,-o) + git-check-ref-format "$2" || { + echo >&2 "'$2' is not suitable for a branch name" + exit 1 + } + origin="$2"; shift + ;; 1,-u|1,--upload-pack) usage ;; *,-u|*,--upload-pack) shift @@ -208,14 +203,14 @@ then 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 && +Pull: $head_points_at:$origin" && + git-update-ref "refs/heads/$origin" $(git-rev-parse HEAD) && 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" || + test "$origin" = "$head" || echo "Pull: ${head}:${head}" done >>.git/remotes/origin esac