@@ -4,6 +4,13 @@ local util = require("neogit.lib.util")
44local Path = require (" plenary.path" )
55local runner = require (" neogit.runner" )
66
7+ --- Get the configured git executable path
8+ --- @return string
9+ local function get_git_executable ()
10+ local config = require (" neogit.config" )
11+ return config .get_git_executable ()
12+ end
13+
714--- @class GitCommandSetup
815--- @field flags table | nil
916--- @field options table | nil
@@ -983,7 +990,7 @@ local configurations = {
983990--- @param dir string
984991--- @return string Absolute path of current worktree
985992local function worktree_root (dir )
986- local cmd = { " git " , " -C" , dir , " rev-parse" , " --show-toplevel" }
993+ local cmd = { get_git_executable () , " -C" , dir , " rev-parse" , " --show-toplevel" }
987994 local result = vim .system (cmd , { text = true }):wait ()
988995
989996 return Path :new (vim .trim (result .stdout )):absolute ()
992999--- @param dir string
9931000--- @return string Absolute path of ` .git/` directory
9941001local function git_dir (dir )
995- local cmd = { " git " , " -C" , dir , " rev-parse" , " --git-common-dir" }
1002+ local cmd = { get_git_executable () , " -C" , dir , " rev-parse" , " --git-common-dir" }
9961003 local result = vim .system (cmd , { text = true }):wait ()
9971004
9981005 return Path :new (vim .trim (result .stdout )):absolute ()
@@ -1001,7 +1008,7 @@ end
10011008--- @param dir string
10021009--- @return string Absolute path of ` .git/` directory
10031010local function worktree_git_dir (dir )
1004- local cmd = { " git " , " -C" , dir , " rev-parse" , " --git-dir" }
1011+ local cmd = { get_git_executable () , " -C" , dir , " rev-parse" , " --git-dir" }
10051012 local result = vim .system (cmd , { text = true }):wait ()
10061013
10071014 return Path :new (vim .trim (result .stdout )):absolute ()
@@ -1010,7 +1017,7 @@ end
10101017--- @param dir string
10111018--- @return boolean
10121019local function is_inside_worktree (dir )
1013- local cmd = { " git " , " -C" , dir , " rev-parse" , " --is-inside-work-tree" }
1020+ local cmd = { get_git_executable () , " -C" , dir , " rev-parse" , " --is-inside-work-tree" }
10141021 local result = vim .system (cmd ):wait ()
10151022
10161023 return result .code == 0
@@ -1170,7 +1177,7 @@ local function new_builder(subcommand)
11701177 -- stylua: ignore
11711178 cmd = util .merge (
11721179 {
1173- " git " ,
1180+ get_git_executable () ,
11741181 " --no-pager" ,
11751182 " --literal-pathspecs" ,
11761183 " --no-optional-locks" ,
0 commit comments