Use git-merge in git-pull (second try).
This again makes git-pull to use git-merge, so that different merge strategy can be specified from the command line. Without explicit strategy parameter, it defaults to git-merge-resolve if only one remote is pulled, and git-merge-octopus otherwise, to keep the default behaviour of the command the same as the original. Also this brings another usability measure: -n flag from the command line, if given, is passed to git-merge to prevent it from running the diffstat at the end of the merge. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Sep 25, 2005 at 19:43 UTC
60fb5b2c4d9e26204f480f8a18ae1ff0051a6440
1 file changed
+44
-4
git-pull.sh
+44
-4
@@ -6,6 +6,38 @@
6
7
. git-sh-setup || die "Not a git archive"
8
9
+usage () {
10
+ die "git pull [-n] [-s strategy]... <repo> <head>..."
11
+}
12
+
13
+strategy_args= no_summary=
14
+while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac
15
+do
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
+ -*)
35
+ usage
36
+ ;;
37
+ esac
38
+ shift
39
+done
40
+
41
orig_head=$(git-rev-parse --verify HEAD) || die "Pulling into a black hole?"
42
git-fetch --update-head-ok "$@" || exit 1
43
@@ -33,11 +65,19 @@ case "$merge_head" in
65
echo >&2 "No changes."
66
exit 0
67
;;
36
-*' '?*)
37
- echo >&2 "Pulling more than one heads; making an Octopus."
38
- exec git-octopus
68
+?*' '?*)
69
+ strategy_default_args='-s octopus'
70
+ ;;
71
+*)
72
+ strategy_default_args='-s resolve'
73
+ ;;
74
+esac
75
+
76
+case "$strategy_args" in
77
+'')
78
+ strategy_args=$strategy_default_args
79
;;
80
esac
81
82
merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD")
43
-git-resolve "$curr_head" $merge_head "$merge_name"
83
+git-merge $no_summary $strategy_args "$merge_name" HEAD $merge_head