@@ -114,6 +114,33 @@ valid_tool () {
114
114
test -n " $cmd "
115
115
}
116
116
117
+ setup_user_tool () {
118
+ merge_tool_cmd=$( get_merge_tool_cmd " $tool " )
119
+ test -n " $merge_tool_cmd " || return 1
120
+
121
+ diff_cmd () {
122
+ ( eval $merge_tool_cmd )
123
+ status=$?
124
+ return $status
125
+ }
126
+
127
+ merge_cmd () {
128
+ trust_exit_code=$( git config --bool \
129
+ " mergetool.$1 .trustExitCode" || echo false)
130
+ if test " $trust_exit_code " = " false"
131
+ then
132
+ touch " $BACKUP "
133
+ ( eval $merge_tool_cmd )
134
+ status=$?
135
+ check_unchanged
136
+ else
137
+ ( eval $merge_tool_cmd )
138
+ status=$?
139
+ fi
140
+ return $status
141
+ }
142
+ }
143
+
117
144
setup_tool () {
118
145
tool=" $1 "
119
146
@@ -142,15 +169,15 @@ setup_tool () {
142
169
143
170
if ! test -f " $MERGE_TOOLS_DIR /$tool "
144
171
then
145
- # Use a special return code for this case since we want to
146
- # source "defaults" even when an explicit tool path is
147
- # configured since the user can use that to override the
148
- # default path in the scriptlet.
149
- return 2
172
+ setup_user_tool
173
+ return $?
150
174
fi
151
175
152
176
# Load the redefined functions
153
177
. " $MERGE_TOOLS_DIR /$tool "
178
+ # Now let the user override the default command for the tool. If
179
+ # they have not done so then this will return 1 which we ignore.
180
+ setup_user_tool
154
181
155
182
if merge_mode && ! can_merge
156
183
then
@@ -187,20 +214,7 @@ run_merge_tool () {
187
214
status=0
188
215
189
216
# Bring tool-specific functions into scope
190
- setup_tool " $1 "
191
- exitcode=$?
192
- case $exitcode in
193
- 0)
194
- :
195
- ;;
196
- 2)
197
- # The configured tool is not a built-in tool.
198
- test -n " $merge_tool_path " || return 1
199
- ;;
200
- * )
201
- return $exitcode
202
- ;;
203
- esac
217
+ setup_tool " $1 " || return 1
204
218
205
219
if merge_mode
206
220
then
@@ -213,38 +227,12 @@ run_merge_tool () {
213
227
214
228
# Run a either a configured or built-in diff tool
215
229
run_diff_cmd () {
216
- merge_tool_cmd=$( get_merge_tool_cmd " $1 " )
217
- if test -n " $merge_tool_cmd "
218
- then
219
- ( eval $merge_tool_cmd )
220
- status=$?
221
- return $status
222
- else
223
- diff_cmd " $1 "
224
- fi
230
+ diff_cmd " $1 "
225
231
}
226
232
227
233
# Run a either a configured or built-in merge tool
228
234
run_merge_cmd () {
229
- merge_tool_cmd=$( get_merge_tool_cmd " $1 " )
230
- if test -n " $merge_tool_cmd "
231
- then
232
- trust_exit_code=$( git config --bool \
233
- " mergetool.$1 .trustExitCode" || echo false)
234
- if test " $trust_exit_code " = " false"
235
- then
236
- touch " $BACKUP "
237
- ( eval $merge_tool_cmd )
238
- status=$?
239
- check_unchanged
240
- else
241
- ( eval $merge_tool_cmd )
242
- status=$?
243
- fi
244
- return $status
245
- else
246
- merge_cmd " $1 "
247
- fi
235
+ merge_cmd " $1 "
248
236
}
249
237
250
238
list_merge_tool_candidates () {
0 commit comments