Add Abstract: support for howto index generator.
[git] / git-clone-dumb-http
1 #!/bin/sh
2 #
3 # Copyright (c) 2005, Junio C Hamano
4 #
5 # Called by git-clone-script
6 # Exits 2 when the remote site does not support dumb server protocol.
7
8 # Usage: git-clone-dumb-http <remote-repo> <local-dir>
9
10 R=${1?"remote repository"} D=${2?"local directory"}
11
12 if [ -n "$GIT_SSL_NO_VERIFY" ]; then
13     curl_extra_args="-k"
14 fi
15 http_fetch () {
16         # $1 = Remote, $2 = Local
17         curl -nsf $curl_extra_args "$1" >"$2"
18 }
19
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
24
25 http_fetch "$R/info/refs" "$clone_tmp/refs" &&
26 http_fetch "$R/objects/info/packs" "$clone_tmp/packs" || exit 2
27
28 # We do not have to worry about rev-cache when cloning.
29 # http_fetch "$R/info/rev-cache" "$clone_tmp/rev-cache" 
30
31 # Clone packs
32 while read type name
33 do
34         case "$type" in
35         P) ;;
36         *) continue ;;
37         esac &&
38
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
43
44 done <"$clone_tmp/packs"
45
46 # Then clone refs.
47 while read sha1 refname
48 do
49         name=`expr "$refname" : 'refs/\(.*\)'` &&
50         git-http-pull -v -a -w "$name" "$name" "$R/" || exit 1
51 done <"$clone_tmp/refs"