]> git.ipfire.org Git - thirdparty/git.git/blame - git-pull.sh
Remove 'Previously this command was known as ...' messages.
[thirdparty/git.git] / git-pull.sh
CommitLineData
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 8
60fb5b2c
JH
9usage () {
10 die "git pull [-n] [-s strategy]... <repo> <head>..."
11}
12
13strategy_args= no_summary=
14while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac
15do
16 case "$1" in
17 -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
18 --no-summa|--no-summar|--no-summary)
19 no_summary=-n ;;
20 -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
21 --strateg=*|--strategy=*|\
22 -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
23 case "$#,$1" in
24 *,*=*)
25 strategy=`expr "$1" : '-[^=]*=\(.*\)'` ;;
26 1,*)
27 usage ;;
28 *)
29 strategy="$2"
30 shift ;;
31 esac
32 strategy_args="${strategy_args}-s $strategy "
33 ;;
34 -*)
619e5a0e
JH
35 # Pass thru anything that is meant for fetch.
36 break
60fb5b2c
JH
37 ;;
38 esac
39 shift
40done
41
bf7960eb 42orig_head=$(git-rev-parse --verify HEAD) || die "Pulling into a black hole?"
215a7ad1 43git-fetch --update-head-ok "$@" || exit 1
b10ac50f 44
bf7960eb 45curr_head=$(git-rev-parse --verify HEAD)
b10ac50f
JH
46if test "$curr_head" != "$orig_head"
47then
48 # The fetch involved updating the current branch.
49
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.
53
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."
58fi
59
05dd8e2e
JH
60merge_head=$(sed -e '/ not-for-merge /d' \
61 -e 's/ .*//' "$GIT_DIR"/FETCH_HEAD | \
62 tr '\012' ' ')
e0bfc81e
JH
63
64case "$merge_head" in
521003ff
JH
65'')
66 echo >&2 "No changes."
67 exit 0
68 ;;
60fb5b2c
JH
69?*' '?*)
70 strategy_default_args='-s octopus'
71 ;;
72*)
73 strategy_default_args='-s resolve'
74 ;;
75esac
76
77case "$strategy_args" in
78'')
79 strategy_args=$strategy_default_args
acfadcfb 80 ;;
e0bfc81e
JH
81esac
82
c8b48ba4 83merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD")
60fb5b2c 84git-merge $no_summary $strategy_args "$merge_name" HEAD $merge_head