3 # Copyright (c) 2005 Junio C Hamano
5 # Resolve two or more trees.
14 # The first parameters up to -- are merge bases; the rest are heads.
15 bases
= head= remotes
= sep_seen
=
18 case ",$sep_seen,$head,$arg," in
26 remotes
="$remotes$arg "
34 # Reject if this is not an Octopus -- resolve should be used instead.
42 # MRC is the current "merge reference commit"
43 # MRT is the current "merge result tree"
45 if ! git diff-index
--quiet --cached HEAD
--
47 gettextln
"Error: Your local changes to the following files would be overwritten by merge"
48 git diff-index
--cached --name-only HEAD
-- |
sed -e 's/^/ /'
51 MRC
=$
(git rev-parse
--verify -q $head)
57 case "$OCTOPUS_FAILURE" in
59 # We allow only last one to have a hand-resolvable
60 # conflicts. Last round failed and we still had
62 gettextln
"Automated merge did not work."
63 gettextln
"Should not be doing an Octopus."
67 eval pretty_name
=\
${GITHEAD_$SHA1:-$SHA1}
68 if test "$SHA1" = "$pretty_name"
70 SHA1_UP
="$(echo "$SHA1" | tr a-z A-Z)"
71 eval pretty_name
=\
${GITHEAD_$SHA1_UP:-$pretty_name}
73 common
=$
(git merge-base
--all $SHA1 $MRC) ||
74 die
"$(eval_gettext "Unable to
find common commit with \
$pretty_name")"
76 case "$LF$common$LF" in
78 eval_gettextln
"Already up-to-date with \$pretty_name"
83 if test "$common,$NON_FF_MERGE" = "$MRC,0"
85 # The first head being merged was a fast-forward.
86 # Advance MRC to the head being merged, and use that
87 # tree as the intermediate result of the merge.
88 # We still need to count this as part of the parent set.
90 eval_gettextln
"Fast-forwarding to: \$pretty_name"
91 git read-tree
-u -m $head $SHA1 ||
exit
92 MRC
=$SHA1 MRT
=$
(git write-tree
)
98 eval_gettextln
"Trying simple merge with \$pretty_name"
99 git read-tree
-u -m --aggressive $common $MRT $SHA1 ||
exit 2
100 next
=$
(git write-tree
2>/dev
/null
)
103 gettextln
"Simple merge did not work, trying automatic merge."
104 git-merge-index
-o git-merge-one-file
-a ||
106 next
=$
(git write-tree
2>/dev
/null
)
113 exit "$OCTOPUS_FAILURE"