[vim] Handle a nil result from io.popen when looking up a Git repo

This commit is contained in:
Eryn Wells 2024-03-08 11:50:04 -08:00
parent 0accf738ed
commit 8ab6b1ea99

View file

@ -4,8 +4,13 @@ require "os"
function gitTopLevelDirectory()
local handle = io.popen("git rev-parse --show-toplevel")
if handle == nil then
return nil
end
local gitRepoTopLevelDirectoryPath = vim.fn.trim(handle:read("*a"))
handle:close()
return gitRepoTopLevelDirectoryPath
end