Skip to content

Commit 037f242

Browse files
authored
fix(diff): use git show when only displaying one commit (#155)
1 parent ed8259b commit 037f242

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lua/lazy/view/diff.lua

+6-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ M.handlers = {
3232

3333
---@type LazyDiffFun
3434
git = function(plugin, diff)
35-
local cmd = { "git", "diff" }
35+
local cmd = { "git" }
3636
if diff.commit then
37+
cmd[#cmd + 1] = "show"
3738
cmd[#cmd + 1] = diff.commit
3839
else
40+
cmd[#cmd + 1] = "diff"
3941
cmd[#cmd + 1] = diff.from
4042
cmd[#cmd + 1] = diff.to
4143
end
@@ -44,10 +46,12 @@ M.handlers = {
4446

4547
---@type LazyDiffFun
4648
terminal_git = function(plugin, diff)
47-
local cmd = { "git", "diff" }
49+
local cmd = { "git" }
4850
if diff.commit then
51+
cmd[#cmd + 1] = "show"
4952
cmd[#cmd + 1] = diff.commit
5053
else
54+
cmd[#cmd + 1] = "diff"
5155
cmd[#cmd + 1] = diff.from
5256
cmd[#cmd + 1] = diff.to
5357
end

lua/lazy/view/init.lua

+1-3
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ function M.show(mode)
3838
M.view:update()
3939
end
4040

41-
---@param opts? {mode?:string}
42-
function M.create(opts)
41+
function M.create()
4342
local self = setmetatable({}, { __index = setmetatable(M, { __index = Float }) })
4443
---@cast self LazyView
4544
Float.init(self)
4645

4746
require("lazy.view.colors").setup()
48-
opts = opts or {}
4947

5048
self.state = vim.deepcopy(default_state)
5149

0 commit comments

Comments
 (0)