git-send-pack: verify that sender is a proper superset of receiver
[git/jnareb-git.git] / git-fetch-script
blobb44cf3f5a5bf61788ae6dc384ed59841ddd1f517
1 #!/bin/sh
3 . git-sh-setup-script || die "Not a git archive"
4 . git-parse-remote "$@"
5 merge_repo="$_remote_repo"
6 merge_head="$_remote_head"
7 merge_store="$_remote_store"
9 TMP_HEAD="$GIT_DIR/TMP_HEAD"
11 case "$merge_repo" in
12 http://*)
13 head=$(wget -q -O - "$merge_repo/$merge_head") || exit 1
14 echo Fetching "$merge_head" using http
15 git-http-pull -v -a "$head" "$merge_repo/"
17 rsync://*)
18 rsync -L "$merge_repo/$merge_head" "$TMP_HEAD" || exit 1
19 head=$(git-rev-parse TMP_HEAD)
20 rm -f "$TMP_HEAD"
21 rsync -avz --ignore-existing "$merge_repo/objects/" "$GIT_OBJECT_DIRECTORY/"
24 head=$(git-fetch-pack "$merge_repo" "$merge_head")
26 esac || exit 1
28 git-rev-parse --verify "$head" > /dev/null || exit 1
30 case "$merge_store" in
31 '')
34 echo "$head" > "$GIT_DIR/$merge_store"
35 esac &&
37 # FETCH_HEAD is fed to git-resolve-script which will eventually be
38 # passed to git-commit-tree as one of the parents. Make sure we do
39 # not give a tag object ID.
41 git-rev-parse "$head^0" >"$GIT_DIR/FETCH_HEAD"