|
6 | 6 | # $2 - file in branch1 SHA1 (or empty) |
7 | 7 | # $3 - file in branch2 SHA1 (or empty) |
8 | 8 | # $4 - pathname in repository |
9 | | -# |
| 9 | +# $5 - orignal file mode (or empty) |
| 10 | +# $6 - file in branch1 mode (or empty) |
| 11 | +# $7 - file in branch2 mode (or empty) |
10 | 12 | # |
11 | 13 | # Handle some trivial cases.. The _really_ trivial cases have |
12 | 14 | # 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 |
18 | | -dir=$(dirname "$4") |
19 | | -mkdir -p "$dir" || exit |
| 15 | +# do any merges that migth change the tree layout. |
20 | 16 |
|
21 | 17 | case "${1:-.}${2:-.}${3:-.}" in |
22 | 18 | # |
23 | | -# deleted in both |
| 19 | +# Deleted in both. |
24 | 20 | # |
25 | 21 | "$1..") |
26 | | - echo "ERROR: $4 is removed in both branches" |
27 | | - echo "ERROR: This is a potential rename conflict" |
| 22 | + echo "ERROR: $4 is removed in both branches." |
| 23 | + echo "ERROR: This is a potential rename conflict." |
28 | 24 | exit 1;; |
29 | 25 | # |
30 | | -# deleted in one and unchanged in the other |
| 26 | +# Deleted in one and unchanged in the other. |
31 | 27 | # |
32 | 28 | "$1.." | "$1.$1" | "$1$1.") |
33 | 29 | echo "Removing $4" |
34 | | - rm -f -- "$4" && exec git-update-cache --remove -- "$4" ;; |
| 30 | + exec git-update-cache --force-remove "$4" ;; |
35 | 31 | # |
36 | | -# added in one |
| 32 | +# Added in one. |
37 | 33 | # |
38 | 34 | ".$2." | "..$3" ) |
39 | 35 | case "$6$7" in *7??) mode=+x;; *) mode=-x;; esac |
40 | | - echo "Adding $4 with perm $mode" |
41 | | - rm -f -- "$4" && |
42 | | - git-cat-file blob "$2$3" >"$4" && |
43 | | - chmod "$mode" -- "$4" && |
44 | | - exec git-update-cache --add -- "$4" ;; |
| 36 | + echo "Adding $4 with perm $mode." |
| 37 | + exec git-update-cache --add --cacheinfo "$6$7" "$2$3" "$4" ;; |
45 | 38 | # |
46 | | -# Added in both (check for same permissions) |
| 39 | +# Added in both (check for same permissions). |
47 | 40 | # |
48 | | -".$2$2") |
| 41 | +".$3$2") |
49 | 42 | if [ "$6" != "$7" ]; then |
50 | | - echo "ERROR: File $4 added in both branches, permissions conflict $6->$7" |
| 43 | + echo "ERROR: File $4 added identically in both branches," |
| 44 | + echo "ERROR: but permissions conflict $6->$7." |
51 | 45 | exit 1 |
52 | 46 | fi |
53 | 47 | case "$6" in *7??) mode=+x;; *) mode=-x;; esac |
54 | 48 | echo "Adding $4 with perm $mode" |
55 | | - rm -f -- "$4" && |
56 | | - git-cat-file blob "$2" >"$4" && |
57 | | - chmod "$mode" -- "$4" && |
58 | | - exec git-update-cache --add -- "$4" ;; |
| 49 | + exec git-update-cache --add --cacheinfo "$6" "$2" "$4" ;; |
59 | 50 | # |
60 | | -# Modified in both, but differently ;( |
| 51 | +# Modified in both, but differently. |
61 | 52 | # |
62 | 53 | "$1$2$3") |
63 | | - echo "Auto-merging $4" |
| 54 | + echo "Auto-merging $4." |
64 | 55 | orig=$(git-unpack-file $1) |
65 | 56 | src1=$(git-unpack-file $2) |
66 | 57 | src2=$(git-unpack-file $3) |
67 | 58 | merge "$src2" "$orig" "$src1" |
68 | 59 | ret=$? |
69 | 60 | 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" |
73 | | - fi |
74 | | - exit 1 |
| 61 | + echo "ERROR: Permissions $5->$6->$7 don't match." |
75 | 62 | fi |
76 | 63 | if [ $ret -ne 0 ]; then |
77 | | - echo "ERROR: Leaving conflict merge in $src2" |
| 64 | + echo "ERROR: Leaving conflict merge in $src2." |
78 | 65 | exit 1 |
79 | 66 | fi |
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" ;; |
| 67 | + sha1=$(git-write-blob "$src2") || { |
| 68 | + echo "ERROR: Leaving conflict merge in $src2." |
| 69 | + } |
| 70 | + exec git-update-cache --add --cacheinfo "$6" $sha1 "$4" ;; |
83 | 71 | *) |
84 | | - echo "Not handling case $4: $1 -> $2 -> $3" ;; |
| 72 | + echo "ERROR: Not handling case $4: $1 -> $2 -> $3" ;; |
85 | 73 | esac |
86 | 74 | exit 1 |
0 commit comments