#!/bin/sh
#
-# use "$1" or something in a real script, this
-# just hard-codes it.
-#
+. git-sh-setup-script || die "Not a git archive"
+
merge_repo=$1
-merge_name=${2:-HEAD}
-echo "Getting object database"
-rsync -avz --ignore-existing $merge_repo/objects/. ${SHA1_FILE_DIRECTORY:-.git/objects}/.
+merge_name=$(echo "$1" | sed 's:\.git/*$::')
+merge_head=HEAD
+type=head
+if [ "$2" = "tag" ]; then
+ type=tag
+ shift
+fi
+if [ "$2" ]
+then
+ merge_name="$type '$2' of $merge_name"
+ merge_head="refs/${type}s/$2"
+fi
-echo "Getting remote $merge_name"
-rsync -L $merge_repo/$merge_name .git/MERGE_HEAD || exit 1
+git-fetch-script "$merge_repo" "$merge_head" || exit 1
-git-resolve-script "$(cat .git/HEAD)" "$(cat .git/MERGE_HEAD)" "$merge_repo"
+git-resolve-script \
+ "$(cat "$GIT_DIR"/HEAD)" \
+ "$(cat "$GIT_DIR"/FETCH_HEAD)" \
+ "$merge_name"