@@ -5,6 +5,19 @@ local M = {
5
5
use_cygpath = false ,
6
6
}
7
7
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
+
8
21
--- Retrieve the git toplevel directory
9
22
--- @param cwd string path
10
23
--- @return string | nil toplevel absolute path
@@ -16,12 +29,12 @@ function M.get_toplevel(cwd)
16
29
local cmd = { " git" , " -C" , cwd , " rev-parse" , " --show-toplevel" , " --absolute-git-dir" }
17
30
log .line (" git" , " %s" , table.concat (cmd , " " ))
18
31
19
- local out = vim . fn . system (cmd )
32
+ local out , exitCode = system (cmd )
20
33
21
34
log .raw (" git" , out )
22
35
log .profile_end (profile )
23
36
24
- if vim . v . shell_error ~= 0 or not out or # out == 0 or out :match (" fatal" ) then
37
+ if exitCode ~= 0 or not out or # out == 0 or out :match (" fatal" ) then
25
38
return nil , nil
26
39
end
27
40
@@ -73,7 +86,7 @@ function M.should_show_untracked(cwd)
73
86
local cmd = { " git" , " -C" , cwd , " config" , " status.showUntrackedFiles" }
74
87
log .line (" git" , table.concat (cmd , " " ))
75
88
76
- local has_untracked = vim . fn . system (cmd )
89
+ local has_untracked = system (cmd )
77
90
78
91
log .raw (" git" , has_untracked )
79
92
log .profile_end (profile )
0 commit comments