Skip to content

Commit

Permalink
Fix running shell commands on older versions of Vim
Browse files Browse the repository at this point in the history
  • Loading branch information
rbong committed Sep 18, 2024
1 parent 007123b commit 4669c40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions autoload/flog/git.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function! flog#git#GetWorkdirFrom(git_dir) abort
let l:parent = fnamemodify(a:git_dir, ':h')

" Check for core.worktree setting
let l:worktree = systemlist(l:cmd + ['config', '--get', 'core.worktree'])
let l:worktree = flog#shell#Systemlist(l:cmd + ['config', '--get', 'core.worktree'])
if empty(v:shell_error) && !empty(l:worktree)
let l:worktree = flog#path#ResolveFrom(l:parent, l:worktree[0])
if isdirectory(l:worktree)
Expand Down Expand Up @@ -53,7 +53,7 @@ function! flog#git#GetWorkdirFrom(git_dir) abort
endif

" Check for non-worktree parent directory
call systemlist(l:cmd + ['-C', flog#shell#Escape(l:parent), 'rev-parse', '--show-toplevel'])
call flog#shell#Systemlist(l:cmd + ['-C', flog#shell#Escape(l:parent), 'rev-parse', '--show-toplevel'])
if !empty(v:shell_error)
return a:git_dir
endif
Expand Down
15 changes: 14 additions & 1 deletion autoload/flog/shell.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,21 @@ function! flog#shell#EscapeList(list) abort
return map(copy(a:list), 'flog#shell#Escape(v:val)')
endfunction

if has('nvim') || v:version > 704 || (v:version == 704 && get(v:, 'patchlevel', 0) >= 247)
function! flog#shell#Systemlist(cmd) abort
return systemlist(a:cmd)
endfunction
else
function! flog#shell#Systemlist(cmd) abort
if type(a:cmd) == v:t_list
return systemlist(join(a:cmd, ' '))
endif
return systemlist(a:cmd)
endfunction
endif

function! flog#shell#Run(cmd) abort
let l:output = systemlist(a:cmd)
let l:output = flog#shell#Systemlist(a:cmd)
if !empty(v:shell_error)
call flog#print#err(join(l:output, "\n"))
throw g:flog_shell_error
Expand Down

0 comments on commit 4669c40

Please sign in to comment.