]> git.ipfire.org Git - thirdparty/git.git/blame - git-clone-dumb-http
[PATCH] archimport autodetects import status, supports incremental imports
[thirdparty/git.git] / git-clone-dumb-http
CommitLineData
c0a58fbb
JH
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
10R=${1?"remote repository"} D=${2?"local directory"}
11
12if [ -n "$GIT_SSL_NO_VERIFY" ]; then
13 curl_extra_args="-k"
14fi
15http_fetch () {
16 # $1 = Remote, $2 = Local
affa40d2 17 curl -nsf $curl_extra_args "$1" >"$2"
c0a58fbb
JH
18}
19
20cd "$D" &&
21clone_tmp=".git/clone-tmp" &&
22mkdir -p "$clone_tmp" || exit 1
23trap "rm -rf .git/clone-tmp" 0 1 2 3 15
24
25http_fetch "$R/info/refs" "$clone_tmp/refs" &&
26http_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
32while read type name
33do
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
44done <"$clone_tmp/packs"
45
46# Then clone refs.
47while read sha1 refname
48do
49 name=`expr "$refname" : 'refs/\(.*\)'` &&
50 git-http-pull -v -a -w "$name" "$name" "$R/" || exit 1
51done <"$clone_tmp/refs"