3 # Copyright (c) 2005 Junio C Hamano
5 # Resolve two or more trees.
8 # The first parameters up to -- are merge bases; the rest are heads.
9 bases
= head= remotes
= sep_seen
=
12 case ",$sep_seen,$head,$arg," in
20 remotes
="$remotes$arg "
28 # Reject if this is not an Octopus -- resolve should be used instead.
36 # MRC is the current "merge reference commit"
37 # MRT is the current "merge result tree"
39 MRC
=$head MSG
= PARENT
="-p $head"
41 CNT
=1 ;# counting our head
45 common
=$
(git-merge-base
$MRC $SHA1) ||
46 die
"Unable to find common commit with $SHA1"
48 if test "$common" = $SHA1
50 echo "Already up-to-date with $SHA1"
55 PARENT
="$PARENT -p $SHA1"
57 if test "$common,$NON_FF_MERGE" = "$MRC,0"
59 # The first head being merged was a fast-forward.
60 # Advance MRC to the head being merged, and use that
61 # tree as the intermediate result of the merge.
62 # We still need to count this as part of the parent set.
64 echo "Fast forwarding to: $SHA1"
65 git-read-tree
-u -m $head $SHA1 ||
exit
66 MRC
=$SHA1 MRT
=$
(git-write-tree
)
72 echo "Trying simple merge with $SHA1"
73 git-read-tree
-u -m $common $MRT $SHA1 ||
exit 2
74 next
=$
(git-write-tree
2>/dev
/null
)
77 echo "Simple merge did not work, trying automatic merge."
78 git-merge-index
-o git-merge-one-file
-a ||
79 exit 2 ; # Automatic merge failed; should not be doing Octopus
80 next
=$
(git-write-tree
2>/dev
/null
)