]>
Commit | Line | Data |
---|---|---|
839a7a06 LT |
1 | #!/bin/sh |
2 | # | |
3 | # This is the git merge script, called with | |
4 | # | |
e3b4be7f LT |
5 | # $1 - original file SHA1 (or empty) |
6 | # $2 - file in branch1 SHA1 (or empty) | |
7 | # $3 - file in branch2 SHA1 (or empty) | |
839a7a06 | 8 | # $4 - pathname in repository |
ee28152d JH |
9 | # $5 - orignal file mode (or empty) |
10 | # $6 - file in branch1 mode (or empty) | |
11 | # $7 - file in branch2 mode (or empty) | |
839a7a06 | 12 | # |
e3b4be7f | 13 | # Handle some trivial cases.. The _really_ trivial cases have |
0fc65a45 | 14 | # been handled already by git-read-tree, but that one doesn't |
ee28152d | 15 | # do any merges that migth change the tree layout. |
0a9ea850 | 16 | |
e3b4be7f | 17 | case "${1:-.}${2:-.}${3:-.}" in |
839a7a06 | 18 | # |
ee28152d | 19 | # Deleted in both. |
e2b6a9d0 JB |
20 | # |
21 | "$1..") | |
2a68a865 LT |
22 | echo "WARNING: $4 is removed in both branches." |
23 | echo "WARNING: This is a potential rename conflict." | |
24 | exec git-update-cache --remove -- "$4" ;; | |
e2b6a9d0 | 25 | # |
ee28152d | 26 | # Deleted in one and unchanged in the other. |
839a7a06 | 27 | # |
e3b4be7f | 28 | "$1.." | "$1.$1" | "$1$1.") |
e2b6a9d0 | 29 | echo "Removing $4" |
2a68a865 LT |
30 | rm -f -- "$4" |
31 | exec git-update-cache --remove -- "$4" ;; | |
839a7a06 | 32 | # |
ee28152d | 33 | # Added in one. |
839a7a06 | 34 | # |
e2b6a9d0 | 35 | ".$2." | "..$3" ) |
21a08dcb | 36 | case "$6$7" in *7??) mode=+x;; *) mode=-x;; esac |
ee28152d | 37 | echo "Adding $4 with perm $mode." |
2a68a865 LT |
38 | git-cat-file blob "$2$3" > "$4" |
39 | chmod $mode -- "$4" | |
40 | exec git-update-cache --add -- "$4" ;; | |
e2b6a9d0 | 41 | # |
ee28152d | 42 | # Added in both (check for same permissions). |
e2b6a9d0 | 43 | # |
ee28152d | 44 | ".$3$2") |
e2b6a9d0 | 45 | if [ "$6" != "$7" ]; then |
ee28152d JH |
46 | echo "ERROR: File $4 added identically in both branches," |
47 | echo "ERROR: but permissions conflict $6->$7." | |
e2b6a9d0 JB |
48 | exit 1 |
49 | fi | |
21a08dcb JH |
50 | case "$6" in *7??) mode=+x;; *) mode=-x;; esac |
51 | echo "Adding $4 with perm $mode" | |
2a68a865 LT |
52 | git-cat-file blob "$2" > "$4" |
53 | chmod $mode -- "$4" | |
54 | exec git-update-cache --add -- "$4" ;; | |
e3b4be7f | 55 | # |
ee28152d | 56 | # Modified in both, but differently. |
e3b4be7f LT |
57 | # |
58 | "$1$2$3") | |
ee28152d | 59 | echo "Auto-merging $4." |
c7d1d4e1 JH |
60 | orig=`git-unpack-file $1` |
61 | src1=`git-unpack-file $2` | |
62 | src2=`git-unpack-file $3` | |
2a68a865 | 63 | merge -p "$src1" "$orig" "$src2" > "$4" |
e2b6a9d0 | 64 | ret=$? |
2a68a865 | 65 | rm -f -- "$orig" "$src1" "$src2" |
e2b6a9d0 | 66 | if [ "$6" != "$7" ]; then |
ee28152d | 67 | echo "ERROR: Permissions $5->$6->$7 don't match." |
2a68a865 | 68 | ret=1 |
e2b6a9d0 | 69 | fi |
e2b6a9d0 | 70 | if [ $ret -ne 0 ]; then |
2a68a865 LT |
71 | # Reset the index to the first branch, making |
72 | # git-diff-file useful | |
73 | git-update-cache --add --cacheinfo "$6" "$2" "$4" | |
74 | echo "ERROR: Merge conflict in $4." | |
0a9ea850 JB |
75 | exit 1 |
76 | fi | |
2a68a865 | 77 | exec git-update-cache --add -- "$4" ;; |
e3b4be7f | 78 | *) |
ee28152d | 79 | echo "ERROR: Not handling case $4: $1 -> $2 -> $3" ;; |
e3b4be7f LT |
80 | esac |
81 | exit 1 |