refactor(git): drop boolean params from pane constructors
This commit is contained in:
+21
-12
@@ -383,27 +383,33 @@ end
|
||||
|
||||
---@param worktree string
|
||||
---@param path string
|
||||
---@param content boolean
|
||||
---@return ow.Git.DiffSide
|
||||
local function head_pane(worktree, path, content)
|
||||
local function head_pane(worktree, path)
|
||||
return {
|
||||
buf = content and diff.git_show_buf(worktree, "HEAD", path)
|
||||
or diff.empty_buf(),
|
||||
buf = diff.git_show_buf(worktree, "HEAD", path),
|
||||
name = "git://HEAD/" .. path,
|
||||
}
|
||||
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 path string
|
||||
---@param exists boolean
|
||||
---@return ow.Git.DiffSide
|
||||
local function worktree_pane(worktree, path, exists)
|
||||
if exists then
|
||||
local function worktree_pane(worktree, path)
|
||||
return {
|
||||
buf = diff.load_file_buf(vim.fs.joinpath(worktree, path)),
|
||||
name = nil,
|
||||
}
|
||||
end
|
||||
|
||||
---@param path string
|
||||
---@return ow.Git.DiffSide
|
||||
local function worktree_empty_pane(path)
|
||||
return { buf = diff.empty_buf(), name = "git://worktree/" .. path }
|
||||
end
|
||||
|
||||
@@ -430,19 +436,22 @@ local function other_pane(s, entry)
|
||||
local worktree = s.worktree
|
||||
if entry.section == "Staged" then
|
||||
if entry.x == "A" then
|
||||
return head_pane(worktree, p, false)
|
||||
return head_empty_pane(p)
|
||||
end
|
||||
if entry.x == "D" then
|
||||
return head_pane(worktree, p, true)
|
||||
return head_pane(worktree, p)
|
||||
end
|
||||
-- HEAD holds the pre-rename path
|
||||
return head_pane(worktree, entry.orig or p, true)
|
||||
return head_pane(worktree, entry.orig or p)
|
||||
end
|
||||
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
|
||||
if entry.section == "Untracked" then
|
||||
return worktree_pane(worktree, p, true)
|
||||
return worktree_pane(worktree, p)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user