Sort branch names snarfed from refs/ hierarchy.
[gitweb.git] / git-pull-script
index 8e309fc98b97659d08061b0e1f1e6d4f1e43fc32..7016fbf943406d8e647e7a02f283fa10ab134905 100755 (executable)
@@ -1,25 +1,26 @@
 #!/bin/sh
 #
-. git-sh-setup-script || die "Not a git archive"
-
-merge_repo=$1
+# Copyright (c) 2005 Junio C Hamano
+#
+# Fetch one or more remote refs and merge it/them into the current HEAD.
 
-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
+. 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"/FETCH_HEAD)" \
-       "Merge $merge_name"
+       $merge_head "Merge $merge_name"