COPTS -> CFLAGS
[git/spearce.git] / git-pull.sh
blobe3d11961b0a5a7608648348153bde0ab6e7ccfff
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
5 # Fetch one or more remote refs and merge it/them into the current HEAD.
7 . git-sh-setup || die "Not a git archive"
9 orig_head=$(cat "$GIT_DIR/HEAD") || die "Pulling into a black hole?"
10 git-fetch --update-head-ok "$@" || exit 1
12 curr_head=$(cat "$GIT_DIR/HEAD")
13 if test "$curr_head" != "$orig_head"
14 then
15 # The fetch involved updating the current branch.
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.
21 echo >&2 "Warning: fetch updated the current branch head."
22 echo >&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."
27 merge_head=$(sed -e 's/ .*//' "$GIT_DIR"/FETCH_HEAD | tr '\012' ' ')
29 case "$merge_head" in
30 '')
31 echo >&2 "No changes."
32 exit 0
34 *' '?*)
35 echo >&2 "Pulling more than one heads; making an Octopus."
36 exec git-octopus
38 esac
40 merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD")
41 git-resolve "$(cat "$GIT_DIR"/HEAD)" $merge_head "$merge_name"