]>
Commit | Line | Data |
---|---|---|
839a7a06 LT |
1 | #!/bin/sh |
2 | # | |
521003ff JH |
3 | # Copyright (c) 2005 Junio C Hamano |
4 | # | |
5 | # Fetch one or more remote refs and merge it/them into the current HEAD. | |
6 | ||
215a7ad1 | 7 | . git-sh-setup || die "Not a git archive" |
b10ac50f JH |
8 | |
9 | orig_head=$(cat "$GIT_DIR/HEAD") || die "Pulling into a black hole?" | |
215a7ad1 | 10 | git-fetch --update-head-ok "$@" || exit 1 |
b10ac50f JH |
11 | |
12 | curr_head=$(cat "$GIT_DIR/HEAD") | |
13 | if test "$curr_head" != "$orig_head" | |
14 | then | |
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 | ||
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." | |
25 | fi | |
26 | ||
e0bfc81e JH |
27 | merge_head=$(sed -e 's/ .*//' "$GIT_DIR"/FETCH_HEAD | tr '\012' ' ') |
28 | merge_name=$(sed -e 's/^[0-9a-f]* //' "$GIT_DIR"/FETCH_HEAD | | |
29 | tr '\012' ' ') | |
30 | ||
31 | case "$merge_head" in | |
521003ff JH |
32 | '') |
33 | echo >&2 "No changes." | |
34 | exit 0 | |
35 | ;; | |
36 | *' '?*) | |
37 | echo >&2 "Pulling more than one heads; making an Octopus." | |
215a7ad1 | 38 | exec git-octopus |
521003ff | 39 | ;; |
e0bfc81e JH |
40 | esac |
41 | ||
215a7ad1 | 42 | git-resolve \ |
8ac069ac | 43 | "$(cat "$GIT_DIR"/HEAD)" \ |
e0bfc81e | 44 | $merge_head "Merge $merge_name" |