1#!/bin/sh
2#
3destination=FETCH_HEAD
4
5merge_repo=$1
6merge_name=${2:-HEAD}
7if [ "$2" = "tag" ]; then
8 merge_name="refs/tags/$3"
9 destination="$merge_name"
10fi
11
12: ${GIT_DIR=.git}
13: ${GIT_OBJECT_DIRECTORY="${SHA1_FILE_DIRECTORY-"$GIT_DIR/objects"}"}
14
15download_one () {
16 # remote_path="$1" local_file="$2"
17 case "$1" in
18 http://*)
19 wget -q -O "$2" "$1" ;;
20 /*)
21 test -f "$1" && cat >"$2" "$1" ;;
22 *)
23 rsync -L "$1" "$2" ;;
24 esac
25}
26
27download_objects () {
28 # remote_repo="$1" head_sha1="$2"
29 case "$1" in
30 http://*)
31 git-http-pull -a "$2" "$1/"
32 ;;
33 /*)
34 git-local-pull -l -a "$2" "$1/"
35 ;;
36 *)
37 rsync -avz --ignore-existing \
38 "$1/objects/." "$GIT_OBJECT_DIRECTORY"/.
39 ;;
40 esac
41}
42
43echo "Getting remote $merge_name"
44download_one "$merge_repo/$merge_name" "$GIT_DIR/$destination" || exit 1
45
46echo "Getting object database"
47download_objects "$merge_repo" "$(cat "$GIT_DIR/$destination")" || exit 1