mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Use filename in clean_smudge_filter_applies() function
And move function to utility. Since we change directory to the file's directory we can just use its name rather than it path from the repo root.
This commit is contained in:
@@ -295,7 +295,7 @@ endfunction
|
||||
function! s:stage(hunk_diff)
|
||||
let bufnr = bufnr('')
|
||||
|
||||
if s:clean_smudge_filter_applies(bufnr)
|
||||
if gitgutter#utility#clean_smudge_filter_applies(bufnr)
|
||||
let choice = input('File uses clean/smudge filter. Stage entire file (y/n)? ')
|
||||
normal! :<ESC>
|
||||
if choice =~ 'y'
|
||||
@@ -654,17 +654,3 @@ function gitgutter#hunk#is_preview_window_open()
|
||||
endif
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:clean_smudge_filter_applies(bufnr)
|
||||
let filtered = gitgutter#utility#getbufvar(a:bufnr, 'filter', -1)
|
||||
if filtered == -1
|
||||
let path = gitgutter#utility#repo_path(a:bufnr, 1)
|
||||
let out = gitgutter#utility#system(
|
||||
\ gitgutter#utility#cd_cmd(a:bufnr, g:gitgutter_git_executable.' '.g:gitgutter_git_args.' check-attr filter -- '.path)
|
||||
\ )
|
||||
let filtered = out !~ 'unspecified'
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'filter', filtered)
|
||||
endif
|
||||
return filtered
|
||||
endfunction
|
||||
|
||||
@@ -178,6 +178,21 @@ function! gitgutter#utility#set_repo_path(bufnr, continuation) abort
|
||||
endfunction
|
||||
|
||||
|
||||
function! gitgutter#utility#clean_smudge_filter_applies(bufnr)
|
||||
let filtered = gitgutter#utility#getbufvar(a:bufnr, 'filter', -1)
|
||||
if filtered == -1
|
||||
let cmd = gitgutter#utility#cd_cmd(a:bufnr,
|
||||
\ g:gitgutter_git_executable.' '.g:gitgutter_git_args.
|
||||
\ ' check-attr filter -- '.
|
||||
\ gitgutter#utility#shellescape(gitgutter#utility#filename(a:bufnr)))
|
||||
let out = gitgutter#utility#system(cmd)
|
||||
let filtered = out !~ 'unspecified'
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'filter', filtered)
|
||||
endif
|
||||
return filtered
|
||||
endfunction
|
||||
|
||||
|
||||
function! gitgutter#utility#cd_cmd(bufnr, cmd) abort
|
||||
let cd = s:unc_path(a:bufnr) ? 'pushd' : (gitgutter#utility#windows() && s:dos_shell() ? 'cd /d' : 'cd')
|
||||
return cd.' '.s:dir(a:bufnr).' && '.a:cmd
|
||||
|
||||
Reference in New Issue
Block a user