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"
10 die
"git pull [-n] [-s strategy]... <repo> <head>..."
13 strategy_args
= no_summary
=
14 while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac
17 -n|
--n|
--no|
--no-|
--no-s|
--no-su|
--no-sum|
--no-summ|\
18 --no-summa|
--no-summar|
--no-summary)
20 -s=*|
--s=*|
--st=*|
--str=*|
--stra=*|
--strat=*|
--strate=*|\
21 --strateg=*|
--strategy=*|\
22 -s|
--s|
--st|
--str|
--stra|
--strat|
--strate|
--strateg|
--strategy)
25 strategy
=`expr "$1" : '-[^=]*=\(.*\)'` ;;
32 strategy_args
="${strategy_args}-s $strategy "
35 # Pass thru anything that is meant for fetch.
42 orig_head
=$
(git-rev-parse
--verify HEAD
) || die
"Pulling into a black hole?"
43 git-fetch
--update-head-ok "$@" ||
exit 1
45 curr_head
=$
(git-rev-parse
--verify HEAD
)
46 if test "$curr_head" != "$orig_head"
48 # The fetch involved updating the current branch.
50 # The working tree and the index file is still based on the
51 # $orig_head commit, but we are merging into $curr_head.
52 # First update the working tree to match $curr_head.
54 echo >&2 "Warning: fetch updated the current branch head."
55 echo >&2 "Warning: fast forwarding your working tree."
56 git-read-tree
-u -m "$orig_head" "$curr_head" ||
57 die
"You need to first update your working tree."
60 merge_head
=$
(sed -e '/ not-for-merge /d' \
61 -e 's/ .*//' "$GIT_DIR"/FETCH_HEAD | \
66 echo >&2 "No changes."
70 strategy_default_args
='-s octopus'
73 strategy_default_args
='-s resolve'
77 case "$strategy_args" in
79 strategy_args
=$strategy_default_args
83 merge_name
=$
(git-fmt-merge-msg
<"$GIT_DIR/FETCH_HEAD")
84 git-merge
$no_summary $strategy_args "$merge_name" HEAD
$merge_head