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:
Andy Stewart
2023-06-03 10:23:21 +01:00
parent cefbe30aa9
commit f7f1286aac
2 changed files with 16 additions and 15 deletions

View File

@@ -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