Browse Source

Merge branch 'ss/mergetool--lib'

* ss/mergetool--lib:
  mergetool--lib: Add Beyond Compare 3 as a tool
  mergetool--lib: Sort tools alphabetically for easier lookup
maint
Junio C Hamano 14 years ago
parent
commit
9d59e6607a
  1. 4
      Documentation/git-difftool.txt
  2. 4
      Documentation/git-mergetool.txt
  3. 8
      Documentation/merge-config.txt
  4. 2
      contrib/completion/git-completion.bash
  5. 225
      git-mergetool--lib.sh

4
Documentation/git-difftool.txt

@ -31,8 +31,8 @@ OPTIONS
--tool=<tool>:: --tool=<tool>::
Use the diff tool specified by <tool>. Use the diff tool specified by <tool>.
Valid merge tools are: Valid merge tools are:
kdiff3, kompare, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, araxis, bc3, diffuse, emerge, ecmerge, gvimdiff, kdiff3,
ecmerge, diffuse, opendiff, p4merge and araxis. kompare, meld, opendiff, p4merge, tkdiff, vimdiff and xxdiff.
+ +
If a diff tool is not specified, 'git difftool' If a diff tool is not specified, 'git difftool'
will use the configuration variable `diff.tool`. If the will use the configuration variable `diff.tool`. If the

4
Documentation/git-mergetool.txt

@ -26,8 +26,8 @@ OPTIONS
--tool=<tool>:: --tool=<tool>::
Use the merge resolution program specified by <tool>. Use the merge resolution program specified by <tool>.
Valid merge tools are: Valid merge tools are:
kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, araxis, bc3, diffuse, ecmerge, emerge, gvimdiff, kdiff3,
diffuse, tortoisemerge, opendiff, p4merge and araxis. meld, opendiff, p4merge, tkdiff, tortoisemerge, vimdiff and xxdiff.
+ +
If a merge resolution program is not specified, 'git mergetool' If a merge resolution program is not specified, 'git mergetool'
will use the configuration variable `merge.tool`. If the will use the configuration variable `merge.tool`. If the

8
Documentation/merge-config.txt

@ -33,10 +33,10 @@ merge.stat::


merge.tool:: merge.tool::
Controls which merge resolution program is used by Controls which merge resolution program is used by
linkgit:git-mergetool[1]. Valid built-in values are: "kdiff3", linkgit:git-mergetool[1]. Valid built-in values are: "araxis",
"tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", "bc3", "diffuse", "ecmerge", "emerge", "gvimdiff", "kdiff3", "meld",
"diffuse", "ecmerge", "tortoisemerge", "p4merge", "araxis" and "opendiff", "p4merge", "tkdiff", "tortoisemerge", "vimdiff"
"opendiff". Any other value is treated is custom merge tool and "xxdiff". Any other value is treated is custom merge tool
and there must be a corresponding mergetool.<tool>.cmd option. and there must be a corresponding mergetool.<tool>.cmd option.


merge.verbosity:: merge.verbosity::

2
contrib/completion/git-completion.bash

@ -1360,7 +1360,7 @@ _git_diff ()
} }


__git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
tkdiff vimdiff gvimdiff xxdiff araxis p4merge tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3
" "


_git_difftool () _git_difftool ()

225
git-mergetool--lib.sh

@ -10,17 +10,20 @@ merge_mode() {


translate_merge_tool_path () { translate_merge_tool_path () {
case "$1" in case "$1" in
vimdiff|vimdiff2) araxis)
echo vim echo compare
;; ;;
gvimdiff|gvimdiff2) bc3)
echo gvim echo bcompare
;; ;;
emerge) emerge)
echo emacs echo emacs
;; ;;
araxis) gvimdiff|gvimdiff2)
echo compare echo gvim
;;
vimdiff|vimdiff2)
echo vim
;; ;;
*) *)
echo "$1" echo "$1"
@ -46,17 +49,16 @@ check_unchanged () {


valid_tool () { valid_tool () {
case "$1" in case "$1" in
kdiff3 | tkdiff | xxdiff | meld | opendiff | \ araxis | bc3 | diffuse | ecmerge | emerge | gvimdiff | gvimdiff2 | \
vimdiff | gvimdiff | vimdiff2 | gvimdiff2 | \ kdiff3 | meld | opendiff | p4merge | tkdiff | vimdiff | vimdiff2 | xxdiff)
emerge | ecmerge | diffuse | araxis | p4merge)
;; # happy ;; # happy
tortoisemerge) kompare)
if ! merge_mode; then if ! diff_mode; then
return 1 return 1
fi fi
;; ;;
kompare) tortoisemerge)
if ! diff_mode; then if ! merge_mode; then
return 1 return 1
fi fi
;; ;;
@ -89,88 +91,91 @@ run_merge_tool () {
status=0 status=0


case "$1" in case "$1" in
kdiff3) araxis)
if merge_mode; then if merge_mode; then
touch "$BACKUP"
if $base_present; then if $base_present; then
("$merge_tool_path" --auto \ "$merge_tool_path" -wait -merge -3 -a1 \
--L1 "$MERGED (Base)" \ "$BASE" "$LOCAL" "$REMOTE" "$MERGED" \
--L2 "$MERGED (Local)" \ >/dev/null 2>&1
--L3 "$MERGED (Remote)" \
-o "$MERGED" \
"$BASE" "$LOCAL" "$REMOTE" \
> /dev/null 2>&1)
else else
("$merge_tool_path" --auto \ "$merge_tool_path" -wait -2 \
--L1 "$MERGED (Local)" \ "$LOCAL" "$REMOTE" "$MERGED" \
--L2 "$MERGED (Remote)" \ >/dev/null 2>&1
-o "$MERGED" \
"$LOCAL" "$REMOTE" \
> /dev/null 2>&1)
fi fi
status=$? check_unchanged
else else
("$merge_tool_path" --auto \ "$merge_tool_path" -wait -2 "$LOCAL" "$REMOTE" \
--L1 "$MERGED (A)" \ >/dev/null 2>&1
--L2 "$MERGED (B)" "$LOCAL" "$REMOTE" \
> /dev/null 2>&1)
fi fi
;; ;;
kompare) bc3)
"$merge_tool_path" "$LOCAL" "$REMOTE"
;;
tkdiff)
if merge_mode; then if merge_mode; then
touch "$BACKUP"
if $base_present; then if $base_present; then
"$merge_tool_path" -a "$BASE" \ "$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" \
-o "$MERGED" "$LOCAL" "$REMOTE" -mergeoutput="$MERGED"
else else
"$merge_tool_path" \ "$merge_tool_path" "$LOCAL" "$REMOTE" \
-o "$MERGED" "$LOCAL" "$REMOTE" -mergeoutput="$MERGED"
fi fi
status=$? check_unchanged
else else
"$merge_tool_path" "$LOCAL" "$REMOTE" "$merge_tool_path" "$LOCAL" "$REMOTE"
fi fi
;; ;;
p4merge) diffuse)
if merge_mode; then if merge_mode; then
touch "$BACKUP" touch "$BACKUP"
if $base_present; then if $base_present; then
"$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" "$MERGED" "$merge_tool_path" \
"$LOCAL" "$MERGED" "$REMOTE" \
"$BASE" | cat
else else
"$merge_tool_path" "$LOCAL" "$LOCAL" "$REMOTE" "$MERGED" "$merge_tool_path" \
"$LOCAL" "$MERGED" "$REMOTE" | cat
fi fi
check_unchanged check_unchanged
else else
"$merge_tool_path" "$LOCAL" "$REMOTE" "$merge_tool_path" "$LOCAL" "$REMOTE" | cat
fi fi
;; ;;
meld) ecmerge)
if merge_mode; then if merge_mode; then
touch "$BACKUP" touch "$BACKUP"
"$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE" if $base_present; then
"$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" \
--default --mode=merge3 --to="$MERGED"
else
"$merge_tool_path" "$LOCAL" "$REMOTE" \
--default --mode=merge2 --to="$MERGED"
fi
check_unchanged check_unchanged
else else
"$merge_tool_path" "$LOCAL" "$REMOTE" "$merge_tool_path" --default --mode=diff2 \
"$LOCAL" "$REMOTE"
fi fi
;; ;;
diffuse) emerge)
if merge_mode; then if merge_mode; then
touch "$BACKUP"
if $base_present; then if $base_present; then
"$merge_tool_path" \ "$merge_tool_path" \
"$LOCAL" "$MERGED" "$REMOTE" \ -f emerge-files-with-ancestor-command \
"$BASE" | cat "$LOCAL" "$REMOTE" "$BASE" \
"$(basename "$MERGED")"
else else
"$merge_tool_path" \ "$merge_tool_path" \
"$LOCAL" "$MERGED" "$REMOTE" | cat -f emerge-files-command \
"$LOCAL" "$REMOTE" \
"$(basename "$MERGED")"
fi fi
check_unchanged status=$?
else else
"$merge_tool_path" "$LOCAL" "$REMOTE" | cat "$merge_tool_path" -f emerge-files-command \
"$LOCAL" "$REMOTE"
fi fi
;; ;;
vimdiff|gvimdiff) gvimdiff|vimdiff)
if merge_mode; then if merge_mode; then
touch "$BACKUP" touch "$BACKUP"
if $base_present; then if $base_present; then
@ -186,7 +191,7 @@ run_merge_tool () {
"$LOCAL" "$REMOTE" "$LOCAL" "$REMOTE"
fi fi
;; ;;
vimdiff2|gvimdiff2) gvimdiff2|vimdiff2)
if merge_mode; then if merge_mode; then
touch "$BACKUP" touch "$BACKUP"
"$merge_tool_path" -f -d -c "wincmd l" \ "$merge_tool_path" -f -d -c "wincmd l" \
@ -197,30 +202,42 @@ run_merge_tool () {
"$LOCAL" "$REMOTE" "$LOCAL" "$REMOTE"
fi fi
;; ;;
xxdiff) kdiff3)
if merge_mode; then if merge_mode; then
touch "$BACKUP"
if $base_present; then if $base_present; then
"$merge_tool_path" -X --show-merged-pane \ ("$merge_tool_path" --auto \
-R 'Accel.SaveAsMerged: "Ctrl-S"' \ --L1 "$MERGED (Base)" \
-R 'Accel.Search: "Ctrl+F"' \ --L2 "$MERGED (Local)" \
-R 'Accel.SearchForward: "Ctrl-G"' \ --L3 "$MERGED (Remote)" \
--merged-file "$MERGED" \ -o "$MERGED" \
"$LOCAL" "$BASE" "$REMOTE" "$BASE" "$LOCAL" "$REMOTE" \
> /dev/null 2>&1)
else else
"$merge_tool_path" -X $extra \ ("$merge_tool_path" --auto \
-R 'Accel.SaveAsMerged: "Ctrl-S"' \ --L1 "$MERGED (Local)" \
-R 'Accel.Search: "Ctrl+F"' \ --L2 "$MERGED (Remote)" \
-R 'Accel.SearchForward: "Ctrl-G"' \ -o "$MERGED" \
--merged-file "$MERGED" \ "$LOCAL" "$REMOTE" \
"$LOCAL" "$REMOTE" > /dev/null 2>&1)
fi fi
status=$?
else
("$merge_tool_path" --auto \
--L1 "$MERGED (A)" \
--L2 "$MERGED (B)" "$LOCAL" "$REMOTE" \
> /dev/null 2>&1)
fi
;;
kompare)
"$merge_tool_path" "$LOCAL" "$REMOTE"
;;
meld)
if merge_mode; then
touch "$BACKUP"
"$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
check_unchanged check_unchanged
else else
"$merge_tool_path" \ "$merge_tool_path" "$LOCAL" "$REMOTE"
-R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl-G"' \
"$LOCAL" "$REMOTE"
fi fi
;; ;;
opendiff) opendiff)
@ -239,39 +256,31 @@ run_merge_tool () {
"$merge_tool_path" "$LOCAL" "$REMOTE" | cat "$merge_tool_path" "$LOCAL" "$REMOTE" | cat
fi fi
;; ;;
ecmerge) p4merge)
if merge_mode; then if merge_mode; then
touch "$BACKUP" touch "$BACKUP"
if $base_present; then if $base_present; then
"$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" \ "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
--default --mode=merge3 --to="$MERGED"
else else
"$merge_tool_path" "$LOCAL" "$REMOTE" \ "$merge_tool_path" "$LOCAL" "$LOCAL" "$REMOTE" "$MERGED"
--default --mode=merge2 --to="$MERGED"
fi fi
check_unchanged check_unchanged
else else
"$merge_tool_path" --default --mode=diff2 \ "$merge_tool_path" "$LOCAL" "$REMOTE"
"$LOCAL" "$REMOTE"
fi fi
;; ;;
emerge) tkdiff)
if merge_mode; then if merge_mode; then
if $base_present; then if $base_present; then
"$merge_tool_path" \ "$merge_tool_path" -a "$BASE" \
-f emerge-files-with-ancestor-command \ -o "$MERGED" "$LOCAL" "$REMOTE"
"$LOCAL" "$REMOTE" "$BASE" \
"$(basename "$MERGED")"
else else
"$merge_tool_path" \ "$merge_tool_path" \
-f emerge-files-command \ -o "$MERGED" "$LOCAL" "$REMOTE"
"$LOCAL" "$REMOTE" \
"$(basename "$MERGED")"
fi fi
status=$? status=$?
else else
"$merge_tool_path" -f emerge-files-command \ "$merge_tool_path" "$LOCAL" "$REMOTE"
"$LOCAL" "$REMOTE"
fi fi
;; ;;
tortoisemerge) tortoisemerge)
@ -286,22 +295,30 @@ run_merge_tool () {
status=1 status=1
fi fi
;; ;;
araxis) xxdiff)
if merge_mode; then if merge_mode; then
touch "$BACKUP" touch "$BACKUP"
if $base_present; then if $base_present; then
"$merge_tool_path" -wait -merge -3 -a1 \ "$merge_tool_path" -X --show-merged-pane \
"$BASE" "$LOCAL" "$REMOTE" "$MERGED" \ -R 'Accel.SaveAsMerged: "Ctrl-S"' \
>/dev/null 2>&1 -R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl-G"' \
--merged-file "$MERGED" \
"$LOCAL" "$BASE" "$REMOTE"
else else
"$merge_tool_path" -wait -2 \ "$merge_tool_path" -X $extra \
"$LOCAL" "$REMOTE" "$MERGED" \ -R 'Accel.SaveAsMerged: "Ctrl-S"' \
>/dev/null 2>&1 -R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl-G"' \
--merged-file "$MERGED" \
"$LOCAL" "$REMOTE"
fi fi
check_unchanged check_unchanged
else else
"$merge_tool_path" -wait -2 "$LOCAL" "$REMOTE" \ "$merge_tool_path" \
>/dev/null 2>&1 -R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl-G"' \
"$LOCAL" "$REMOTE"
fi fi
;; ;;
*) *)
@ -343,7 +360,7 @@ guess_merge_tool () {
else else
tools="opendiff kdiff3 tkdiff xxdiff meld $tools" tools="opendiff kdiff3 tkdiff xxdiff meld $tools"
fi fi
tools="$tools gvimdiff diffuse ecmerge p4merge araxis" tools="$tools gvimdiff diffuse ecmerge p4merge araxis bc3"
fi fi
case "${VISUAL:-$EDITOR}" in case "${VISUAL:-$EDITOR}" in
*vim*) *vim*)

Loading…
Cancel
Save