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"}"}
14TMP_HEAD="$GIT_DIR/TMP_HEAD"
15
16case "$merge_repo" in
17http://*)
18 head=$(wget -q -O - "$merge_repo/$merge_name") || exit 1
19 git-http-pull -a "$head" "$merge_repo"
20 ;;
21rsync://*)
22 rsync -L "$merge_repo/$merge_name" "$TMP_HEAD" || exit 1
23 head=$(git-rev-parse TMP_HEAD)
24 rm -f "$TMP_HEAD"
25 rsync -avz --ignore-existing "$merge_repo/objects/" "$GIT_OBJECT_DIRECTORY/"
26 ;;
27*)
28 head=$(git-fetch-pack "$merge_repo" "$merge_name")
29 ;;
30esac || exit 1
31git-rev-parse --verify "$head" > /dev/null || exit 1
32echo "$head" > "$GIT_DIR/$destination"