git-fetch-scripton commit git-rev-list: use proper lazy reachability analysis (8906300)
   1#!/bin/sh
   2#
   3merge_repo=$1
   4merge_name=${2:-HEAD}
   5
   6: ${GIT_DIR=.git}
   7: ${GIT_OBJECT_DIRECTORY="${SHA1_FILE_DIRECTORY-"$GIT_DIR/objects"}"}
   8
   9download_one () {
  10        # remote_path="$1" local_file="$2"
  11        case "$1" in
  12        http://*)
  13                wget -q -O "$2" "$1" ;;
  14        /*)
  15                test -f "$1" && cat >"$2" "$1" ;;
  16        *)
  17                rsync -L "$1" "$2" ;;
  18        esac
  19}
  20
  21download_objects () {
  22        # remote_repo="$1" head_sha1="$2"
  23        case "$1" in
  24        http://*)
  25                git-http-pull -a "$2" "$1/"
  26                ;;
  27        /*)
  28                git-local-pull -l -a "$2" "$1/"
  29                ;;
  30        *)
  31                rsync -avz --ignore-existing \
  32                        "$1/objects/." "$GIT_OBJECT_DIRECTORY"/.
  33                ;;
  34        esac
  35}
  36
  37echo "Getting remote $merge_name"
  38download_one "$merge_repo/$merge_name" "$GIT_DIR"/MERGE_HEAD
  39
  40echo "Getting object database"
  41download_objects "$merge_repo" "$(cat "$GIT_DIR"/MERGE_HEAD)"