3 # Copyright (c) 2005 Linus Torvalds
5 # Resolve two trees, 'stupid merge'.
7 # The first parameters up to -- are merge bases; the rest are heads.
8 bases= head= remotes= sep_seen=
11 case ",$sep_seen,$head,$arg," in
19 remotes="$remotes$arg "
27 # Give up if we are given two or more remotes -- not handling octopus.
33 # Find an optimum merge base if there are more than one candidates.
36 echo "Trying to find the optimum merge base."
43 GIT_INDEX_FILE=$G git read-tree -m $c $head $remotes \
44 2>/dev/null || continue
45 # Count the paths that are unmerged.
46 cnt=`GIT_INDEX_FILE=$G git ls-files --unmerged | wc -l`
47 if test $best_cnt -le 0 -o $cnt -le $best_cnt
51 if test "$best_cnt" -eq 0
53 # Cannot do any better than all trivial merge.
66 git update-index --refresh 2>/dev/null
67 git read-tree -u -m $common $head $remotes || exit 2
68 echo "Trying simple merge."
69 if result_tree=$(git write-tree 2>/dev/null)
73 echo "Simple merge failed, trying Automatic merge."
74 if git-merge-index -o git-merge-one-file -a