refactor(git): drop boolean params from pane constructors

This commit is contained in:
2026-04-27 13:57:40 +02:00
parent 4dfd7ef5fa
commit 3b87d84ca9
+22 -13
View File
@@ -383,27 +383,33 @@ end
---@param worktree string ---@param worktree string
---@param path string ---@param path string
---@param content boolean
---@return ow.Git.DiffSide ---@return ow.Git.DiffSide
local function head_pane(worktree, path, content) local function head_pane(worktree, path)
return { return {
buf = content and diff.git_show_buf(worktree, "HEAD", path) buf = diff.git_show_buf(worktree, "HEAD", path),
or diff.empty_buf(),
name = "git://HEAD/" .. path, name = "git://HEAD/" .. path,
} }
end end
---@param path string
---@return ow.Git.DiffSide
local function head_empty_pane(path)
return { buf = diff.empty_buf(), name = "git://HEAD/" .. path }
end
---@param worktree string ---@param worktree string
---@param path string ---@param path string
---@param exists boolean
---@return ow.Git.DiffSide ---@return ow.Git.DiffSide
local function worktree_pane(worktree, path, exists) local function worktree_pane(worktree, path)
if exists then
return { return {
buf = diff.load_file_buf(vim.fs.joinpath(worktree, path)), buf = diff.load_file_buf(vim.fs.joinpath(worktree, path)),
name = nil, name = nil,
} }
end end
---@param path string
---@return ow.Git.DiffSide
local function worktree_empty_pane(path)
return { buf = diff.empty_buf(), name = "git://worktree/" .. path } return { buf = diff.empty_buf(), name = "git://worktree/" .. path }
end end
@@ -430,19 +436,22 @@ local function other_pane(s, entry)
local worktree = s.worktree local worktree = s.worktree
if entry.section == "Staged" then if entry.section == "Staged" then
if entry.x == "A" then if entry.x == "A" then
return head_pane(worktree, p, false) return head_empty_pane(p)
end end
if entry.x == "D" then if entry.x == "D" then
return head_pane(worktree, p, true) return head_pane(worktree, p)
end end
-- HEAD holds the pre-rename path -- HEAD holds the pre-rename path
return head_pane(worktree, entry.orig or p, true) return head_pane(worktree, entry.orig or p)
end end
if entry.section == "Unstaged" then if entry.section == "Unstaged" then
return worktree_pane(worktree, p, entry.y ~= "D") if entry.y == "D" then
return worktree_empty_pane(p)
end
return worktree_pane(worktree, p)
end end
if entry.section == "Untracked" then if entry.section == "Untracked" then
return worktree_pane(worktree, p, true) return worktree_pane(worktree, p)
end end
end end