1#!/bin/sh 2# 3# This is the git merge script, called with 4# 5# $1 - original file SHA1 (or empty) 6# $2 - file in branch1 SHA1 (or empty) 7# $3 - file in branch2 SHA1 (or empty) 8# $4 - pathname in repository 9# 10# 11# Handle some trivial cases.. The _really_ trivial cases have 12# been handled already by git-read-tree, but that one doesn't 13# do any merges that migth change the tree layout 14# 15 16# if the directory is newly added in a branch, it might not exist 17# in the current tree 18dir=$(dirname "$4") 19mkdir-p"$dir" 20 21case"${1:-.}${2:-.}${3:-.}"in 22# 23# deleted in both 24# 25"$1..") 26echo"ERROR:$4is removed in both branches" 27echo"ERROR: This is a potential rename conflict" 28exit1;; 29# 30# deleted in one and unchanged in the other 31# 32"$1.."|"$1.$1"|"$1$1.") 33rm-f --"$4" 34echo"Removing$4" 35 git-update-cache --remove --"$4" 36exit0 37;; 38 39# 40# added in one 41# 42".$2."|"..$3") 43echo"Adding$4with perm$6$7" 44mv$(git-unpack-file "$2$3") $4 45chmod"$6$7"$4 46 git-update-cache --add --$4 47exit0 48;; 49# 50# Added in both (check for same permissions) 51# 52".$2$2") 53if["$6"!="$7"];then 54echo"ERROR: File$4added in both branches, permissions conflict$6->$7" 55exit1 56fi 57echo"Adding$4with perm$6" 58mv$(git-unpack-file "$2") $4 59chmod"$6"$4 60 git-update-cache --add --$4 61exit0;; 62# 63# Modified in both, but differently ;( 64# 65"$1$2$3") 66echo"Auto-merging$4" 67 orig=$(git-unpack-file $1) 68 src1=$(git-unpack-file $2) 69 src2=$(git-unpack-file $3) 70 merge "$src2""$orig""$src1" 71 ret=$? 72if["$6"!="$7"];then 73echo"ERROR: Permissions$5->$6->$7don't match merging$src2" 74if[$ret-ne0];then 75echo"ERROR: Leaving conflict merge in$src2" 76fi 77exit1 78fi 79chmod--"$6""$src2" 80if[$ret-ne0];then 81echo"ERROR: Leaving conflict merge in$src2" 82exit1 83fi 84cp--"$src2""$4"&&chmod--"$6""$4"&& git-update-cache --add --"$4"&&exit0 85;; 86 87*) 88echo"Not handling case$1->$2->$3" 89;; 90esac 91exit1