summaryrefslogtreecommitdiff
path: root/git-clone.sh
diff options
context:
space:
mode:
Diffstat (limited to 'git-clone.sh')
-rwxr-xr-xgit-clone.sh33
1 files changed, 14 insertions, 19 deletions
diff --git a/git-clone.sh b/git-clone.sh
index 280cc2e..377d59e 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -9,7 +9,7 @@
unset CDPATH
usage() {
- echo >&2 "Usage: $0 [-l [-s]] [-q] [-u <upload-pack>] [-n] <repo> [<dir>]"
+ echo >&2 "Usage: $0 [-l [-s]] [-q] [-u <upload-pack>] [-o <name>] [-n] <repo> [<dir>]"
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