3 # This is the git merge script, called with
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
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
16 # if the directory is newly added in a branch, it might not exist
21 case "${1:-.}${2:-.}${3:-.}" in
26 echo "ERROR: $4 is removed in both branches"
27 echo "ERROR: This is a potential rename conflict"
30 # deleted in one and unchanged in the other
32 "$1.." | "$1.$1" | "$1$1.")
35 git-update-cache --remove -- "$4"
43 echo "Adding $4 with perm $6$7"
44 mv $(git-unpack-file "$2$3") $4
46 git-update-cache --add -- $4
50 # Added in both (check for same permissions)
53 if [ "$6" != "$7" ]; then
54 echo "ERROR: File $4 added in both branches, permissions conflict $6->$7"
57 echo "Adding $4 with perm $6"
58 mv $(git-unpack-file "$2") $4
60 git-update-cache --add -- $4
63 # Modified in both, but differently ;(
66 echo "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"
72 if [ "$6" != "$7" ]; then
73 echo "ERROR: Permissions $5->$6->$7 don't match merging $src2"
74 if [ $ret -ne 0 ]; then
75 echo "ERROR: Leaving conflict merge in $src2"
80 if [ $ret -ne 0 ]; then
81 echo "ERROR: Leaving conflict merge in $src2"
84 cp -- "$src2" "$4" && chmod -- "$6" "$4" && git-update-cache --add -- "$4" && exit 0
88 echo "Not handling case $1 -> $2 -> $3"