feat: support git worktree, closes #29
This commit is contained in:
1
cspell.json
Normal file
1
cspell.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "language": "en", "version": "0.2", "flagWords": [], "words": ["worktree", "gitdir"] }
|
||||
@@ -27,9 +27,19 @@ local function match(line)
|
||||
end
|
||||
|
||||
local function root(cwd)
|
||||
local is_worktree = function(url)
|
||||
local file, head = io.open(tostring(url)), nil
|
||||
if file then
|
||||
head = file:read(8)
|
||||
file:close()
|
||||
end
|
||||
return head == "gitdir: "
|
||||
end
|
||||
|
||||
repeat
|
||||
local cha = fs.cha(cwd:join(".git"))
|
||||
if cha and cha.is_dir then
|
||||
local next = cwd:join(".git")
|
||||
local cha = fs.cha(next)
|
||||
if cha and (cha.is_dir or is_worktree(next)) then
|
||||
return tostring(cwd)
|
||||
end
|
||||
cwd = cwd:parent()
|
||||
|
||||
Reference in New Issue
Block a user