3 # Copyright (c) 2005 Junio C Hamano
5 # Resolve two or more trees.
16 # The first parameters up to -- are merge bases; the rest are heads.
17 bases
= head= remotes
= sep_seen
=
20 case ",$sep_seen,$head,$arg," in
28 remotes
="$remotes$arg "
36 # Reject if this is not an Octopus -- resolve should be used instead.
44 # MRC is the current "merge reference commit"
45 # MRT is the current "merge result tree"
47 MRC
=$
(git rev-parse
--verify -q $head)
53 case "$OCTOPUS_FAILURE" in
55 # We allow only last one to have a hand-resolvable
56 # conflicts. Last round failed and we still had
58 echo "Automated merge did not work."
59 echo "Should not be doing an Octopus."
63 eval pretty_name
=\
${GITHEAD_$SHA1:-$SHA1}
64 if test "$SHA1" = "$pretty_name"
66 SHA1_UP
="$(echo "$SHA1" | tr a-z A-z)"
67 eval pretty_name
=\
${GITHEAD_$SHA1_UP:-$pretty_name}
69 common
=$
(git merge-base
--all $SHA1 $MRC) ||
70 die
"Unable to find common commit with $pretty_name"
72 case "$LF$common$LF" in
74 echo "Already up-to-date with $pretty_name"
79 if test "$common,$NON_FF_MERGE" = "$MRC,0"
81 # The first head being merged was a fast-forward.
82 # Advance MRC to the head being merged, and use that
83 # tree as the intermediate result of the merge.
84 # We still need to count this as part of the parent set.
86 echo "Fast-forwarding to: $pretty_name"
87 git read-tree
-u -m $head $SHA1 ||
exit
88 MRC
=$SHA1 MRT
=$
(git write-tree
)
94 echo "Trying simple merge with $pretty_name"
95 git read-tree
-u -m --aggressive $common $MRT $SHA1 ||
exit 2
96 next
=$
(git write-tree
2>/dev
/null
)
99 echo "Simple merge did not work, trying automatic merge."
100 git-merge-index
-o git-merge-one-file
-a ||
102 next
=$
(git write-tree
2>/dev
/null
)
109 exit "$OCTOPUS_FAILURE"