]>
git.ipfire.org Git - thirdparty/git.git/blob - git-pull.sh
3 # Copyright (c) 2005 Junio C Hamano
5 # Fetch one or more remote refs and merge it/them into the current HEAD.
7 USAGE
='[-n | --no-summary] [--no-commit] [-s strategy]... [<fetch-options>] <repo> <head>...'
8 LONG_USAGE
='Fetch one or more remote refs and merge it/them into the current HEAD.'
11 strategy_args
= no_summary
= no_commit
=
12 while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac
15 -n|
--n|
--no|
--no-|
--no-s|
--no-su|
--no-sum|
--no-summ|\
16 --no-summa|
--no-summar|
--no-summary)
18 --no-c|
--no-co|
--no-com|
--no-comm|
--no-commi|
--no-commit)
19 no_commit
=--no-commit ;;
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 "
34 -h|
--h|
--he|
--hel|
--help)
38 # Pass thru anything that is meant for fetch.
45 orig_head
=$
(git-rev-parse
--verify HEAD
) || die
"Pulling into a black hole?"
46 git-fetch
--update-head-ok "$@" ||
exit 1
48 curr_head
=$
(git-rev-parse
--verify HEAD
)
49 if test "$curr_head" != "$orig_head"
51 # The fetch involved updating the current branch.
53 # The working tree and the index file is still based on the
54 # $orig_head commit, but we are merging into $curr_head.
55 # First update the working tree to match $curr_head.
57 echo >&2 "Warning: fetch updated the current branch head."
58 echo >&2 "Warning: fast forwarding your working tree."
59 git-read-tree
-u -m "$orig_head" "$curr_head" ||
60 die
"You need to first update your working tree."
63 merge_head
=$
(sed -e '/ not-for-merge /d' \
64 -e 's/ .*//' "$GIT_DIR"/FETCH_HEAD | \
69 echo >&2 "No changes."
73 var
=`git-var -l | sed -ne 's/^pull\.octopus=/-s /p'`
76 strategy_default_args
='-s octopus'
78 strategy_default_args
=$var
82 var
=`git-var -l | sed -ne 's/^pull\.twohead=/-s /p'`
85 strategy_default_args
='-s recursive'
87 strategy_default_args
=$var
92 case "$strategy_args" in
94 strategy_args
=$strategy_default_args
98 merge_name
=$
(git-fmt-merge-msg
<"$GIT_DIR/FETCH_HEAD")
99 git-merge
$no_summary $no_commit $strategy_args "$merge_name" HEAD
$merge_head