fix(#1547): pass explicit system arguments to for git toplevel and untracked actions

* the nice fix

* fix(#1547): pass git toplevel cwd unescaped, pass git untracked arguments as per toplevel

Co-authored-by: Maximilian Philipp <philipp@student.tugraz.at>
Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
Xyhlon 2022-09-25 04:58:05 +02:00 committed by GitHub
parent 52b0c32152
commit 9914780cba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,10 +4,11 @@ local log = require "nvim-tree.log"
local has_cygpath = vim.fn.executable "cygpath" == 1
function M.get_toplevel(cwd)
local cmd = "git -C " .. vim.fn.shellescape(cwd) .. " rev-parse --show-toplevel"
local ps = log.profile_start("git toplevel %s", cwd)
log.line("git", cmd)
local cmd = { "git", "-C", cwd, "rev-parse", "--show-toplevel" }
log.line("git", "%s", vim.inspect(cmd))
local toplevel = vim.fn.system(cmd)
@ -41,10 +42,10 @@ function M.should_show_untracked(cwd)
return untracked[cwd]
end
local cmd = "git -C " .. cwd .. " config status.showUntrackedFiles"
local ps = log.profile_start("git untracked %s", cwd)
log.line("git", cmd)
local cmd = { "git", "-C", cwd, "config", "status.showUntrackedFiles" }
log.line("git", vim.inspect(cmd))
local has_untracked = vim.fn.system(cmd)