1#!/bin/sh 2# 3# Copyright (c) 2005 Linus Torvalds 4# Copyright (c) 2005 Junio C Hamano 5# 6# Resolve two trees, using enhanced multi-base read-tree. 7 8# The first parameters up to -- are merge bases; the rest are heads. 9bases=head= remotes= sep_seen= 10for arg 11do 12case",$sep_seen,$head,$arg,"in 13*,--,) 14 sep_seen=yes 15;; 16,yes,,*) 17head=$arg 18;; 19,yes,*) 20 remotes="$remotes$arg" 21;; 22*) 23 bases="$bases$arg" 24;; 25esac 26done 27 28# Give up if we are given more than two remotes -- not handling octopus. 29case"$remotes"in 30?*' '?*) 31exit2;; 32esac 33 34# Give up if this is a baseless merge. 35iftest''="$bases" 36then 37exit2 38fi 39 40git update-index --refresh2>/dev/null 41git read-tree -u -m --aggressive$bases $head $remotes||exit2 42echo"Trying simple merge." 43if result_tree=$(git write-tree 2>/dev/null) 44then 45exit0 46else 47echo"Simple merge failed, trying Automatic merge." 48if git-merge-index -o git-merge-one-file -a 49then 50exit0 51else 52exit1 53fi 54fi