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] [--no-commit] [-s strategy]... <repo> <head>..."
13 strategy_args= no_summary= no_commit=
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 --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
21 no_commit=--no-commit ;;
22 -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
23 --strateg=*|--strategy=*|\
24 -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
27 strategy=`expr "$1" : '-[^=]*=\(.*\)'` ;;
34 strategy_args="${strategy_args}-s $strategy "
37 # Pass thru anything that is meant for fetch.
44 orig_head=$(git-rev-parse --verify HEAD) || die "Pulling into a black hole?"
45 git-fetch --update-head-ok "$@" || exit 1
47 curr_head=$(git-rev-parse --verify HEAD)
48 if test "$curr_head" != "$orig_head"
50 # The fetch involved updating the current branch.
52 # The working tree and the index file is still based on the
53 # $orig_head commit, but we are merging into $curr_head.
54 # First update the working tree to match $curr_head.
56 echo >&2 "Warning: fetch updated the current branch head."
57 echo >&2 "Warning: fast forwarding your working tree."
58 git-read-tree -u -m "$orig_head" "$curr_head" ||
59 die "You need to first update your working tree."
62 merge_head=$(sed -e '/ not-for-merge /d' \
63 -e 's/ .*//' "$GIT_DIR"/FETCH_HEAD | \
68 echo >&2 "No changes."
72 strategy_default_args='-s octopus'
75 strategy_default_args='-s resolve'
79 case "$strategy_args" in
81 strategy_args=$strategy_default_args
85 merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD")
86 git-merge $no_summary $no_commit $strategy_args "$merge_name" HEAD $merge_head