fix: opts.git_command for files, commits, bcommits (#1374)
This commit is contained in:
@@ -848,6 +848,8 @@ builtin.git_files({opts}) *builtin.git_files()*
|
|||||||
{recurse_submodules} (boolean) if true, adds the
|
{recurse_submodules} (boolean) if true, adds the
|
||||||
`--recurse-submodules` flag to command
|
`--recurse-submodules` flag to command
|
||||||
(default: false)
|
(default: false)
|
||||||
|
{git_command} (table) command that will be exectued.
|
||||||
|
{"git","ls-files","--exclude-standard","--cached"}
|
||||||
|
|
||||||
|
|
||||||
builtin.git_commits({opts}) *builtin.git_commits()*
|
builtin.git_commits({opts}) *builtin.git_commits()*
|
||||||
@@ -866,6 +868,8 @@ builtin.git_commits({opts}) *builtin.git_commits()*
|
|||||||
{cwd} (string) specify the path of the repo
|
{cwd} (string) specify the path of the repo
|
||||||
{use_git_root} (boolean) if we should use git root as cwd or the cwd
|
{use_git_root} (boolean) if we should use git root as cwd or the cwd
|
||||||
(important for submodule) (default: true)
|
(important for submodule) (default: true)
|
||||||
|
{git_command} (table) command that will be exectued.
|
||||||
|
{"git","log","--pretty=oneline","--abbrev-commit","--","."}
|
||||||
|
|
||||||
|
|
||||||
builtin.git_bcommits({opts}) *builtin.git_bcommits()*
|
builtin.git_bcommits({opts}) *builtin.git_bcommits()*
|
||||||
@@ -886,6 +890,8 @@ builtin.git_bcommits({opts}) *builtin.git_bcommits()*
|
|||||||
(important for submodule) (default: true)
|
(important for submodule) (default: true)
|
||||||
{current_file} (string) specify the current file that should be used
|
{current_file} (string) specify the current file that should be used
|
||||||
for bcommits (default: current buffer)
|
for bcommits (default: current buffer)
|
||||||
|
{git_command} (table) command that will be exectued.
|
||||||
|
{"git","log","--pretty=oneline","--abbrev-commit"}
|
||||||
|
|
||||||
|
|
||||||
builtin.git_branches({opts}) *builtin.git_branches()*
|
builtin.git_branches({opts}) *builtin.git_branches()*
|
||||||
|
|||||||
@@ -22,16 +22,14 @@ git.files = function(opts)
|
|||||||
|
|
||||||
-- By creating the entry maker after the cwd options,
|
-- By creating the entry maker after the cwd options,
|
||||||
-- we ensure the maker uses the cwd options when being created.
|
-- we ensure the maker uses the cwd options when being created.
|
||||||
opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts)
|
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_file(opts))
|
||||||
|
local git_command = vim.F.if_nil(opts.git_command, { "git", "ls-files", "--exclude-standard", "--cached" })
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers.new(opts, {
|
||||||
prompt_title = "Git Files",
|
prompt_title = "Git Files",
|
||||||
finder = finders.new_oneshot_job(
|
finder = finders.new_oneshot_job(
|
||||||
vim.tbl_flatten {
|
vim.tbl_flatten {
|
||||||
"git",
|
git_command,
|
||||||
"ls-files",
|
|
||||||
"--exclude-standard",
|
|
||||||
"--cached",
|
|
||||||
show_untracked and "--others" or nil,
|
show_untracked and "--others" or nil,
|
||||||
recurse_submodules and "--recurse-submodules" or nil,
|
recurse_submodules and "--recurse-submodules" or nil,
|
||||||
},
|
},
|
||||||
@@ -43,22 +41,12 @@ git.files = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
git.commits = function(opts)
|
git.commits = function(opts)
|
||||||
opts.entry_maker = opts.entry_maker or make_entry.gen_from_git_commits(opts)
|
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_commits(opts))
|
||||||
|
local git_command = vim.F.if_nil(opts.git_command, { "git", "log", "--pretty=oneline", "--abbrev-commit", "--", "." })
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers.new(opts, {
|
||||||
prompt_title = "Git Commits",
|
prompt_title = "Git Commits",
|
||||||
|
finder = finders.new_oneshot_job(git_command, opts),
|
||||||
finder = finders.new_oneshot_job(
|
|
||||||
vim.tbl_flatten {
|
|
||||||
"git",
|
|
||||||
"log",
|
|
||||||
"--pretty=oneline",
|
|
||||||
"--abbrev-commit",
|
|
||||||
"--",
|
|
||||||
".",
|
|
||||||
},
|
|
||||||
opts
|
|
||||||
),
|
|
||||||
previewer = {
|
previewer = {
|
||||||
previewers.git_commit_diff_to_parent.new(opts),
|
previewers.git_commit_diff_to_parent.new(opts),
|
||||||
previewers.git_commit_diff_to_head.new(opts),
|
previewers.git_commit_diff_to_head.new(opts),
|
||||||
@@ -80,7 +68,7 @@ git.commits = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
git.stash = function(opts)
|
git.stash = function(opts)
|
||||||
opts.entry_maker = opts.entry_maker or make_entry.gen_from_git_stash()
|
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_stash())
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers.new(opts, {
|
||||||
prompt_title = "Git Stash",
|
prompt_title = "Git Stash",
|
||||||
@@ -108,19 +96,16 @@ local get_current_buf_line = function(winnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
git.bcommits = function(opts)
|
git.bcommits = function(opts)
|
||||||
opts.current_line = not opts.current_file and get_current_buf_line(0) or nil
|
opts.current_line = (opts.current_file == nil) and get_current_buf_line(0) or nil
|
||||||
opts.current_file = opts.current_file or vim.fn.expand "%:p"
|
opts.current_file = vim.F.if_nil(opts.current_file, vim.fn.expand "%:p")
|
||||||
|
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_commits(opts))
|
||||||
opts.entry_maker = opts.entry_maker or make_entry.gen_from_git_commits(opts)
|
local git_command = vim.F.if_nil(opts.git_command, { "git", "log", "--pretty=oneline", "--abbrev-commit" })
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers.new(opts, {
|
||||||
prompt_title = "Git BCommits",
|
prompt_title = "Git BCommits",
|
||||||
finder = finders.new_oneshot_job(
|
finder = finders.new_oneshot_job(
|
||||||
vim.tbl_flatten {
|
vim.tbl_flatten {
|
||||||
"git",
|
git_command,
|
||||||
"log",
|
|
||||||
"--pretty=oneline",
|
|
||||||
"--abbrev-commit",
|
|
||||||
opts.current_file,
|
opts.current_file,
|
||||||
},
|
},
|
||||||
opts
|
opts
|
||||||
@@ -326,7 +311,7 @@ git.status = function(opts)
|
|||||||
|
|
||||||
return finders.new_table {
|
return finders.new_table {
|
||||||
results = output,
|
results = output,
|
||||||
entry_maker = opts.entry_maker or make_entry.gen_from_git_status(opts),
|
entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_status(opts)),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -380,7 +365,7 @@ end
|
|||||||
local function apply_checks(mod)
|
local function apply_checks(mod)
|
||||||
for k, v in pairs(mod) do
|
for k, v in pairs(mod) do
|
||||||
mod[k] = function(opts)
|
mod[k] = function(opts)
|
||||||
opts = opts or {}
|
opts = vim.F.if_nil(opts, {})
|
||||||
|
|
||||||
set_opts_cwd(opts)
|
set_opts_cwd(opts)
|
||||||
v(opts)
|
v(opts)
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ builtin.current_buffer_tags = require_on_exported_call("telescope.builtin.files"
|
|||||||
---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true)
|
---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true)
|
||||||
---@field show_untracked boolean: if true, adds `--others` flag to command and shows untracked files (default: true)
|
---@field show_untracked boolean: if true, adds `--others` flag to command and shows untracked files (default: true)
|
||||||
---@field recurse_submodules boolean: if true, adds the `--recurse-submodules` flag to command (default: false)
|
---@field recurse_submodules boolean: if true, adds the `--recurse-submodules` flag to command (default: false)
|
||||||
|
---@field git_command table: command that will be exectued. {"git","ls-files","--exclude-standard","--cached"}
|
||||||
builtin.git_files = require_on_exported_call("telescope.builtin.git").files
|
builtin.git_files = require_on_exported_call("telescope.builtin.git").files
|
||||||
|
|
||||||
--- Lists commits for current directory with diff preview
|
--- Lists commits for current directory with diff preview
|
||||||
@@ -157,6 +158,7 @@ builtin.git_files = require_on_exported_call("telescope.builtin.git").files
|
|||||||
---@param opts table: options to pass to the picker
|
---@param opts table: options to pass to the picker
|
||||||
---@field cwd string: specify the path of the repo
|
---@field cwd string: specify the path of the repo
|
||||||
---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true)
|
---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true)
|
||||||
|
---@field git_command table: command that will be exectued. {"git","log","--pretty=oneline","--abbrev-commit","--","."}
|
||||||
builtin.git_commits = require_on_exported_call("telescope.builtin.git").commits
|
builtin.git_commits = require_on_exported_call("telescope.builtin.git").commits
|
||||||
|
|
||||||
--- Lists commits for current buffer with diff preview
|
--- Lists commits for current buffer with diff preview
|
||||||
@@ -169,6 +171,7 @@ builtin.git_commits = require_on_exported_call("telescope.builtin.git").commits
|
|||||||
---@field cwd string: specify the path of the repo
|
---@field cwd string: specify the path of the repo
|
||||||
---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true)
|
---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true)
|
||||||
---@field current_file string: specify the current file that should be used for bcommits (default: current buffer)
|
---@field current_file string: specify the current file that should be used for bcommits (default: current buffer)
|
||||||
|
---@field git_command table: command that will be exectued. {"git","log","--pretty=oneline","--abbrev-commit"}
|
||||||
builtin.git_bcommits = require_on_exported_call("telescope.builtin.git").bcommits
|
builtin.git_bcommits = require_on_exported_call("telescope.builtin.git").bcommits
|
||||||
|
|
||||||
--- List branches for current directory, with output from `git log --oneline` shown in the preview window
|
--- List branches for current directory, with output from `git log --oneline` shown in the preview window
|
||||||
|
|||||||
Reference in New Issue
Block a user