Skip to content

Commit fb2a182

Browse files
committed
Add DiffConflictsWithHistory to split the diff view and open the history
Closes #15. Credit to @jmandawg and @transamericamoon for the addition.
1 parent 1bda092 commit fb2a182

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ splitting them apart.
7777
git config --global mergetool.keepBackup false
7878
```
7979
80+
Or, if you'd prefer to always open both the diff view and the history view
81+
call `DiffConflictsWithHistory` instead:
82+
83+
```
84+
git config --global mergetool.diffconflicts.cmd 'vim -c DiffConflictsWithHistory "$MERGED" "$BASE" "$LOCAL" "$REMOTE"'
85+
```
86+
8087
3. During a merge you can call `:DiffConflictsShowHistory` to open a new tab
8188
containing the merge BASE and full copies of the LOCAL and REMOTE versions
8289
of the conflicted file. This can help to understand the history or intent

doc/diffconflicts.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@ git config --global mergetool.diffconflicts.trustExitCode true
1111
git config --global mergetool.keepBackup false
1212

1313
Commands:
14+
:DiffConflicts
15+
Convert a file containing Git conflict markers into a two-way diff.
16+
1417
:DiffConflictsShowHistory
1518
Open a new tab containing the merge base and the local and remote
1619
version of the conflicted file.
1720

21+
:DiffConflictsWithHistory
22+
Call both DiffConflicts and DiffConflictsShowHistory. This is useful in
23+
the Git mergetool configuration to always open the history by default.
24+
1825
*DiffConflicts-settings*
1926
This plugin doesn't have any settings.

plugin/diffconflicts.vim

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,23 @@ function! s:checkThenShowHistory()
9292
endif
9393
endfunction
9494

95-
function! s:checkThenDiff(showHist)
95+
function! s:checkThenDiff()
9696
if (s:hasConflicts())
97-
call s:diffconfl()
98-
if (a:showHist)
99-
call s:checkThenShowHistory()
100-
tabfirst
101-
endif
102-
redraw
103-
echohl WarningMsg
104-
\ | echon "Resolve conflicts leftward then save. Use :cq to abort."
105-
\ | echohl None
97+
redraw
98+
echohl WarningMsg
99+
\ | echon "Resolve conflicts leftward then save. Use :cq to abort."
100+
\ | echohl None
101+
return s:diffconfl()
106102
else
107103
echohl WarningMsg | echo "No conflict markers found." | echohl None
108104
endif
109105
endfunction
110106

111-
112-
command! DiffConflicts call s:checkThenDiff(0)
113-
command! DiffConflictsWithHistory call s:checkThenDiff(1)
107+
command! DiffConflicts call s:checkThenDiff()
114108
command! DiffConflictsShowHistory call s:checkThenShowHistory()
109+
command! DiffConflictsWithHistory call s:checkThenShowHistory()
110+
\ | 1tabn
111+
\ | call s:checkThenDiff()
115112

116113
let &cpo = s:save_cpo
117114
unlet s:save_cpo

0 commit comments

Comments
 (0)