File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,6 +61,20 @@ function M.get_git_dir(path)
6161 end
6262 end
6363
64+ -- Check if git directory is absolute path or a relative
65+ local function is_path_absolute (dir )
66+ local patterns = {
67+ ' ^/' , -- unix
68+ ' ^%a:[/\\ ]' , -- windows
69+ }
70+ for _ , pattern in ipairs (patterns ) do
71+ if string.find (dir , pattern ) then
72+ return true
73+ end
74+ end
75+ return false
76+ end
77+
6478 -- If path nil or '.' get the absolute path to current directory
6579 if not path or path == ' .' then
6680 path = vim .fn .getcwd ()
@@ -81,8 +95,7 @@ function M.get_git_dir(path)
8195
8296 if not git_dir then return end
8397
84- -- Check if git directory is absolute path or a relative
85- if git_dir :sub (1 ,1 ) == ' /' then
98+ if is_path_absolute (git_dir ) then
8699 return git_dir
87100 end
88101 return path .. ' /' .. git_dir
You can’t perform that action at this time.
0 commit comments