[Commits,BCommits] Windows support (#430)

Works only in s:execute of fzf's Vim plugin.
s:execute_term corrupts the output of fzf#shellescape.
This commit is contained in:
Jan Edmund Lazo
2017-08-21 13:13:06 -04:00
committed by Junegunn Choi
parent fa91d53f5c
commit b0baf7593d

View File

@@ -1042,11 +1042,11 @@ function! s:commits(buffer_local, args)
return s:warn('Not in git repository') return s:warn('Not in git repository')
endif endif
let source = 'git log '.get(g:, 'fzf_commits_log_options', '--graph --color=always --format="%C(auto)%h%d %s %C(green)%cr"') let source = 'git log '.get(g:, 'fzf_commits_log_options', '--graph --color=always '.fzf#shellescape('--format="%C(auto)%h%d %s %C(green)%cr"'))
let current = expand('%:S') let current = expand('%')
let managed = 0 let managed = 0
if !empty(current) if !empty(current)
call system('git show '.current.' 2> /dev/null') call system('git show '.fzf#shellescape(current).' 2> '.(s:is_win ? 'nul' : '/dev/null'))
let managed = !v:shell_error let managed = !v:shell_error
endif endif
@@ -1054,7 +1054,7 @@ function! s:commits(buffer_local, args)
if !managed if !managed
return s:warn('The current buffer is not in the working tree') return s:warn('The current buffer is not in the working tree')
endif endif
let source .= ' --follow '.current let source .= ' --follow '.fzf#shellescape(current)
endif endif
let command = a:buffer_local ? 'BCommits' : 'Commits' let command = a:buffer_local ? 'BCommits' : 'Commits'
@@ -1062,15 +1062,15 @@ function! s:commits(buffer_local, args)
let options = { let options = {
\ 'source': source, \ 'source': source,
\ 'sink*': s:function('s:commits_sink'), \ 'sink*': s:function('s:commits_sink'),
\ 'options': '--ansi --multi --tiebreak=index --reverse '. \ 'options': ['--ansi', '--multi', '--tiebreak=index', '--reverse',
\ '--inline-info --prompt "'.command.'> " --bind=ctrl-s:toggle-sort '. \ '--inline-info', '--prompt', command.'> ', '--bind=ctrl-s:toggle-sort',
\ '--expect='.expect_keys \ '--header', ':: Press '.s:magenta('CTRL-S', 'Special').' to toggle sort',
\ '--expect='.expect_keys]
\ } \ }
if a:buffer_local if a:buffer_local
let options.options .= ',ctrl-d --header ":: Press '.s:magenta('CTRL-S', 'Special').' to toggle sort, '.s:magenta('CTRL-D', 'Special').' to diff"' let options.options[-2] .= ', '.s:magenta('CTRL-D', 'Special').' to diff'
else let options.options[-1] .= ',ctrl-d'
let options.options .= ' --header ":: Press '.s:magenta('CTRL-S', 'Special').' to toggle sort"'
endif endif
return s:fzf(a:buffer_local ? 'bcommits' : 'commits', options, a:args) return s:fzf(a:buffer_local ? 'bcommits' : 'commits', options, a:args)