Skip to content

Commit 3990835

Browse files
Naxdydlyongemallo
authored andcommitted
fix(git): disable GPG signatures for log/show commands (sindrets#540)
Add --no-show-signature flag to git log and show commands to prevent GPG signature output from interfering with parsing. This fixes issues when users have log.showSignature enabled in their git config. Fixes sindrets#537
1 parent f728b1f commit 3990835

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

lua/diffview/vcs/adapters/git/init.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,11 @@ end
267267
---@param path string
268268
---@param rev Rev?
269269
function GitAdapter:get_show_args(path, rev)
270-
return utils.vec_join(self:args(), "show", fmt("%s:%s", rev and rev:object_name() or "", path))
270+
return utils.vec_join(self:args(), "show", "--no-show-signature", fmt("%s:%s", rev and rev:object_name() or "", path))
271271
end
272272

273273
function GitAdapter:get_log_args(args)
274-
return utils.vec_join("log", "--first-parent", "--stat", args)
274+
return utils.vec_join("log", "--no-show-signature", "--first-parent", "--stat", args)
275275
end
276276

277277
function GitAdapter:get_dir(path)
@@ -311,14 +311,14 @@ function GitAdapter:get_merge_context()
311311
end
312312

313313
local ret = {}
314-
local out, code = self:exec_sync({ "show", "-s", "--pretty=format:%H%n%D", "HEAD", "--" }, self.ctx.toplevel)
314+
local out, code = self:exec_sync({ "show", "-s", "--pretty=format:%H%n%D", "HEAD", "--no-show-signature", "--" }, self.ctx.toplevel)
315315

316316
ret.ours = code ~= 0 and {} or {
317317
hash = out[1],
318318
ref_names = out[2],
319319
}
320320

321-
out, code = self:exec_sync({ "show", "-s", "--pretty=format:%H%n%D", their_head, "--" }, self.ctx.toplevel)
321+
out, code = self:exec_sync({ "show", "-s", "--pretty=format:%H%n%D", their_head, "--no-show-signature", "--" }, self.ctx.toplevel)
322322

323323
ret.theirs = code ~= 0 and {} or {
324324
hash = out[1],
@@ -330,7 +330,7 @@ function GitAdapter:get_merge_context()
330330

331331
ret.base = {
332332
hash = out[1],
333-
ref_names = self:exec_sync({ "show", "-s", "--pretty=format:%D", out[1] }, self.ctx.toplevel)[1],
333+
ref_names = self:exec_sync({ "show", "-s", "--pretty=format:%D", out[1], "--no-show-signature" }, self.ctx.toplevel)[1],
334334
}
335335

336336
return ret
@@ -570,6 +570,7 @@ function GitAdapter:stream_fh_data(state)
570570
"-c",
571571
"core.quotePath=false",
572572
"log",
573+
"--no-show-signature",
573574
"--pretty=format:%x00%n" .. GitAdapter.COMMIT_PRETTY_FMT,
574575
"--numstat",
575576
"--raw",
@@ -649,6 +650,7 @@ function GitAdapter:stream_line_trace_data(state)
649650
"-c",
650651
"core.quotePath=false",
651652
"log",
653+
"--no-show-signature",
652654
"--color=never",
653655
"--no-ext-diff",
654656
"--pretty=format:%x00%n" .. GitAdapter.COMMIT_PRETTY_FMT,
@@ -720,6 +722,7 @@ function GitAdapter:file_history_dry_run(log_opt)
720722
else
721723
cmd = utils.vec_join(
722724
"log",
725+
"--no-show-signature",
723726
"--pretty=format:%H",
724727
"--name-status",
725728
options,
@@ -1036,6 +1039,7 @@ GitAdapter.fh_retry_commit = async.wrap(function(self, rev_arg, state, opt, call
10361039
"--pretty=format:" .. GitAdapter.COMMIT_PRETTY_FMT,
10371040
"--numstat",
10381041
"--raw",
1042+
"--no-show-signature",
10391043
"--diff-merges=" .. state.log_options.diff_merges,
10401044
(state.single_file and state.log_options.follow) and "--follow" or nil,
10411045
rev_arg,

0 commit comments

Comments
 (0)