From 8bc814de2be44358f4b6264fcaa425f3ee29d9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sindre=20T=2E=20Str=C3=B8m?= Date: Mon, 17 May 2021 21:54:19 +0200 Subject: [PATCH] fix(git): Fix shell args on windows. (#349) --- lua/nvim-tree/git.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lua/nvim-tree/git.lua b/lua/nvim-tree/git.lua index 77925bf1..d58ec705 100644 --- a/lua/nvim-tree/git.lua +++ b/lua/nvim-tree/git.lua @@ -10,11 +10,17 @@ local not_git = 'not a git repo' local is_win = vim.api.nvim_call_function("has", {"win32"}) == 1 local function update_root_status(root) + local e_root = vim.fn.shellescape(root) local untracked = ' -u' - if vim.fn.trim(vim.fn.system('git -C \'' .. root .. '\' config --type=bool status.showUntrackedFiles')) == 'false' then + + local cmd = "git -C " .. e_root .. " config --type=bool status.showUntrackedFiles" + if vim.trim(vim.fn.system(cmd)) == 'false' then untracked = '' end - local status = vim.fn.systemlist('git -C \'' .. root .. '\' status --porcelain=v1 --ignored=matching'..untracked) + + cmd = "git -C " .. e_root .. " status --porcelain=v1 --ignored=matching" .. untracked + local status = vim.fn.systemlist(cmd) + roots[root] = {} gitignore_map[root] = {} @@ -61,7 +67,8 @@ local function get_git_root(path) end local function create_root(cwd) - local git_root = vim.fn.system('cd "'..cwd..'" && git rev-parse --show-toplevel') + local cmd = "git -C " .. vim.fn.shellescape(cwd) .. " rev-parse --show-toplevel" + local git_root = vim.fn.system(cmd) if not git_root or #git_root == 0 or git_root:match('fatal') then roots[cwd] = not_git