From ae69fd0481fa7bb39ee9ee68dc2e009d500e3b1d Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 14 Sep 2010 21:21:42 -0500 Subject: [PATCH 1/3] mergetool-lib: combine vimdiff and gvimdiff run blocks They are nearly identical outside of the foreground flag, which can safely be passed to both vim and gvim. The merge tool itself is named in $merge_tool_path. Signed-off-by: Dan McGee Signed-off-by: Junio C Hamano --- git-mergetool--lib.sh | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index b5e1943b1d1..f9a51ba5044 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -169,25 +169,14 @@ run_merge_tool () { "$merge_tool_path" "$LOCAL" "$REMOTE" | cat fi ;; - vimdiff) + vimdiff|gvimdiff) if merge_mode; then touch "$BACKUP" - "$merge_tool_path" -d -c "wincmd l" \ + "$merge_tool_path" -f -d -c "wincmd l" \ "$LOCAL" "$MERGED" "$REMOTE" check_unchanged else - "$merge_tool_path" -d -c "wincmd l" \ - "$LOCAL" "$REMOTE" - fi - ;; - gvimdiff) - if merge_mode; then - touch "$BACKUP" - "$merge_tool_path" -d -c "wincmd l" -f \ - "$LOCAL" "$MERGED" "$REMOTE" - check_unchanged - else - "$merge_tool_path" -d -c "wincmd l" -f \ + "$merge_tool_path" -f -d -c "wincmd l" \ "$LOCAL" "$REMOTE" fi ;; From 829ef383a2b03a614d7d23e575270f2b10a805c1 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 14 Sep 2010 21:21:43 -0500 Subject: [PATCH 2/3] mergetool-lib: add a three-way diff view for vim/gvim When the base version is available, use a three-way, four panel view by default. This shows the (local, base, remote) revisions up top and the merged result by itself in the lower pane. All revisions will still scroll together by default, and the cursor still defaults to the merged result edit pane. Signed-off-by: Dan McGee Signed-off-by: Junio C Hamano --- git-mergetool--lib.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index f9a51ba5044..b84ac582f95 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -172,8 +172,13 @@ run_merge_tool () { vimdiff|gvimdiff) if merge_mode; then touch "$BACKUP" - "$merge_tool_path" -f -d -c "wincmd l" \ - "$LOCAL" "$MERGED" "$REMOTE" + 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" -f -d -c "wincmd l" \ From 000866909a5d9233c89d8fcc33a8125cc84f24d6 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 27 Sep 2010 10:19:09 -0500 Subject: [PATCH 3/3] mergetool-lib: make the three-way diff the default for vim/gvim The original vimdiff/gvimdiff configuration is now available by using 'vimdiff2' or 'gvimdiff2' as the preferred merge tool. Signed-off-by: Dan McGee Signed-off-by: Junio C Hamano --- git-mergetool--lib.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index b84ac582f95..77d4aee20ee 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -10,10 +10,10 @@ merge_mode() { translate_merge_tool_path () { case "$1" in - vimdiff) + vimdiff|vimdiff2) echo vim ;; - gvimdiff) + gvimdiff|gvimdiff2) echo gvim ;; emerge) @@ -47,7 +47,8 @@ check_unchanged () { valid_tool () { case "$1" in kdiff3 | tkdiff | xxdiff | meld | opendiff | \ - emerge | vimdiff | gvimdiff | ecmerge | diffuse | araxis | p4merge) + vimdiff | gvimdiff | vimdiff2 | gvimdiff2 | \ + emerge | ecmerge | diffuse | araxis | p4merge) ;; # happy tortoisemerge) if ! merge_mode; then @@ -185,6 +186,17 @@ run_merge_tool () { "$LOCAL" "$REMOTE" fi ;; + vimdiff2|gvimdiff2) + if merge_mode; then + touch "$BACKUP" + "$merge_tool_path" -f -d -c "wincmd l" \ + "$LOCAL" "$MERGED" "$REMOTE" + check_unchanged + else + "$merge_tool_path" -f -d -c "wincmd l" \ + "$LOCAL" "$REMOTE" + fi + ;; xxdiff) if merge_mode; then touch "$BACKUP"