@@ -5,6 +5,19 @@ local M = {
55 use_cygpath = false ,
66}
77
8+ --- Execute system command
9+ --- @param cmd string[]
10+ --- @return string stdout
11+ --- @return integer exit code
12+ local function system (cmd )
13+ if vim .fn .has (" nvim-0.10" ) == 1 then
14+ local obj = vim .system (cmd ):wait ()
15+ return obj .stdout or " " , obj .code
16+ else
17+ return vim .fn .system (cmd ), vim .v .shell_error
18+ end
19+ end
20+
821--- Retrieve the git toplevel directory
922--- @param cwd string path
1023--- @return string | nil toplevel absolute path
@@ -16,13 +29,7 @@ function M.get_toplevel(cwd)
1629 local cmd = { " git" , " -C" , cwd , " rev-parse" , " --show-toplevel" , " --absolute-git-dir" }
1730 log .line (" git" , " %s" , table.concat (cmd , " " ))
1831
19- local out , exitCode
20- if vim .fn .has (" nvim-0.10" ) == 1 then
21- local obj = vim .system (cmd ):wait ()
22- out , exitCode = obj .stdout or " " , obj .code
23- else
24- out , exitCode = vim .fn .system (cmd ), vim .v .shell_error
25- end
32+ local out , exitCode = system (cmd )
2633
2734 log .raw (" git" , out )
2835 log .profile_end (profile )
@@ -79,7 +86,7 @@ function M.should_show_untracked(cwd)
7986 local cmd = { " git" , " -C" , cwd , " config" , " status.showUntrackedFiles" }
8087 log .line (" git" , table.concat (cmd , " " ))
8188
82- local has_untracked = vim . fn . system (cmd )
89+ local has_untracked = system (cmd )
8390
8491 log .raw (" git" , has_untracked )
8592 log .profile_end (profile )
0 commit comments