3 # Copyright (c) 2005 Junio C Hamano
5 # Resolve two or more trees.
13 # The first parameters up to -- are merge bases; the rest are heads.
14 bases
= head= remotes
= sep_seen
=
17 case ",$sep_seen,$head,$arg," in
25 remotes
="$remotes$arg "
33 # Reject if this is not an octopus -- resolve should be used instead.
41 # MRC is the current "merge reference commit"
42 # MRT is the current "merge result tree"
44 if ! git diff-index
--quiet --cached HEAD
--
46 gettextln
"Error: Your local changes to the following files would be overwritten by merge"
47 git diff-index
--cached --name-only HEAD
-- |
sed -e 's/^/ /'
50 MRC
=$
(git rev-parse
--verify -q $head)
56 case "$OCTOPUS_FAILURE" in
58 # We allow only last one to have a hand-resolvable
59 # conflicts. Last round failed and we still had
61 gettextln
"Automated merge did not work."
62 gettextln
"Should not be doing an octopus."
66 eval pretty_name
=\
${GITHEAD_$SHA1:-$SHA1}
67 if test "$SHA1" = "$pretty_name"
69 SHA1_UP
="$(echo "$SHA1" | tr a-z A-Z)"
70 eval pretty_name
=\
${GITHEAD_$SHA1_UP:-$pretty_name}
72 common
=$
(git merge-base
--all $SHA1 $MRC) ||
73 die
"$(eval_gettext "Unable to
find common commit with \
$pretty_name")"
75 case "$LF$common$LF" in
77 eval_gettextln
"Already up-to-date with \$pretty_name"
82 if test "$common,$NON_FF_MERGE" = "$MRC,0"
84 # The first head being merged was a fast-forward.
85 # Advance MRC to the head being merged, and use that
86 # tree as the intermediate result of the merge.
87 # We still need to count this as part of the parent set.
89 eval_gettextln
"Fast-forwarding to: \$pretty_name"
90 git read-tree
-u -m $head $SHA1 ||
exit
91 MRC
=$SHA1 MRT
=$
(git write-tree
)
97 eval_gettextln
"Trying simple merge with \$pretty_name"
98 git read-tree
-u -m --aggressive $common $MRT $SHA1 ||
exit 2
99 next
=$
(git write-tree
2>/dev
/null
)
102 gettextln
"Simple merge did not work, trying automatic merge."
103 git merge-index
-o git-merge-one-file
-a ||
105 next
=$
(git write-tree
2>/dev
/null
)
112 exit "$OCTOPUS_FAILURE"