Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(diff): set --git-dir argument to overwrite user defined workspace $GIT_DIR #1950

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lua/lazy/view/diff.lua
Original file line number Diff line number Diff line change
@@ -23,18 +23,18 @@ M.handlers = {

---@type LazyDiffFun
["diffview.nvim"] = function(plugin, diff)
local args
local args = "--git-dir=.git" .. " " .. ("-C=%s"):format(plugin.dir) .. " "
if diff.commit then
args = ("-C=%s"):format(plugin.dir) .. " " .. diff.commit .. "^!"
args = args .. diff.commit .. "^!"
else
args = ("-C=%s"):format(plugin.dir) .. " " .. diff.from .. ".." .. diff.to
args = args .. diff.from .. ".." .. diff.to
end
vim.cmd("DiffviewOpen " .. args)
end,

---@type LazyDiffFun
git = function(plugin, diff)
local cmd = { "git" }
local cmd = { "git", "--git-dir=.git" }
if diff.commit then
cmd[#cmd + 1] = "show"
cmd[#cmd + 1] = diff.commit
@@ -48,7 +48,7 @@ M.handlers = {

---@type LazyDiffFun
terminal_git = function(plugin, diff)
local cmd = { "git" }
local cmd = { "git", "--git-dir=.git" }
if diff.commit then
cmd[#cmd + 1] = "show"
cmd[#cmd + 1] = diff.commit