From f6e66df141a8c6227ebdc0b6b66859dfb643fcf4 Mon Sep 17 00:00:00 2001 From: Maximilian Philipp Date: Wed, 24 Aug 2022 01:59:57 +0200 Subject: [PATCH 1/2] the nice fix --- lua/nvim-tree/git/utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvim-tree/git/utils.lua b/lua/nvim-tree/git/utils.lua index 1aa48bab249..bc9ba02fa98 100644 --- a/lua/nvim-tree/git/utils.lua +++ b/lua/nvim-tree/git/utils.lua @@ -9,7 +9,7 @@ function M.get_toplevel(cwd) local ps = log.profile_start("git toplevel %s", cwd) log.line("git", cmd) - local toplevel = vim.fn.system(cmd) + local toplevel = vim.fn.system { "git", "-C", vim.fn.shellescape(cwd), "rev-parse", "--show-toplevel" } log.raw("git", toplevel) log.profile_end(ps, "git toplevel %s", cwd) From 0e7058f50d06e6828610c99db127fce23e6bc355 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Thu, 22 Sep 2022 11:13:25 +1000 Subject: [PATCH 2/2] fix(#1547): pass git toplevel cwd unescaped, pass git untracked arguments as per toplevel --- lua/nvim-tree/git/utils.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lua/nvim-tree/git/utils.lua b/lua/nvim-tree/git/utils.lua index 71342aec4f1..ee5eee251de 100644 --- a/lua/nvim-tree/git/utils.lua +++ b/lua/nvim-tree/git/utils.lua @@ -4,12 +4,13 @@ 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 toplevel = vim.fn.system { "git", "-C", vim.fn.shellescape(cwd), "rev-parse", "--show-toplevel" } + local cmd = { "git", "-C", cwd, "rev-parse", "--show-toplevel" } + log.line("git", "%s", vim.inspect(cmd)) + + local toplevel = vim.fn.system(cmd) log.raw("git", toplevel) log.profile_end(ps, "git toplevel %s", cwd) @@ -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)