refactor(git): URI scheme is now a git revspec, loaded via cat-file -p

This commit is contained in:
2026-04-28 13:20:38 +02:00
parent a0c87b9b7b
commit 68f2ad1b52
6 changed files with 55 additions and 56 deletions
+15 -15
View File
@@ -484,15 +484,19 @@ end
---@return ow.Git.DiffSide
local function head_pane(worktree, path)
return {
buf = diff.git_show_buf(worktree, "HEAD", path),
name = "git://HEAD//" .. path,
buf = diff.git_show_buf(worktree, "HEAD:" .. path),
name = "git://HEAD:" .. path,
}
end
---@param worktree string
---@param path string
---@return ow.Git.DiffSide
local function head_empty_pane(path)
return { buf = diff.empty_buf(), name = "git://HEAD//" .. path }
local function absent_pane(worktree, path)
return {
buf = diff.empty_buf(),
name = "[absent] " .. vim.fs.joinpath(worktree, path),
}
end
---@param worktree string
@@ -505,12 +509,6 @@ local function worktree_pane(worktree, path)
}
end
---@param path string
---@return ow.Git.DiffSide
local function worktree_empty_pane(path)
return { buf = diff.empty_buf(), name = "git://worktree//" .. path }
end
---@param s ow.Git.SidebarState
---@param entry ow.Git.FileEntry
---@return ow.Git.DiffSide
@@ -519,10 +517,12 @@ local function index_pane(s, entry)
entry.section == "Untracked"
or (entry.section == "Staged" and entry.x == "D")
)
if not in_index then
return absent_pane(s.worktree, entry.path)
end
return {
buf = in_index and diff.git_show_buf(s.worktree, "index", entry.path)
or diff.empty_buf(),
name = "git://index//" .. entry.path,
buf = diff.git_show_buf(s.worktree, ":" .. entry.path),
name = "git://:" .. entry.path,
}
end
@@ -534,7 +534,7 @@ local function other_pane(s, entry)
local worktree = s.worktree
if entry.section == "Staged" then
if entry.x == "A" then
return head_empty_pane(p)
return absent_pane(worktree, p)
end
if entry.x == "D" then
return head_pane(worktree, p)
@@ -544,7 +544,7 @@ local function other_pane(s, entry)
end
if entry.section == "Unstaged" then
if entry.y == "D" then
return worktree_empty_pane(p)
return absent_pane(worktree, p)
end
return worktree_pane(worktree, p)
end