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
19 mkdir
-p "$dir" ||
exit
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.")
34 rm -f -- "$4" && exec git-update-cache
--remove -- "$4" ;;
39 case "$6$7" in *7??
) mode
=+x
;; *) mode
=-x;; esac
40 echo "Adding $4 with perm $mode"
42 git-cat-file blob
"$2$3" >"$4" &&
43 chmod "$mode" -- "$4" &&
44 exec git-update-cache
--add -- "$4" ;;
46 # Added in both (check for same permissions)
49 if [ "$6" != "$7" ]; then
50 echo "ERROR: File $4 added in both branches, permissions conflict $6->$7"
53 case "$6" in *7??
) mode
=+x
;; *) mode
=-x;; esac
54 echo "Adding $4 with perm $mode"
56 git-cat-file blob
"$2" >"$4" &&
57 chmod "$mode" -- "$4" &&
58 exec git-update-cache
--add -- "$4" ;;
60 # Modified in both, but differently ;(
63 echo "Auto-merging $4"
64 orig
=$
(git-unpack-file
$1)
65 src1
=$
(git-unpack-file
$2)
66 src2
=$
(git-unpack-file
$3)
67 merge
"$src2" "$orig" "$src1"
69 if [ "$6" != "$7" ]; then
70 echo "ERROR: Permissions $5->$6->$7 don't match merging $src2"
71 if [ $ret -ne 0 ]; then
72 echo "ERROR: Leaving conflict merge in $src2"
76 if [ $ret -ne 0 ]; then
77 echo "ERROR: Leaving conflict merge in $src2"
80 case "$6" in *7??
) mode
=+x
;; *) mode
=-x;; esac
81 rm -f -- "$4" && cat "$src2" >"$4" && chmod "$mode" -- "$4" &&
82 exec git-update-cache
--add -- "$4" ;;
84 echo "Not handling case $4: $1 -> $2 -> $3" ;;