refactor(git): gitlog as gitlog:// URI singleton, fix synthetic-URI cwd resolve

This commit is contained in:
2026-04-29 14:06:40 +02:00
parent 49c618959d
commit 781496dc13
4 changed files with 85 additions and 29 deletions
+5 -4
View File
@@ -84,14 +84,15 @@ function M.resolve(path)
return vim.fs.normalize(gitdir), worktree
end
---Resolve the gitdir/worktree from the current buffer's file path, falling
---back to `vim.fn.getcwd()` when the buffer is unnamed. Returns nil for
---both when not inside a git repo.
---Resolve the gitdir/worktree from the current buffer's file path,
---falling back to `vim.fn.getcwd()` when the buffer is unnamed or
---carries a synthetic URI (`git://`, `gitlog://`) that isn't a real
---filesystem path. Returns nil for both when not inside a git repo.
---@return string? gitdir
---@return string? worktree
function M.resolve_cwd()
local path = vim.api.nvim_buf_get_name(0)
if path == "" then
if path == "" or path:match("^%a+://") then
path = vim.fn.getcwd()
end
return M.resolve(path)