Merge branch 'da/difftool-mergtool-refactor'

* da/difftool-mergtool-refactor:
  mergetools/meld: Use '--output' when available
  mergetool--lib: Refactor tools into separate files
  mergetool--lib: Make style consistent with git
  difftool--helper: Make style consistent with git
This commit is contained in:
Junio C Hamano 2011-08-25 16:00:43 -07:00
commit 3f1c70f717
18 changed files with 432 additions and 320 deletions

View File

@ -302,6 +302,7 @@ bindir = $(prefix)/$(bindir_relative)
mandir = share/man
infodir = share/info
gitexecdir = libexec/git-core
mergetoolsdir = $(gitexecdir)/mergetools
sharedir = $(prefix)/share
gitwebdir = $(sharedir)/gitweb
template_dir = share/git-core/templates
@ -2258,6 +2259,13 @@ endif
gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
export gitexec_instdir
ifneq ($(filter /%,$(firstword $(mergetoolsdir))),)
mergetools_instdir = $(mergetoolsdir)
else
mergetools_instdir = $(prefix)/$(mergetoolsdir)
endif
mergetools_instdir_SQ = $(subst ','\'',$(mergetools_instdir))
install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
install: all
@ -2267,6 +2275,9 @@ install: all
$(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
(cd mergetools && $(TAR) cf - .) | \
(cd '$(DESTDIR_SQ)$(mergetools_instdir_SQ)' && umask 022 && $(TAR) xof -)
ifndef NO_PERL
$(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
$(MAKE) -C gitweb install

View File

@ -13,7 +13,8 @@ TOOL_MODE=diff
should_prompt () {
prompt_merge=$(git config --bool mergetool.prompt || echo true)
prompt=$(git config --bool difftool.prompt || echo $prompt_merge)
if test "$prompt" = true; then
if test "$prompt" = true
then
test -z "$GIT_DIFFTOOL_NO_PROMPT"
else
test -n "$GIT_DIFFTOOL_PROMPT"
@ -37,9 +38,11 @@ launch_merge_tool () {
# $LOCAL and $REMOTE are temporary files so prompt
# the user with the real $MERGED name before launching $merge_tool.
if should_prompt; then
if should_prompt
then
printf "\nViewing: '$MERGED'\n"
if use_ext_cmd; then
if use_ext_cmd
then
printf "Hit return to launch '%s': " \
"$GIT_DIFFTOOL_EXTCMD"
else
@ -48,7 +51,8 @@ launch_merge_tool () {
read ans
fi
if use_ext_cmd; then
if use_ext_cmd
then
export BASE
eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"'
else
@ -56,8 +60,10 @@ launch_merge_tool () {
fi
}
if ! use_ext_cmd; then
if test -n "$GIT_DIFF_TOOL"; then
if ! use_ext_cmd
then
if test -n "$GIT_DIFF_TOOL"
then
merge_tool="$GIT_DIFF_TOOL"
else
merge_tool="$(get_merge_tool)" || exit

View File

@ -9,33 +9,16 @@ merge_mode() {
}
translate_merge_tool_path () {
case "$1" in
araxis)
echo compare
;;
bc3)
echo bcompare
;;
emerge)
echo emacs
;;
gvimdiff|gvimdiff2)
echo gvim
;;
vimdiff|vimdiff2)
echo vim
;;
*)
echo "$1"
;;
esac
echo "$1"
}
check_unchanged () {
if test "$MERGED" -nt "$BACKUP"; then
if test "$MERGED" -nt "$BACKUP"
then
status=0
else
while true; do
while true
do
echo "$MERGED seems unchanged."
printf "Was the merge successful? [y/n] "
read answer
@ -47,37 +30,57 @@ check_unchanged () {
fi
}
valid_tool_config () {
if test -n "$(get_merge_tool_cmd "$1")"
then
return 0
else
return 1
fi
}
valid_tool () {
setup_tool "$1" || valid_tool_config "$1"
}
setup_tool () {
case "$1" in
araxis | bc3 | diffuse | ecmerge | emerge | gvimdiff | gvimdiff2 | \
kdiff3 | meld | opendiff | p4merge | tkdiff | vimdiff | vimdiff2 | xxdiff)
;; # happy
kompare)
if ! diff_mode; then
return 1
fi
;;
tortoisemerge)
if ! merge_mode; then
return 1
fi
vim*|gvim*)
tool=vim
;;
*)
if test -z "$(get_merge_tool_cmd "$1")"; then
return 1
fi
tool="$1"
;;
esac
mergetools="$(git --exec-path)/mergetools"
# Load the default definitions
. "$mergetools/defaults"
if ! test -f "$mergetools/$tool"
then
return 1
fi
# Load the redefined functions
. "$mergetools/$tool"
if merge_mode && ! can_merge
then
echo "error: '$tool' can not be used to resolve merges" >&2
exit 1
elif diff_mode && ! can_diff
then
echo "error: '$tool' can only be used to resolve merges" >&2
exit 1
fi
return 0
}
get_merge_tool_cmd () {
# Prints the custom command for a merge tool
if test -n "$1"; then
merge_tool="$1"
else
merge_tool="$(get_merge_tool)"
fi
if diff_mode; then
merge_tool="$1"
if diff_mode
then
echo "$(git config difftool.$merge_tool.cmd ||
git config mergetool.$merge_tool.cmd)"
else
@ -85,6 +88,7 @@ get_merge_tool_cmd () {
fi
}
# Entry point for running tools
run_merge_tool () {
# If GIT_PREFIX is empty then we cannot use it in tools
# that expect to be able to chdir() to its value.
@ -95,271 +99,29 @@ run_merge_tool () {
base_present="$2"
status=0
case "$1" in
araxis)
if merge_mode; then
touch "$BACKUP"
if $base_present; then
"$merge_tool_path" -wait -merge -3 -a1 \
"$BASE" "$LOCAL" "$REMOTE" "$MERGED" \
>/dev/null 2>&1
else
"$merge_tool_path" -wait -2 \
"$LOCAL" "$REMOTE" "$MERGED" \
>/dev/null 2>&1
fi
check_unchanged
else
"$merge_tool_path" -wait -2 "$LOCAL" "$REMOTE" \
>/dev/null 2>&1
fi
;;
bc3)
if merge_mode; then
touch "$BACKUP"
if $base_present; then
"$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" \
-mergeoutput="$MERGED"
else
"$merge_tool_path" "$LOCAL" "$REMOTE" \
-mergeoutput="$MERGED"
fi
check_unchanged
else
"$merge_tool_path" "$LOCAL" "$REMOTE"
fi
;;
diffuse)
if merge_mode; then
touch "$BACKUP"
if $base_present; then
"$merge_tool_path" \
"$LOCAL" "$MERGED" "$REMOTE" \
"$BASE" | cat
else
"$merge_tool_path" \
"$LOCAL" "$MERGED" "$REMOTE" | cat
fi
check_unchanged
else
"$merge_tool_path" "$LOCAL" "$REMOTE" | cat
fi
;;
ecmerge)
if merge_mode; then
touch "$BACKUP"
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
else
"$merge_tool_path" --default --mode=diff2 \
"$LOCAL" "$REMOTE"
fi
;;
emerge)
if merge_mode; then
if $base_present; then
"$merge_tool_path" \
-f emerge-files-with-ancestor-command \
"$LOCAL" "$REMOTE" "$BASE" \
"$(basename "$MERGED")"
else
"$merge_tool_path" \
-f emerge-files-command \
"$LOCAL" "$REMOTE" \
"$(basename "$MERGED")"
fi
status=$?
else
"$merge_tool_path" -f emerge-files-command \
"$LOCAL" "$REMOTE"
fi
;;
gvimdiff|vimdiff)
if merge_mode; then
touch "$BACKUP"
if $base_present; then
"$merge_tool_path" -f -d -c "wincmd J" \
"$MERGED" "$LOCAL" "$BASE" "$REMOTE"
else
"$merge_tool_path" -f -d -c "wincmd l" \
"$LOCAL" "$MERGED" "$REMOTE"
fi
check_unchanged
else
"$merge_tool_path" -R -f -d -c "wincmd l" \
-c 'cd $GIT_PREFIX' \
"$LOCAL" "$REMOTE"
fi
;;
gvimdiff2|vimdiff2)
if merge_mode; then
touch "$BACKUP"
"$merge_tool_path" -f -d -c "wincmd l" \
"$LOCAL" "$MERGED" "$REMOTE"
check_unchanged
else
"$merge_tool_path" -R -f -d -c "wincmd l" \
-c 'cd $GIT_PREFIX' \
"$LOCAL" "$REMOTE"
fi
;;
kdiff3)
if merge_mode; then
if $base_present; then
("$merge_tool_path" --auto \
--L1 "$MERGED (Base)" \
--L2 "$MERGED (Local)" \
--L3 "$MERGED (Remote)" \
-o "$MERGED" \
"$BASE" "$LOCAL" "$REMOTE" \
> /dev/null 2>&1)
else
("$merge_tool_path" --auto \
--L1 "$MERGED (Local)" \
--L2 "$MERGED (Remote)" \
-o "$MERGED" \
"$LOCAL" "$REMOTE" \
> /dev/null 2>&1)
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
else
"$merge_tool_path" "$LOCAL" "$REMOTE"
fi
;;
opendiff)
if merge_mode; then
touch "$BACKUP"
if $base_present; then
"$merge_tool_path" "$LOCAL" "$REMOTE" \
-ancestor "$BASE" \
-merge "$MERGED" | cat
else
"$merge_tool_path" "$LOCAL" "$REMOTE" \
-merge "$MERGED" | cat
fi
check_unchanged
else
"$merge_tool_path" "$LOCAL" "$REMOTE" | cat
fi
;;
p4merge)
if merge_mode; then
touch "$BACKUP"
$base_present || >"$BASE"
"$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
check_unchanged
else
"$merge_tool_path" "$LOCAL" "$REMOTE"
fi
;;
tkdiff)
if merge_mode; then
if $base_present; then
"$merge_tool_path" -a "$BASE" \
-o "$MERGED" "$LOCAL" "$REMOTE"
else
"$merge_tool_path" \
-o "$MERGED" "$LOCAL" "$REMOTE"
fi
status=$?
else
"$merge_tool_path" "$LOCAL" "$REMOTE"
fi
;;
tortoisemerge)
if $base_present; then
touch "$BACKUP"
"$merge_tool_path" \
-base:"$BASE" -mine:"$LOCAL" \
-theirs:"$REMOTE" -merged:"$MERGED"
check_unchanged
else
echo "TortoiseMerge cannot be used without a base" 1>&2
status=1
fi
;;
xxdiff)
if merge_mode; then
touch "$BACKUP"
if $base_present; then
"$merge_tool_path" -X --show-merged-pane \
-R 'Accel.SaveAsMerged: "Ctrl-S"' \
-R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl-G"' \
--merged-file "$MERGED" \
"$LOCAL" "$BASE" "$REMOTE"
else
"$merge_tool_path" -X $extra \
-R 'Accel.SaveAsMerged: "Ctrl-S"' \
-R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl-G"' \
--merged-file "$MERGED" \
"$LOCAL" "$REMOTE"
fi
check_unchanged
else
"$merge_tool_path" \
-R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl-G"' \
"$LOCAL" "$REMOTE"
fi
;;
*)
merge_tool_cmd="$(get_merge_tool_cmd "$1")"
if test -z "$merge_tool_cmd"; then
if merge_mode; then
status=1
fi
break
fi
if merge_mode; then
trust_exit_code="$(git config --bool \
mergetool."$1".trustExitCode || echo false)"
if test "$trust_exit_code" = "false"; then
touch "$BACKUP"
( eval $merge_tool_cmd )
check_unchanged
else
( eval $merge_tool_cmd )
status=$?
fi
else
( eval $merge_tool_cmd )
fi
;;
esac
# Bring tool-specific functions into scope
setup_tool "$1"
if merge_mode
then
merge_cmd "$1"
else
diff_cmd "$1"
fi
return $status
}
guess_merge_tool () {
if merge_mode; then
if merge_mode
then
tools="tortoisemerge"
else
tools="kompare"
fi
if test -n "$DISPLAY"; then
if test -n "$GNOME_DESKTOP_SESSION_ID" ; then
if test -n "$DISPLAY"
then
if test -n "$GNOME_DESKTOP_SESSION_ID"
then
tools="meld opendiff kdiff3 tkdiff xxdiff $tools"
else
tools="opendiff kdiff3 tkdiff xxdiff meld $tools"
@ -380,7 +142,8 @@ guess_merge_tool () {
for i in $tools
do
merge_tool_path="$(translate_merge_tool_path "$i")"
if type "$merge_tool_path" > /dev/null 2>&1; then
if type "$merge_tool_path" >/dev/null 2>&1
then
echo "$i"
return 0
fi
@ -393,12 +156,14 @@ guess_merge_tool () {
get_configured_merge_tool () {
# Diff mode first tries diff.tool and falls back to merge.tool.
# Merge mode only checks merge.tool
if diff_mode; then
if diff_mode
then
merge_tool=$(git config diff.tool || git config merge.tool)
else
merge_tool=$(git config merge.tool)
fi
if test -n "$merge_tool" && ! valid_tool "$merge_tool"; then
if test -n "$merge_tool" && ! valid_tool "$merge_tool"
then
echo >&2 "git config option $TOOL_MODE.tool set to unknown tool: $merge_tool"
echo >&2 "Resetting to default..."
return 1
@ -408,26 +173,26 @@ get_configured_merge_tool () {
get_merge_tool_path () {
# A merge tool has been set, so verify that it's valid.
if test -n "$1"; then
merge_tool="$1"
else
merge_tool="$(get_merge_tool)"
fi
if ! valid_tool "$merge_tool"; then
merge_tool="$1"
if ! valid_tool "$merge_tool"
then
echo >&2 "Unknown merge tool $merge_tool"
exit 1
fi
if diff_mode; then
if diff_mode
then
merge_tool_path=$(git config difftool."$merge_tool".path ||
git config mergetool."$merge_tool".path)
else
merge_tool_path=$(git config mergetool."$merge_tool".path)
fi
if test -z "$merge_tool_path"; then
if test -z "$merge_tool_path"
then
merge_tool_path="$(translate_merge_tool_path "$merge_tool")"
fi
if test -z "$(get_merge_tool_cmd "$merge_tool")" &&
! type "$merge_tool_path" > /dev/null 2>&1; then
! type "$merge_tool_path" >/dev/null 2>&1
then
echo >&2 "The $TOOL_MODE tool $merge_tool is not available as"\
"'$merge_tool_path'"
exit 1
@ -437,9 +202,10 @@ get_merge_tool_path () {
get_merge_tool () {
# Check if a merge tool has been configured
merge_tool=$(get_configured_merge_tool)
merge_tool="$(get_configured_merge_tool)"
# Try to guess an appropriate merge tool if no tool has been set.
if test -z "$merge_tool"; then
if test -z "$merge_tool"
then
merge_tool="$(guess_merge_tool)" || exit
fi
echo "$merge_tool"

20
mergetools/araxis Normal file
View File

@ -0,0 +1,20 @@
diff_cmd () {
"$merge_tool_path" -wait -2 "$LOCAL" "$REMOTE" >/dev/null 2>&1
}
merge_cmd () {
touch "$BACKUP"
if $base_present
then
"$merge_tool_path" -wait -merge -3 -a1 \
"$BASE" "$LOCAL" "$REMOTE" "$MERGED" >/dev/null 2>&1
else
"$merge_tool_path" -wait -2 \
"$LOCAL" "$REMOTE" "$MERGED" >/dev/null 2>&1
fi
check_unchanged
}
translate_merge_tool_path() {
echo compare
}

20
mergetools/bc3 Normal file
View File

@ -0,0 +1,20 @@
diff_cmd () {
"$merge_tool_path" "$LOCAL" "$REMOTE"
}
merge_cmd () {
touch "$BACKUP"
if $base_present
then
"$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" \
-mergeoutput="$MERGED"
else
"$merge_tool_path" "$LOCAL" "$REMOTE" \
-mergeoutput="$MERGED"
fi
check_unchanged
}
translate_merge_tool_path() {
echo bcompare
}

46
mergetools/defaults Normal file
View File

@ -0,0 +1,46 @@
# Redefined by builtin tools
can_merge () {
return 0
}
can_diff () {
return 0
}
diff_cmd () {
merge_tool_cmd="$(get_merge_tool_cmd "$1")"
if test -z "$merge_tool_cmd"
then
status=1
break
fi
( eval $merge_tool_cmd )
status=$?
return $status
}
merge_cmd () {
merge_tool_cmd="$(get_merge_tool_cmd "$1")"
if test -z "$merge_tool_cmd"
then
status=1
break
fi
trust_exit_code="$(git config --bool \
mergetool."$1".trustExitCode || echo false)"
if test "$trust_exit_code" = "false"
then
touch "$BACKUP"
( eval $merge_tool_cmd )
status=$?
check_unchanged
else
( eval $merge_tool_cmd )
status=$?
fi
return $status
}
translate_merge_tool_path () {
echo "$1"
}

17
mergetools/diffuse Normal file
View File

@ -0,0 +1,17 @@
diff_cmd () {
"$merge_tool_path" "$LOCAL" "$REMOTE" | cat
}
merge_cmd () {
touch "$BACKUP"
if $base_present
then
"$merge_tool_path" \
"$LOCAL" "$MERGED" "$REMOTE" \
"$BASE" | cat
else
"$merge_tool_path" \
"$LOCAL" "$MERGED" "$REMOTE" | cat
fi
check_unchanged
}

16
mergetools/ecmerge Normal file
View File

@ -0,0 +1,16 @@
diff_cmd () {
"$merge_tool_path" --default --mode=diff2 "$LOCAL" "$REMOTE"
}
merge_cmd () {
touch "$BACKUP"
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
}

23
mergetools/emerge Normal file
View File

@ -0,0 +1,23 @@
diff_cmd () {
"$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE"
}
merge_cmd () {
if $base_present
then
"$merge_tool_path" \
-f emerge-files-with-ancestor-command \
"$LOCAL" "$REMOTE" "$BASE" \
"$(basename "$MERGED")"
else
"$merge_tool_path" \
-f emerge-files-command \
"$LOCAL" "$REMOTE" \
"$(basename "$MERGED")"
fi
status=$?
}
translate_merge_tool_path() {
echo emacs
}

24
mergetools/kdiff3 Normal file
View File

@ -0,0 +1,24 @@
diff_cmd () {
"$merge_tool_path" --auto \
--L1 "$MERGED (A)" --L2 "$MERGED (B)" \
"$LOCAL" "$REMOTE" >/dev/null 2>&1
}
merge_cmd () {
if $base_present
then
"$merge_tool_path" --auto \
--L1 "$MERGED (Base)" \
--L2 "$MERGED (Local)" \
--L3 "$MERGED (Remote)" \
-o "$MERGED" "$BASE" "$LOCAL" "$REMOTE" \
>/dev/null 2>&1
else
"$merge_tool_path" --auto \
--L1 "$MERGED (Local)" \
--L2 "$MERGED (Remote)" \
-o "$MERGED" "$LOCAL" "$REMOTE" \
>/dev/null 2>&1
fi
status=$?
}

7
mergetools/kompare Normal file
View File

@ -0,0 +1,7 @@
can_merge () {
return 1
}
diff_cmd () {
"$merge_tool_path" "$LOCAL" "$REMOTE"
}

32
mergetools/meld Normal file
View File

@ -0,0 +1,32 @@
diff_cmd () {
"$merge_tool_path" "$LOCAL" "$REMOTE"
}
merge_cmd () {
if test -z "${meld_has_output_option:+set}"
then
check_meld_for_output_version
fi
touch "$BACKUP"
if test "$meld_has_output_option" = true
then
"$merge_tool_path" --output "$MERGED" \
"$LOCAL" "$BASE" "$REMOTE"
else
"$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
fi
check_unchanged
}
# Check whether 'meld --output <file>' is supported
check_meld_for_output_version () {
meld_path="$(git config mergetool.meld.path)"
meld_path="${meld_path:-meld}"
if "$meld_path" --output /dev/null --help >/dev/null 2>&1
then
meld_has_output_option=true
else
meld_has_output_option=false
fi
}

16
mergetools/opendiff Normal file
View File

@ -0,0 +1,16 @@
diff_cmd () {
"$merge_tool_path" "$LOCAL" "$REMOTE" | cat
}
merge_cmd () {
touch "$BACKUP"
if $base_present
then
"$merge_tool_path" "$LOCAL" "$REMOTE" \
-ancestor "$BASE" -merge "$MERGED" | cat
else
"$merge_tool_path" "$LOCAL" "$REMOTE" \
-merge "$MERGED" | cat
fi
check_unchanged
}

10
mergetools/p4merge Normal file
View File

@ -0,0 +1,10 @@
diff_cmd () {
"$merge_tool_path" "$LOCAL" "$REMOTE"
}
merge_cmd () {
touch "$BACKUP"
$base_present || >"$BASE"
"$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
check_unchanged
}

12
mergetools/tkdiff Normal file
View File

@ -0,0 +1,12 @@
diff_cmd () {
"$merge_tool_path" "$LOCAL" "$REMOTE"
}
merge_cmd () {
if $base_present
then
"$merge_tool_path" -a "$BASE" -o "$MERGED" "$LOCAL" "$REMOTE"
else
"$merge_tool_path" -o "$MERGED" "$LOCAL" "$REMOTE"
fi
}

17
mergetools/tortoisemerge Normal file
View File

@ -0,0 +1,17 @@
can_diff () {
return 1
}
merge_cmd () {
if $base_present
then
touch "$BACKUP"
"$merge_tool_path" \
-base:"$BASE" -mine:"$LOCAL" \
-theirs:"$REMOTE" -merged:"$MERGED"
check_unchanged
else
echo "TortoiseMerge cannot be used without a base" 1>&2
return 1
fi
}

44
mergetools/vim Normal file
View File

@ -0,0 +1,44 @@
diff_cmd () {
case "$1" in
gvimdiff|vimdiff)
"$merge_tool_path" -R -f -d \
-c 'wincmd l' -c 'cd $GIT_PREFIX' "$LOCAL" "$REMOTE"
;;
gvimdiff2|vimdiff2)
"$merge_tool_path" -R -f -d \
-c 'wincmd l' -c 'cd $GIT_PREFIX' "$LOCAL" "$REMOTE"
;;
esac
}
merge_cmd () {
touch "$BACKUP"
case "$1" in
gvimdiff|vimdiff)
if $base_present
then
"$merge_tool_path" -f -d -c 'wincmd J' \
"$MERGED" "$LOCAL" "$BASE" "$REMOTE"
else
"$merge_tool_path" -f -d -c 'wincmd l' \
"$LOCAL" "$MERGED" "$REMOTE"
fi
;;
gvimdiff2|vimdiff2)
"$merge_tool_path" -f -d -c 'wincmd l' \
"$LOCAL" "$MERGED" "$REMOTE"
;;
esac
check_unchanged
}
translate_merge_tool_path() {
case "$1" in
gvimdiff|gvimdiff2)
echo gvim
;;
vimdiff|vimdiff2)
echo vim
;;
esac
}

25
mergetools/xxdiff Normal file
View File

@ -0,0 +1,25 @@
diff_cmd () {
"$merge_tool_path" \
-R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl-G"' \
"$LOCAL" "$REMOTE"
}
merge_cmd () {
touch "$BACKUP"
if $base_present
then
"$merge_tool_path" -X --show-merged-pane \
-R 'Accel.SaveAsMerged: "Ctrl-S"' \
-R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl-G"' \
--merged-file "$MERGED" "$LOCAL" "$BASE" "$REMOTE"
else
"$merge_tool_path" -X $extra \
-R 'Accel.SaveAsMerged: "Ctrl-S"' \
-R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl-G"' \
--merged-file "$MERGED" "$LOCAL" "$REMOTE"
fi
check_unchanged
}