Skip to content

Commit

Permalink
fix(#1547): pass explicit system arguments to for git toplevel and un…
Browse files Browse the repository at this point in the history
…tracked 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>
  • Loading branch information
3 people authored Sep 25, 2022
1 parent 52b0c32 commit 9914780
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lua/nvim-tree/git/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 9914780

Please sign in to comment.