From 7d425ff4b90060578c49eb639f61bc79b5047e21 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Sat, 3 Jun 2023 10:25:28 +0100 Subject: [PATCH] Use filename not path in git add Since we change directory to the file's directory we can use its name rather than its path in the repo. --- autoload/gitgutter/hunk.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/autoload/gitgutter/hunk.vim b/autoload/gitgutter/hunk.vim index 358be9a..55ee411 100644 --- a/autoload/gitgutter/hunk.vim +++ b/autoload/gitgutter/hunk.vim @@ -301,9 +301,11 @@ function! s:stage(hunk_diff) if choice =~ 'y' let path = gitgutter#utility#repo_path(bufnr, 1) " Add file to index. - call gitgutter#utility#system( - \ gitgutter#utility#cd_cmd(bufnr, g:gitgutter_git_executable.' '.g:gitgutter_git_args.' add '.path) - \ ) + let cmd = gitgutter#utility#cd_cmd(bufnr, + \ g:gitgutter_git_executable.' '.g:gitgutter_git_args. + \ ' add '. + \ gitgutter#utility#shellescape(gitgutter#utility#filename(bufnr))) + call gitgutter#utility#system(cmd) else return endif