8a2d37d623a71b71b0f1e86184c0bc88a25068df
1 #!/bin/sh
2 #
3 destination=FETCH_HEAD
5 merge_repo=$1
6 merge_name=${2:-HEAD}
7 if [ "$2" = "tag" ]; then
8 merge_name="refs/tags/$3"
9 destination="$merge_name"
10 fi
12 : ${GIT_DIR=.git}
13 : ${GIT_OBJECT_DIRECTORY="${SHA1_FILE_DIRECTORY-"$GIT_DIR/objects"}"}
14 TMP_HEAD="$GIT_DIR/TMP_HEAD"
16 case "$merge_repo" in
17 http://*)
18 head=$(wget -q -O - "$merge_repo/$merge_name") || exit 1
19 echo Fetching $head using http
20 git-http-pull -v -a "$head" "$merge_repo/"
21 ;;
22 rsync://*)
23 rsync -L "$merge_repo/$merge_name" "$TMP_HEAD" || exit 1
24 head=$(git-rev-parse TMP_HEAD)
25 rm -f "$TMP_HEAD"
26 rsync -avz --ignore-existing "$merge_repo/objects/" "$GIT_OBJECT_DIRECTORY/"
27 ;;
28 *)
29 head=$(git-fetch-pack "$merge_repo" "$merge_name")
30 ;;
31 esac || exit 1
32 git-rev-parse --verify "$head" > /dev/null || exit 1
33 echo "$head" > "$GIT_DIR/$destination"