summaryrefslogtreecommitdiff
path: root/git-mergetool--lib.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-03-19 23:24:27 -0700
committerJunio C Hamano <gitster@pobox.com>2011-03-19 23:24:27 -0700
commit9d59e6607a597a0a934566bfa547b45c7b57822c (patch)
treec3ff191357256ec88cfb7f770e5b10554c16e34d /git-mergetool--lib.sh
parentf4784b3eab2e12e7a8fda7431572753f3a970c63 (diff)
parentffe6dc081aa23d56e6306d143d99ca508db38c5e (diff)
downloadgit-9d59e6607a597a0a934566bfa547b45c7b57822c.tar.gz
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
Diffstat (limited to 'git-mergetool--lib.sh')
-rw-r--r--git-mergetool--lib.sh225
1 files changed, 121 insertions, 104 deletions
diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 78ce49e984..fb3f52ba25 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -10,17 +10,20 @@ merge_mode() {
translate_merge_tool_path () {
case "$1" in
- vimdiff|vimdiff2)
- echo vim
+ araxis)
+ echo compare
;;
- gvimdiff|gvimdiff2)
- echo gvim
+ bc3)
+ echo bcompare
;;
emerge)
echo emacs
;;
- araxis)
- echo compare
+ gvimdiff|gvimdiff2)
+ echo gvim
+ ;;
+ vimdiff|vimdiff2)
+ echo vim
;;
*)
echo "$1"
@@ -46,17 +49,16 @@ check_unchanged () {
valid_tool () {
case "$1" in
- kdiff3 | tkdiff | xxdiff | meld | opendiff | \
- vimdiff | gvimdiff | vimdiff2 | gvimdiff2 | \
- emerge | ecmerge | diffuse | araxis | p4merge)
+ araxis | bc3 | diffuse | ecmerge | emerge | gvimdiff | gvimdiff2 | \
+ kdiff3 | meld | opendiff | p4merge | tkdiff | vimdiff | vimdiff2 | xxdiff)
;; # happy
- tortoisemerge)
- if ! merge_mode; then
+ kompare)
+ if ! diff_mode; then
return 1
fi
;;
- kompare)
- if ! diff_mode; then
+ tortoisemerge)
+ if ! merge_mode; then
return 1
fi
;;
@@ -89,88 +91,91 @@ run_merge_tool () {
status=0
case "$1" in
- kdiff3)
+ araxis)
if merge_mode; then
+ touch "$BACKUP"
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)
+ "$merge_tool_path" -wait -merge -3 -a1 \
+ "$BASE" "$LOCAL" "$REMOTE" "$MERGED" \
+ >/dev/null 2>&1
else
- ("$merge_tool_path" --auto \
- --L1 "$MERGED (Local)" \
- --L2 "$MERGED (Remote)" \
- -o "$MERGED" \
- "$LOCAL" "$REMOTE" \
- > /dev/null 2>&1)
+ "$merge_tool_path" -wait -2 \
+ "$LOCAL" "$REMOTE" "$MERGED" \
+ >/dev/null 2>&1
fi
- status=$?
+ check_unchanged
else
- ("$merge_tool_path" --auto \
- --L1 "$MERGED (A)" \
- --L2 "$MERGED (B)" "$LOCAL" "$REMOTE" \
- > /dev/null 2>&1)
+ "$merge_tool_path" -wait -2 "$LOCAL" "$REMOTE" \
+ >/dev/null 2>&1
fi
;;
- kompare)
- "$merge_tool_path" "$LOCAL" "$REMOTE"
- ;;
- tkdiff)
+ bc3)
if merge_mode; then
+ touch "$BACKUP"
if $base_present; then
- "$merge_tool_path" -a "$BASE" \
- -o "$MERGED" "$LOCAL" "$REMOTE"
+ "$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" \
+ -mergeoutput="$MERGED"
else
- "$merge_tool_path" \
- -o "$MERGED" "$LOCAL" "$REMOTE"
+ "$merge_tool_path" "$LOCAL" "$REMOTE" \
+ -mergeoutput="$MERGED"
fi
- status=$?
+ check_unchanged
else
"$merge_tool_path" "$LOCAL" "$REMOTE"
fi
;;
- p4merge)
+ diffuse)
if merge_mode; then
- touch "$BACKUP"
+ touch "$BACKUP"
if $base_present; then
- "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
+ "$merge_tool_path" \
+ "$LOCAL" "$MERGED" "$REMOTE" \
+ "$BASE" | cat
else
- "$merge_tool_path" "$LOCAL" "$LOCAL" "$REMOTE" "$MERGED"
+ "$merge_tool_path" \
+ "$LOCAL" "$MERGED" "$REMOTE" | cat
fi
check_unchanged
else
- "$merge_tool_path" "$LOCAL" "$REMOTE"
+ "$merge_tool_path" "$LOCAL" "$REMOTE" | cat
fi
;;
- meld)
+ ecmerge)
if merge_mode; then
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
else
- "$merge_tool_path" "$LOCAL" "$REMOTE"
+ "$merge_tool_path" --default --mode=diff2 \
+ "$LOCAL" "$REMOTE"
fi
;;
- diffuse)
+ emerge)
if merge_mode; then
- touch "$BACKUP"
if $base_present; then
"$merge_tool_path" \
- "$LOCAL" "$MERGED" "$REMOTE" \
- "$BASE" | cat
+ -f emerge-files-with-ancestor-command \
+ "$LOCAL" "$REMOTE" "$BASE" \
+ "$(basename "$MERGED")"
else
"$merge_tool_path" \
- "$LOCAL" "$MERGED" "$REMOTE" | cat
+ -f emerge-files-command \
+ "$LOCAL" "$REMOTE" \
+ "$(basename "$MERGED")"
fi
- check_unchanged
+ status=$?
else
- "$merge_tool_path" "$LOCAL" "$REMOTE" | cat
+ "$merge_tool_path" -f emerge-files-command \
+ "$LOCAL" "$REMOTE"
fi
;;
- vimdiff|gvimdiff)
+ gvimdiff|vimdiff)
if merge_mode; then
touch "$BACKUP"
if $base_present; then
@@ -186,7 +191,7 @@ run_merge_tool () {
"$LOCAL" "$REMOTE"
fi
;;
- vimdiff2|gvimdiff2)
+ gvimdiff2|vimdiff2)
if merge_mode; then
touch "$BACKUP"
"$merge_tool_path" -f -d -c "wincmd l" \
@@ -197,30 +202,42 @@ run_merge_tool () {
"$LOCAL" "$REMOTE"
fi
;;
- xxdiff)
+ kdiff3)
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"
+ ("$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" -X $extra \
- -R 'Accel.SaveAsMerged: "Ctrl-S"' \
- -R 'Accel.Search: "Ctrl+F"' \
- -R 'Accel.SearchForward: "Ctrl-G"' \
- --merged-file "$MERGED" \
- "$LOCAL" "$REMOTE"
+ ("$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" \
- -R 'Accel.Search: "Ctrl+F"' \
- -R 'Accel.SearchForward: "Ctrl-G"' \
- "$LOCAL" "$REMOTE"
+ "$merge_tool_path" "$LOCAL" "$REMOTE"
fi
;;
opendiff)
@@ -239,39 +256,31 @@ run_merge_tool () {
"$merge_tool_path" "$LOCAL" "$REMOTE" | cat
fi
;;
- ecmerge)
+ p4merge)
if merge_mode; then
- touch "$BACKUP"
+ touch "$BACKUP"
if $base_present; then
- "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" \
- --default --mode=merge3 --to="$MERGED"
+ "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
else
- "$merge_tool_path" "$LOCAL" "$REMOTE" \
- --default --mode=merge2 --to="$MERGED"
+ "$merge_tool_path" "$LOCAL" "$LOCAL" "$REMOTE" "$MERGED"
fi
check_unchanged
else
- "$merge_tool_path" --default --mode=diff2 \
- "$LOCAL" "$REMOTE"
+ "$merge_tool_path" "$LOCAL" "$REMOTE"
fi
;;
- emerge)
+ tkdiff)
if merge_mode; then
if $base_present; then
- "$merge_tool_path" \
- -f emerge-files-with-ancestor-command \
- "$LOCAL" "$REMOTE" "$BASE" \
- "$(basename "$MERGED")"
+ "$merge_tool_path" -a "$BASE" \
+ -o "$MERGED" "$LOCAL" "$REMOTE"
else
"$merge_tool_path" \
- -f emerge-files-command \
- "$LOCAL" "$REMOTE" \
- "$(basename "$MERGED")"
+ -o "$MERGED" "$LOCAL" "$REMOTE"
fi
status=$?
else
- "$merge_tool_path" -f emerge-files-command \
- "$LOCAL" "$REMOTE"
+ "$merge_tool_path" "$LOCAL" "$REMOTE"
fi
;;
tortoisemerge)
@@ -286,22 +295,30 @@ run_merge_tool () {
status=1
fi
;;
- araxis)
+ xxdiff)
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
+ "$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" -wait -2 \
- "$LOCAL" "$REMOTE" "$MERGED" \
- >/dev/null 2>&1
+ "$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" -wait -2 "$LOCAL" "$REMOTE" \
- >/dev/null 2>&1
+ "$merge_tool_path" \
+ -R 'Accel.Search: "Ctrl+F"' \
+ -R 'Accel.SearchForward: "Ctrl-G"' \
+ "$LOCAL" "$REMOTE"
fi
;;
*)
@@ -343,7 +360,7 @@ guess_merge_tool () {
else
tools="opendiff kdiff3 tkdiff xxdiff meld $tools"
fi
- tools="$tools gvimdiff diffuse ecmerge p4merge araxis"
+ tools="$tools gvimdiff diffuse ecmerge p4merge araxis bc3"
fi
case "${VISUAL:-$EDITOR}" in
*vim*)