Sort branch names snarfed from refs/ hierarchy.
[gitweb.git] / git-pull-script
index a4ca97c64566419a0dc02e8e719333d1c9240edc..7016fbf943406d8e647e7a02f283fa10ab134905 100755 (executable)
@@ -1,23 +1,26 @@
 #!/bin/sh
 #
-merge_repo=$1
-
-merge_name=$(echo "$1" | sed 's:\.git/*$::')
-merge_head=HEAD
-if [ "$2" ]
-then
-   merge_name="'$2' branch from
-
-       $merge_name"
-   merge_head="refs/heads/$2"
-fi
+# Copyright (c) 2005 Junio C Hamano
+#
+# Fetch one or more remote refs and merge it/them into the current HEAD.
 
-: ${GIT_DIR=.git}
-: ${GIT_OBJECT_DIRECTORY="${SHA1_FILE_DIRECTORY-"$GIT_DIR/objects"}"}
+. git-sh-setup-script || die "Not a git archive"
+git-fetch-script "$@" || exit 1
+merge_head=$(sed -e 's/        .*//' "$GIT_DIR"/FETCH_HEAD | tr '\012' ' ')
+merge_name=$(sed -e 's/^[0-9a-f]*      //' "$GIT_DIR"/FETCH_HEAD |
+        tr '\012' ' ')
 
-git-fetch-script "$merge_repo" "$merge_head" || exit 1
+case "$merge_head" in
+'')
+       echo >&2 "No changes."
+       exit 0
+       ;;
+*' '?*)
+       echo >&2 "Pulling more than one heads; making an Octopus."
+       exec git-octopus-script
+       ;;
+esac
 
 git-resolve-script \
        "$(cat "$GIT_DIR"/HEAD)" \
-       "$(cat "$GIT_DIR"/MERGE_HEAD)" \
-       "$merge_name"
+       $merge_head "Merge $merge_name"