Skip to content

Commit

Permalink
using proper shellslash
Browse files Browse the repository at this point in the history
  • Loading branch information
mhinz committed Mar 27, 2013
1 parent cd26e1c commit 1de08cb
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions plugin/signify.vim
Original file line number Diff line number Diff line change
Expand Up @@ -272,55 +272,55 @@ endfunction
" Functions -> s:repo_get_diff_git {{{1
function! s:repo_get_diff_git(path) abort
if executable('git')
let diff = system('cd '. shellescape(fnamemodify(a:path, ':h')) .' && git diff --no-ext-diff -U0 -- '. shellescape(a:path))
let diff = system('cd '. s:escape(fnamemodify(a:path, ':h')) .' && git diff --no-ext-diff -U0 -- '. s:escape(a:path))
return v:shell_error ? '' : diff
endif
endfunction

" Functions -> s:repo_get_diff_hg {{{1
function! s:repo_get_diff_hg(path) abort
if executable('hg')
let diff = system('hg diff --nodates -U0 -- '. shellescape(a:path))
let diff = system('hg diff --nodates -U0 -- '. s:escape(a:path))
return v:shell_error ? '' : diff
endif
endfunction

" Functions -> s:repo_get_diff_svn {{{1
function! s:repo_get_diff_svn(path) abort
if executable('svn')
let diff = system('svn diff --diff-cmd '. s:difftool .' -x -U0 -- '. shellescape(a:path))
let diff = system('svn diff --diff-cmd '. s:difftool .' -x -U0 -- '. s:escape(a:path))
return v:shell_error ? '' : diff
endif
endfunction

" Functions -> s:repo_get_diff_bzr {{{1
function! s:repo_get_diff_bzr(path) abort
if executable('bzr')
let diff = system('bzr diff --using '. s:difftool .' --diff-options=-U0 -- '. shellescape(a:path))
let diff = system('bzr diff --using '. s:difftool .' --diff-options=-U0 -- '. s:escape(a:path))
return v:shell_error ? '' : diff
endif
endfunction

" Functions -> s:repo_get_diff_darcs {{{1
function! s:repo_get_diff_darcs(path) abort
if executable('darcs')
let diff = system('cd '. shellescape(fnamemodify(a:path, ':h')) .' && darcs diff --no-pause-for-gui --diff-command="'. s:difftool .' -U0 %1 %2" -- '. shellescape(a:path))
let diff = system('cd '. s:escape(fnamemodify(a:path, ':h')) .' && darcs diff --no-pause-for-gui --diff-command="'. s:difftool .' -U0 %1 %2" -- '. s:escape(a:path))
return v:shell_error ? '' : diff
endif
endfunction

" Functions -> s:repo_get_diff_cvs {{{1
function! s:repo_get_diff_cvs(path) abort
if executable('cvs')
let diff = system('cd '. shellescape(fnamemodify(a:path, ':h')) .' && cvs diff -U0 -- '. shellescape(fnamemodify(a:path, ':t')))
let diff = system('cd '. s:escape(fnamemodify(a:path, ':h')) .' && cvs diff -U0 -- '. s:escape(fnamemodify(a:path, ':t')))
return v:shell_error ? '' : diff
endif
endfunction

" Functions -> s:repo_get_diff_rcs {{{1
function! s:repo_get_diff_rcs(path) abort
if executable('rcs')
let diff = system('rcsdiff -U0 '. shellescape(a:path) .' 2>/dev/null')
let diff = system('rcsdiff -U0 '. s:escape(a:path) .' 2>/dev/null')
return v:shell_error ? '' : diff
endif
endfunction
Expand Down Expand Up @@ -572,6 +572,22 @@ function! s:jump_to_prev_hunk(count)
let s:sy[s:path].last_jump_was_next = 0
endfunction

" Functions -> s:s:escape() {{{1
function s:escape(path) abort
if has('+shellslash')
let old_ssl = &shellslash
set noshellslash
endif

let path = shellescape(a:path)

if exists('old_ssl')
let &shellslash = old_ssl
endif

return path
endfunction

" Functions -> SignifyDebugListActiveBuffers() {{{1
function! SignifyDebugListActiveBuffers() abort
if len(s:sy) == 0
Expand Down

2 comments on commit 1de08cb

@fritzophrenic
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the s:escape function, has('+shellslash') should be exists('+shellslash'). Then it works for me.

@mhinz
Copy link
Owner Author

@mhinz mhinz commented on 1de08cb Mar 27, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh.. late-night commits.. thanks!

Please sign in to comment.