[PATCH] Make git-sh-setup-script do what it was supposed to do
[git/gitweb.git] / git-clone-dumb-http
blob8203c67626f45b2c9363b5e5b7bc47df5647490f
1 #!/bin/sh
3 # Copyright (c) 2005, Junio C Hamano
5 # Called by git-clone-script
6 # Exits 2 when the remote site does not support dumb server protocol.
8 # Usage: git-clone-dumb-http <remote-repo> <local-dir>
10 R=${1?"remote repository"} D=${2?"local directory"}
12 if [ -n "$GIT_SSL_NO_VERIFY" ]; then
13 curl_extra_args="-k"
15 http_fetch () {
16 # $1 = Remote, $2 = Local
17 curl -ns $curl_extra_args "$1" >"$2"
20 cd "$D" &&
21 clone_tmp=".git/clone-tmp" &&
22 mkdir -p "$clone_tmp" || exit 1
23 trap "rm -rf .git/clone-tmp" 0 1 2 3 15
25 http_fetch "$R/info/refs" "$clone_tmp/refs" &&
26 http_fetch "$R/objects/info/packs" "$clone_tmp/packs" || exit 2
28 # We do not have to worry about rev-cache when cloning.
29 # http_fetch "$R/info/rev-cache" "$clone_tmp/rev-cache"
31 # Clone packs
32 while read type name
34 case "$type" in
35 P) ;;
36 *) continue ;;
37 esac &&
39 idx=`expr "$name" : '\(.*\)\.pack'`.idx
40 http_fetch "$R/objects/pack/$name" ".git/objects/pack/$name" &&
41 http_fetch "$R/objects/pack/$idx" ".git/objects/pack/$idx" &&
42 git-verify-pack ".git/objects/pack/$idx" || exit 1
44 done <"$clone_tmp/packs"
46 # Then clone refs.
47 while read sha1 refname
49 name=`expr "$refname" : 'refs/\(.*\)'` &&
50 git-http-pull -v -a -w "$name" "$name" "$R/" || exit 1
51 done <"$clone_tmp/refs"