feat(picker.git_diff): added staged flag

This commit is contained in:
Folke Lemaitre 2025-10-29 15:30:58 +01:00
parent 0a33aec0c6
commit 118648ce93
No known key found for this signature in database
GPG key ID: 9B52594D560070AB
2 changed files with 4 additions and 0 deletions

View file

@ -335,6 +335,7 @@ M.git_status = {
---@class snacks.picker.git.diff.Config: snacks.picker.git.Config
---@field group? boolean group changes by file (when false, show individual hunks)
---@field staged? boolean show staged changes
---@field base? string base commit/branch/tag to diff against (default: HEAD)
M.git_diff = {
group = false,

View file

@ -260,6 +260,9 @@ function M.diff(opts, ctx)
if opts.base then
vim.list_extend(args, { "--merge-base", opts.base })
end
if opts.staged then
table.insert(args, "--cached")
end
return require("snacks.picker.source.diff").diff(
ctx:opts({
cmd = "git",