3 # Copyright (c) 2005 Junio C Hamano
5 # Fetch one or more remote refs and merge it/them into the current HEAD.
10 echo >&2 "usage: $0"' [-n] [--no-commit] [--no-summary] [--help]
15 Fetch one or more remote refs and merge it/them into the current HEAD.
20 strategy_args= no_summary= no_commit=
21 while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac
24 -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
25 --no-summa|--no-summar|--no-summary)
27 --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
28 no_commit=--no-commit ;;
29 -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
30 --strateg=*|--strategy=*|\
31 -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
34 strategy=`expr "$1" : '-[^=]*=\(.*\)'` ;;
41 strategy_args="${strategy_args}-s $strategy "
43 -h|--h|--he|--hel|--help)
47 # Pass thru anything that is meant for fetch.
54 orig_head=$(git-rev-parse --verify HEAD) || die "Pulling into a black hole?"
55 git-fetch --update-head-ok "$@" || exit 1
57 curr_head=$(git-rev-parse --verify HEAD)
58 if test "$curr_head" != "$orig_head"
60 # The fetch involved updating the current branch.
62 # The working tree and the index file is still based on the
63 # $orig_head commit, but we are merging into $curr_head.
64 # First update the working tree to match $curr_head.
66 echo >&2 "Warning: fetch updated the current branch head."
67 echo >&2 "Warning: fast forwarding your working tree."
68 git-read-tree -u -m "$orig_head" "$curr_head" ||
69 die "You need to first update your working tree."
72 merge_head=$(sed -e '/ not-for-merge /d' \
73 -e 's/ .*//' "$GIT_DIR"/FETCH_HEAD | \
78 echo >&2 "No changes."
82 var=`git-var -l | sed -ne 's/^pull\.octopus=/-s /p'`
85 strategy_default_args='-s octopus'
87 strategy_default_args=$var
91 var=`git-var -l | sed -ne 's/^pull\.twohead=/-s /p'`
94 strategy_default_args='-s recursive'
96 strategy_default_args=$var
101 case "$strategy_args" in
103 strategy_args=$strategy_default_args
107 merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD")
108 git-merge $no_summary $no_commit $strategy_args "$merge_name" HEAD $merge_head