Skip to content

Commit a6dfbee

Browse files
authored
fix(#407): safer handling of the git results
1 parent f2e225b commit a6dfbee

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lua/vgit/git/git_repo.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function git_repo.discover(filepath)
1212
local result, err = gitcli.run({ '-C', dirname, 'rev-parse', '--show-toplevel' })
1313

1414
if err then return nil, err end
15+
if #result==0 then return nil, {} end
1516
return result[1]
1617
end
1718

@@ -22,6 +23,7 @@ function git_repo.dirname()
2223
local result, git_dir_err = gitcli.run({ '-C', reponame, 'rev-parse', '--git-dir' })
2324
local git_dir = result[1]
2425
if git_dir_err then return nil, git_dir_err end
26+
if #result==0 then return nil, {} end
2527

2628
return reponame .. '/' .. git_dir
2729
end

0 commit comments

Comments
 (0)