@@ -27,7 +27,7 @@ SUBDIRECTORY_OK=Yes
27
27
cd_to_toplevel
28
28
require_work_tree
29
29
30
- if ! test " $# " -eq 7
30
+ if test $# ! = 7
31
31
then
32
32
echo " $LONG_USAGE "
33
33
exit 1
@@ -38,7 +38,8 @@ case "${1:-.}${2:-.}${3:-.}" in
38
38
# Deleted in both or deleted in one and unchanged in the other
39
39
#
40
40
" $1 .." | " $1 .$1 " | " $1$1 ." )
41
- if [ " $2 " ]; then
41
+ if test -n " $2 "
42
+ then
42
43
echo " Removing $4 "
43
44
else
44
45
# read-tree checked that index matches HEAD already,
@@ -48,7 +49,8 @@ case "${1:-.}${2:-.}${3:-.}" in
48
49
# we do not have it in the index, though.
49
50
exec git update-index --remove -- " $4 "
50
51
fi
51
- if test -f " $4 " ; then
52
+ if test -f " $4 "
53
+ then
52
54
rm -f -- " $4 " &&
53
55
rmdir -p " $( expr " z$4 " : ' z\(.*\)/' ) " 2> /dev/null || :
54
56
fi &&
@@ -67,7 +69,7 @@ case "${1:-.}${2:-.}${3:-.}" in
67
69
echo " Adding $4 "
68
70
if test -f " $4 "
69
71
then
70
- echo " ERROR: untracked $4 is overwritten by the merge."
72
+ echo " ERROR: untracked $4 is overwritten by the merge." >&2
71
73
exit 1
72
74
fi
73
75
git update-index --add --cacheinfo " $7 " " $3 " " $4 " &&
@@ -78,9 +80,10 @@ case "${1:-.}${2:-.}${3:-.}" in
78
80
# Added in both, identically (check for same permissions).
79
81
#
80
82
" .$3$2 " )
81
- if [ " $6 " != " $7 " ]; then
82
- echo " ERROR: File $4 added identically in both branches,"
83
- echo " ERROR: but permissions conflict $6 ->$7 ."
83
+ if test " $6 " ! = " $7 "
84
+ then
85
+ echo " ERROR: File $4 added identically in both branches," >&2
86
+ echo " ERROR: but permissions conflict $6 ->$7 ." >&2
84
87
exit 1
85
88
fi
86
89
echo " Adding $4 "
@@ -95,71 +98,63 @@ case "${1:-.}${2:-.}${3:-.}" in
95
98
96
99
case " ,$6 ,$7 ," in
97
100
* ,120000,* )
98
- echo " ERROR: $4 : Not merging symbolic link changes."
101
+ echo " ERROR: $4 : Not merging symbolic link changes." >&2
99
102
exit 1
100
103
;;
101
104
* ,160000,* )
102
- echo " ERROR: $4 : Not merging conflicting submodule changes."
105
+ echo " ERROR: $4 : Not merging conflicting submodule changes." >&2
103
106
exit 1
104
107
;;
105
108
esac
106
109
107
- src2=` git-unpack-file $3 `
110
+ src1=$( git-unpack-file $2 )
111
+ src2=$( git-unpack-file $3 )
108
112
case " $1 " in
109
113
' ' )
110
114
echo " Added $4 in both, but differently."
111
- # This extracts OUR file in $orig, and uses git apply to
112
- # remove lines that are unique to ours.
113
- orig=` git-unpack-file $2 `
114
- sz0=` wc -c < " $orig " `
115
- @@DIFF@@ -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add
116
- sz1=` wc -c < " $orig " `
117
-
118
- # If we do not have enough common material, it is not
119
- # worth trying two-file merge using common subsections.
120
- expr $sz0 \< $sz1 \* 2 > /dev/null || : > $orig
115
+ orig=$( git-unpack-file $2 )
116
+ create_virtual_base " $orig " " $src2 "
121
117
;;
122
118
* )
123
119
echo " Auto-merging $4 "
124
- orig=` git-unpack-file $1 `
120
+ orig=$( git-unpack-file $1 )
125
121
;;
126
122
esac
127
123
128
- # Be careful for funny filename such as "-L" in "$4", which
129
- # would confuse "merge" greatly.
130
- src1=` git-unpack-file $2 `
131
124
git merge-file " $src1 " " $orig " " $src2 "
132
125
ret=$?
133
126
msg=
134
- if [ $ret -ne 0 ]; then
127
+ if test $ret ! = 0 || test -z " $1 "
128
+ then
135
129
msg=' content conflict'
130
+ ret=1
136
131
fi
137
132
138
133
# Create the working tree file, using "our tree" version from the
139
134
# index, and then store the result of the merge.
140
135
git checkout-index -f --stage=2 -- " $4 " && cat " $src1 " > " $4 " || exit 1
141
136
rm -f -- " $orig " " $src1 " " $src2 "
142
137
143
- if [ " $6 " != " $7 " ]; then
144
- if [ -n " $msg " ]; then
138
+ if test " $6 " ! = " $7 "
139
+ then
140
+ if test -n " $msg "
141
+ then
145
142
msg=" $msg , "
146
143
fi
147
144
msg=" ${msg} permissions conflict: $5 ->$6 ,$7 "
148
145
ret=1
149
146
fi
150
- if [ " $1 " = ' ' ]; then
151
- ret=1
152
- fi
153
147
154
- if [ $ret -ne 0 ]; then
155
- echo " ERROR: $msg in $4 "
148
+ if test $ret ! = 0
149
+ then
150
+ echo " ERROR: $msg in $4 " >&2
156
151
exit 1
157
152
fi
158
153
exec git update-index -- " $4 "
159
154
;;
160
155
161
156
* )
162
- echo " ERROR: $4 : Not handling case $1 -> $2 -> $3 "
157
+ echo " ERROR: $4 : Not handling case $1 -> $2 -> $3 " >&2
163
158
;;
164
159
esac
165
160
exit 1
0 commit comments