@@ -32,10 +32,12 @@ translate_merge_tool_path () {
3232}
3333
3434check_unchanged () {
35- if test " $MERGED " -nt " $BACKUP " ; then
35+ if test " $MERGED " -nt " $BACKUP "
36+ then
3637 status=0
3738 else
38- while true ; do
39+ while true
40+ do
3941 echo " $MERGED seems unchanged."
4042 printf " Was the merge successful? [y/n] "
4143 read answer
@@ -53,17 +55,20 @@ valid_tool () {
5355 kdiff3 | meld | opendiff | p4merge | tkdiff | vimdiff | vimdiff2 | xxdiff)
5456 ;; # happy
5557 kompare)
56- if ! diff_mode; then
58+ if ! diff_mode
59+ then
5760 return 1
5861 fi
5962 ;;
6063 tortoisemerge)
61- if ! merge_mode; then
64+ if ! merge_mode
65+ then
6266 return 1
6367 fi
6468 ;;
6569 * )
66- if test -z " $( get_merge_tool_cmd " $1 " ) " ; then
70+ if test -z " $( get_merge_tool_cmd " $1 " ) "
71+ then
6772 return 1
6873 fi
6974 ;;
@@ -72,12 +77,14 @@ valid_tool () {
7277
7378get_merge_tool_cmd () {
7479 # Prints the custom command for a merge tool
75- if test -n " $1 " ; then
80+ if test -n " $1 "
81+ then
7682 merge_tool=" $1 "
7783 else
7884 merge_tool=" $( get_merge_tool) "
7985 fi
80- if diff_mode; then
86+ if diff_mode
87+ then
8188 echo " $( git config difftool.$merge_tool .cmd ||
8289 git config mergetool.$merge_tool .cmd) "
8390 else
@@ -97,9 +104,11 @@ run_merge_tool () {
97104
98105 case " $1 " in
99106 araxis)
100- if merge_mode; then
107+ if merge_mode
108+ then
101109 touch " $BACKUP "
102- if $base_present ; then
110+ if $base_present
111+ then
103112 " $merge_tool_path " -wait -merge -3 -a1 \
104113 " $BASE " " $LOCAL " " $REMOTE " " $MERGED " \
105114 > /dev/null 2>&1
@@ -115,9 +124,11 @@ run_merge_tool () {
115124 fi
116125 ;;
117126 bc3)
118- if merge_mode; then
127+ if merge_mode
128+ then
119129 touch " $BACKUP "
120- if $base_present ; then
130+ if $base_present
131+ then
121132 " $merge_tool_path " " $LOCAL " " $REMOTE " " $BASE " \
122133 -mergeoutput=" $MERGED "
123134 else
@@ -130,9 +141,11 @@ run_merge_tool () {
130141 fi
131142 ;;
132143 diffuse)
133- if merge_mode; then
144+ if merge_mode
145+ then
134146 touch " $BACKUP "
135- if $base_present ; then
147+ if $base_present
148+ then
136149 " $merge_tool_path " \
137150 " $LOCAL " " $MERGED " " $REMOTE " \
138151 " $BASE " | cat
@@ -146,9 +159,11 @@ run_merge_tool () {
146159 fi
147160 ;;
148161 ecmerge)
149- if merge_mode; then
162+ if merge_mode
163+ then
150164 touch " $BACKUP "
151- if $base_present ; then
165+ if $base_present
166+ then
152167 " $merge_tool_path " " $BASE " " $LOCAL " " $REMOTE " \
153168 --default --mode=merge3 --to=" $MERGED "
154169 else
@@ -162,8 +177,10 @@ run_merge_tool () {
162177 fi
163178 ;;
164179 emerge)
165- if merge_mode; then
166- if $base_present ; then
180+ if merge_mode
181+ then
182+ if $base_present
183+ then
167184 " $merge_tool_path " \
168185 -f emerge-files-with-ancestor-command \
169186 " $LOCAL " " $REMOTE " " $BASE " \
@@ -181,9 +198,11 @@ run_merge_tool () {
181198 fi
182199 ;;
183200 gvimdiff|vimdiff)
184- if merge_mode; then
201+ if merge_mode
202+ then
185203 touch " $BACKUP "
186- if $base_present ; then
204+ if $base_present
205+ then
187206 " $merge_tool_path " -f -d -c " wincmd J" \
188207 " $MERGED " " $LOCAL " " $BASE " " $REMOTE "
189208 else
@@ -198,7 +217,8 @@ run_merge_tool () {
198217 fi
199218 ;;
200219 gvimdiff2|vimdiff2)
201- if merge_mode; then
220+ if merge_mode
221+ then
202222 touch " $BACKUP "
203223 " $merge_tool_path " -f -d -c " wincmd l" \
204224 " $LOCAL " " $MERGED " " $REMOTE "
@@ -210,36 +230,39 @@ run_merge_tool () {
210230 fi
211231 ;;
212232 kdiff3)
213- if merge_mode; then
214- if $base_present ; then
215- (" $merge_tool_path " --auto \
233+ if merge_mode
234+ then
235+ if $base_present
236+ then
237+ " $merge_tool_path " --auto \
216238 --L1 " $MERGED (Base)" \
217239 --L2 " $MERGED (Local)" \
218240 --L3 " $MERGED (Remote)" \
219241 -o " $MERGED " \
220242 " $BASE " " $LOCAL " " $REMOTE " \
221- > /dev/null 2>&1 )
243+ > /dev/null 2>&1
222244 else
223- ( " $merge_tool_path " --auto \
245+ " $merge_tool_path " --auto \
224246 --L1 " $MERGED (Local)" \
225247 --L2 " $MERGED (Remote)" \
226248 -o " $MERGED " \
227249 " $LOCAL " " $REMOTE " \
228- > /dev/null 2>&1 )
250+ > /dev/null 2>&1
229251 fi
230252 status=$?
231253 else
232- ( " $merge_tool_path " --auto \
254+ " $merge_tool_path " --auto \
233255 --L1 " $MERGED (A)" \
234256 --L2 " $MERGED (B)" " $LOCAL " " $REMOTE " \
235- > /dev/null 2>&1 )
257+ > /dev/null 2>&1
236258 fi
237259 ;;
238260 kompare)
239261 " $merge_tool_path " " $LOCAL " " $REMOTE "
240262 ;;
241263 meld)
242- if merge_mode; then
264+ if merge_mode
265+ then
243266 touch " $BACKUP "
244267 " $merge_tool_path " " $LOCAL " " $MERGED " " $REMOTE "
245268 check_unchanged
@@ -248,9 +271,11 @@ run_merge_tool () {
248271 fi
249272 ;;
250273 opendiff)
251- if merge_mode; then
274+ if merge_mode
275+ then
252276 touch " $BACKUP "
253- if $base_present ; then
277+ if $base_present
278+ then
254279 " $merge_tool_path " " $LOCAL " " $REMOTE " \
255280 -ancestor " $BASE " \
256281 -merge " $MERGED " | cat
@@ -264,7 +289,8 @@ run_merge_tool () {
264289 fi
265290 ;;
266291 p4merge)
267- if merge_mode; then
292+ if merge_mode
293+ then
268294 touch " $BACKUP "
269295 $base_present || > " $BASE "
270296 " $merge_tool_path " " $BASE " " $LOCAL " " $REMOTE " " $MERGED "
@@ -274,8 +300,10 @@ run_merge_tool () {
274300 fi
275301 ;;
276302 tkdiff)
277- if merge_mode; then
278- if $base_present ; then
303+ if merge_mode
304+ then
305+ if $base_present
306+ then
279307 " $merge_tool_path " -a " $BASE " \
280308 -o " $MERGED " " $LOCAL " " $REMOTE "
281309 else
@@ -288,7 +316,8 @@ run_merge_tool () {
288316 fi
289317 ;;
290318 tortoisemerge)
291- if $base_present ; then
319+ if $base_present
320+ then
292321 touch " $BACKUP "
293322 " $merge_tool_path " \
294323 -base:" $BASE " -mine:" $LOCAL " \
@@ -300,9 +329,11 @@ run_merge_tool () {
300329 fi
301330 ;;
302331 xxdiff)
303- if merge_mode; then
332+ if merge_mode
333+ then
304334 touch " $BACKUP "
305- if $base_present ; then
335+ if $base_present
336+ then
306337 " $merge_tool_path " -X --show-merged-pane \
307338 -R ' Accel.SaveAsMerged: "Ctrl-S"' \
308339 -R ' Accel.Search: "Ctrl+F"' \
@@ -327,16 +358,20 @@ run_merge_tool () {
327358 ;;
328359 * )
329360 merge_tool_cmd=" $( get_merge_tool_cmd " $1 " ) "
330- if test -z " $merge_tool_cmd " ; then
331- if merge_mode; then
361+ if test -z " $merge_tool_cmd "
362+ then
363+ if merge_mode
364+ then
332365 status=1
333366 fi
334367 break
335368 fi
336- if merge_mode; then
369+ if merge_mode
370+ then
337371 trust_exit_code=" $( git config --bool \
338372 mergetool." $1 " .trustExitCode || echo false) "
339- if test " $trust_exit_code " = " false" ; then
373+ if test " $trust_exit_code " = " false"
374+ then
340375 touch " $BACKUP "
341376 ( eval $merge_tool_cmd )
342377 check_unchanged
@@ -353,13 +388,16 @@ run_merge_tool () {
353388}
354389
355390guess_merge_tool () {
356- if merge_mode; then
391+ if merge_mode
392+ then
357393 tools=" tortoisemerge"
358394 else
359395 tools=" kompare"
360396 fi
361- if test -n " $DISPLAY " ; then
362- if test -n " $GNOME_DESKTOP_SESSION_ID " ; then
397+ if test -n " $DISPLAY "
398+ then
399+ if test -n " $GNOME_DESKTOP_SESSION_ID "
400+ then
363401 tools=" meld opendiff kdiff3 tkdiff xxdiff $tools "
364402 else
365403 tools=" opendiff kdiff3 tkdiff xxdiff meld $tools "
@@ -380,7 +418,8 @@ guess_merge_tool () {
380418 for i in $tools
381419 do
382420 merge_tool_path=" $( translate_merge_tool_path " $i " ) "
383- if type " $merge_tool_path " > /dev/null 2>&1 ; then
421+ if type " $merge_tool_path " > /dev/null 2>&1
422+ then
384423 echo " $i "
385424 return 0
386425 fi
@@ -393,12 +432,14 @@ guess_merge_tool () {
393432get_configured_merge_tool () {
394433 # Diff mode first tries diff.tool and falls back to merge.tool.
395434 # Merge mode only checks merge.tool
396- if diff_mode; then
435+ if diff_mode
436+ then
397437 merge_tool=$( git config diff.tool || git config merge.tool)
398438 else
399439 merge_tool=$( git config merge.tool)
400440 fi
401- if test -n " $merge_tool " && ! valid_tool " $merge_tool " ; then
441+ if test -n " $merge_tool " && ! valid_tool " $merge_tool "
442+ then
402443 echo >&2 " git config option $TOOL_MODE .tool set to unknown tool: $merge_tool "
403444 echo >&2 " Resetting to default..."
404445 return 1
@@ -408,26 +449,31 @@ get_configured_merge_tool () {
408449
409450get_merge_tool_path () {
410451 # A merge tool has been set, so verify that it's valid.
411- if test -n " $1 " ; then
452+ if test -n " $1 "
453+ then
412454 merge_tool=" $1 "
413455 else
414456 merge_tool=" $( get_merge_tool) "
415457 fi
416- if ! valid_tool " $merge_tool " ; then
458+ if ! valid_tool " $merge_tool "
459+ then
417460 echo >&2 " Unknown merge tool $merge_tool "
418461 exit 1
419462 fi
420- if diff_mode; then
463+ if diff_mode
464+ then
421465 merge_tool_path=$( git config difftool." $merge_tool " .path ||
422466 git config mergetool." $merge_tool " .path)
423467 else
424468 merge_tool_path=$( git config mergetool." $merge_tool " .path)
425469 fi
426- if test -z " $merge_tool_path " ; then
470+ if test -z " $merge_tool_path "
471+ then
427472 merge_tool_path=" $( translate_merge_tool_path " $merge_tool " ) "
428473 fi
429474 if test -z " $( get_merge_tool_cmd " $merge_tool " ) " &&
430- ! type " $merge_tool_path " > /dev/null 2>&1 ; then
475+ ! type " $merge_tool_path " > /dev/null 2>&1
476+ then
431477 echo >&2 " The $TOOL_MODE tool $merge_tool is not available as" \
432478 " '$merge_tool_path '"
433479 exit 1
@@ -439,7 +485,8 @@ get_merge_tool () {
439485 # Check if a merge tool has been configured
440486 merge_tool=$( get_configured_merge_tool)
441487 # Try to guess an appropriate merge tool if no tool has been set.
442- if test -z " $merge_tool " ; then
488+ if test -z " $merge_tool "
489+ then
443490 merge_tool=" $( guess_merge_tool) " || exit
444491 fi
445492 echo " $merge_tool "
0 commit comments