Skip to content

Commit b30a418

Browse files
committed
fix: execute all git commands without shell, may fix #457
1 parent 33fc4bd commit b30a418

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Diff for: lua/neo-tree/git/status.lua

+5-4
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,18 @@ M.status = function(base, exclude_directories, path)
124124
return {}
125125
end
126126

127-
local staged_cmd = 'git -C "' .. git_root .. '" diff --staged --name-status ' .. base .. " --"
128-
local staged_ok, staged_result = utils.execute_command(staged_cmd)
127+
local C = git_root
128+
local staged_cmd = { "git", "-C", C, "diff", "--staged", "--name-status", base, "--" }
129+
local staged_ok, staged_result = utils.execute_command(base_cmd + staged_cmd)
129130
if not staged_ok then
130131
return {}
131132
end
132-
local unstaged_cmd = 'git -C "' .. git_root .. '" diff --name-status'
133+
local unstaged_cmd = { "git", "-C", C, "diff", "--name-status" }
133134
local unstaged_ok, unstaged_result = utils.execute_command(unstaged_cmd)
134135
if not unstaged_ok then
135136
return {}
136137
end
137-
local untracked_cmd = 'git -C "' .. git_root .. '" ls-files --exclude-standard --others'
138+
local untracked_cmd = { "git", "-C", C, "ls-files", "--exclude-standard", "--others" }
138139
local untracked_ok, untracked_result = utils.execute_command(untracked_cmd)
139140
if not untracked_ok then
140141
return {}

Diff for: lua/neo-tree/git/utils.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ local log = require("neo-tree.log")
44
local M = {}
55

66
M.get_repository_root = function(path)
7-
local cmd = "git rev-parse --show-toplevel"
7+
local cmd = { "git", "rev-parse", "--show-toplevel" }
88
if utils.truthy(path) then
9-
cmd = "git -C " .. path .. " rev-parse --show-toplevel"
9+
cmd = { "git", "-C", path, "rev-parse", "--show-toplevel" }
1010
end
1111
local ok, git_root = utils.execute_command(cmd)
1212
if not ok then

0 commit comments

Comments
 (0)