]>
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 LT |
8 | # $4 - pathname in repository |
9 | # | |
10 | # | |
e3b4be7f LT |
11 | # Handle some trivial cases.. The _really_ trivial cases have |
12 | # been handled already by read-tree, but that one doesn't | |
13 | # do any merges that migth change the tree layout | |
839a7a06 | 14 | # |
e3b4be7f | 15 | |
0a9ea850 JB |
16 | # if the directory is newly added in a branch, it might not exist |
17 | # in the current tree | |
18 | dir=$(dirname "$4") | |
19 | mkdir -p "$dir" | |
20 | ||
e3b4be7f | 21 | case "${1:-.}${2:-.}${3:-.}" in |
839a7a06 | 22 | # |
e3b4be7f | 23 | # deleted in both, or deleted in one and unchanged in the other |
839a7a06 | 24 | # |
e3b4be7f LT |
25 | "$1.." | "$1.$1" | "$1$1.") |
26 | rm -f -- "$4" | |
27 | update-cache --remove -- "$4" | |
839a7a06 | 28 | exit 0 |
e3b4be7f LT |
29 | ;; |
30 | ||
839a7a06 | 31 | # |
e3b4be7f | 32 | # added in one, or added identically in both |
839a7a06 | 33 | # |
e3b4be7f LT |
34 | ".$2." | "..$3" | ".$2$2") |
35 | mv $(unpack-file "${2:-$3}") $4 | |
36 | update-cache --add -- $4 | |
37 | exit 0 | |
38 | ;; | |
39 | ||
40 | # | |
41 | # Modified in both, but differently ;( | |
42 | # | |
43 | "$1$2$3") | |
44 | echo "Auto-merging $4" | |
45 | orig=$(unpack-file $1) | |
46 | src1=$(unpack-file $2) | |
47 | src2=$(unpack-file $3) | |
0a9ea850 JB |
48 | merge "$src2" "$orig" "$src1" |
49 | if [ $? -ne 0 ]; then | |
50 | echo Leaving conflict merge in $src2 | |
51 | exit 1 | |
52 | fi | |
e3b4be7f LT |
53 | cp "$src2" "$4" && update-cache --add -- "$4" && exit 0 |
54 | ;; | |
55 | ||
56 | *) | |
57 | echo "Not handling case $1 -> $2 -> $3" | |
58 | ;; | |
59 | esac | |
60 | exit 1 |