diff options
| author | Tom <tapayne88@users.noreply.github.com> | 2021-02-27 11:04:30 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-27 12:04:30 +0100 |
| commit | 49650f5d749fef3d1e6cf52ba031c02163a59158 (patch) | |
| tree | d084e83d0fa2453d5690100eeca482b9a7fa18da /lua/telescope/builtin/git.lua | |
| parent | d37dc88eab1be7dc853af212537fdeb9fe2542a7 (diff) | |
feat: allow git_* to use vim pwd over git root (#563)
with opt use_git_root = false
Examples:
- Telescope git_files use_git_root=false
- Telescope git_commits use_git_root=false
- Telescope git_status use_git_root=false
Diffstat (limited to 'lua/telescope/builtin/git.lua')
| -rw-r--r-- | lua/telescope/builtin/git.lua | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lua/telescope/builtin/git.lua b/lua/telescope/builtin/git.lua index c403f14..a296517 100644 --- a/lua/telescope/builtin/git.lua +++ b/lua/telescope/builtin/git.lua @@ -37,7 +37,9 @@ git.files = function(opts) end git.commits = function(opts) - local results = utils.get_os_command_output({ 'git', 'log', '--pretty=oneline', '--abbrev-commit' }, opts.cwd) + local results = utils.get_os_command_output({ + 'git', 'log', '--pretty=oneline', '--abbrev-commit', '--', '.' + }, opts.cwd) pickers.new(opts, { prompt_title = 'Git Commits', @@ -110,7 +112,7 @@ end git.status = function(opts) local gen_new_finder = function() - local output = utils.get_os_command_output({ 'git', 'status', '-s' }, opts.cwd) + local output = utils.get_os_command_output({ 'git', 'status', '-s', '--', '.' }, opts.cwd) if table.getn(output) == 0 then print('No changes found') @@ -154,11 +156,14 @@ local set_opts_cwd = function(opts) -- Find root of git directory and remove trailing newline characters local git_root = vim.fn.systemlist("git -C " .. opts.cwd .. " rev-parse --show-toplevel")[1] + local use_git_root = utils.get_default(opts.use_git_root, true) if vim.v.shell_error ~= 0 then error(opts.cwd .. ' is not a git directory') else - opts.cwd = git_root + if use_git_root then + opts.cwd = git_root + end end end |
