1#!/bin/sh 2# 3# Copyright (c) 2005 Junio C Hamano 4# 5# Fetch one or more remote refs and merge it/them into the current HEAD. 6 7. git-sh-setup|| die "Not a git archive" 8 9orig_head=$(cat "$GIT_DIR/HEAD")|| die "Pulling into a black hole?" 10git-fetch --update-head-ok"$@"||exit1 11 12curr_head=$(cat "$GIT_DIR/HEAD") 13iftest"$curr_head"!="$orig_head" 14then 15# The fetch involved updating the current branch. 16 17# The working tree and the index file is still based on the 18# $orig_head commit, but we are merging into $curr_head. 19# First update the working tree to match $curr_head. 20 21echo>&2"Warning: fetch updated the current branch head." 22echo>&2"Warning: fast forwarding your working tree." 23 git-read-tree -u -m"$orig_head""$curr_head"|| 24 die "You need to first update your working tree." 25fi 26 27merge_head=$(sed -e 's/ .*//' "$GIT_DIR"/FETCH_HEAD) 28merge_name=$( 29 perl -e'print join("; ", map { chomp; s/^[0-9a-f]* //;$_} <>)' \ 30"$GIT_DIR"/FETCH_HEAD 31) 32 33case"$merge_head"in 34'') 35echo>&2"No changes." 36exit0 37;; 38*' '?*) 39echo>&2"Pulling more than one heads; making an Octopus." 40exec git-octopus 41;; 42esac 43 44git-resolve \ 45"$(cat "$GIT_DIR"/HEAD)" \ 46$merge_head"Merge$merge_name"