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