diff options
| author | Simon Hauser <Simon-Hauser@outlook.de> | 2021-02-09 18:25:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-09 18:25:57 +0100 |
| commit | 3a7fa41857394cd2d90d00891413c12fada039c3 (patch) | |
| tree | bff862cb4e8f3623fe167f1105e9f1dac72dfb95 /lua/telescope/actions/init.lua | |
| parent | 993e383dd5356bf10c5cf2b5d0ac88f9c7746181 (diff) | |
fix: all git builtin respect cwd now (#517)
Diffstat (limited to 'lua/telescope/actions/init.lua')
| -rw-r--r-- | lua/telescope/actions/init.lua | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua index 4e82777..bd2c4bd 100644 --- a/lua/telescope/actions/init.lua +++ b/lua/telescope/actions/init.lua @@ -5,6 +5,7 @@ local a = vim.api local log = require('telescope.log') local path = require('telescope.path') local state = require('telescope.state') +local utils = require('telescope.utils') local transform_mod = require('telescope.actions.mt').transform_mod @@ -262,22 +263,23 @@ actions.insert_value = function(prompt_bufnr) end actions.git_checkout = function(prompt_bufnr) - local selection = actions.get_selected_entry(prompt_bufnr) + local cwd = actions.get_current_picker(prompt_bufnr).cwd + local selection = actions.get_selected_entry() actions.close(prompt_bufnr) - local val = selection.value - os.execute('git checkout ' .. val) + utils.get_os_command_output({ 'git', 'checkout', selection.value }, cwd) end actions.git_staging_toggle = function(prompt_bufnr) - local selection = actions.get_selected_entry(prompt_bufnr) + local cwd = actions.get_current_picker(prompt_bufnr).cwd + local selection = actions.get_selected_entry() -- If parts of the file are staged and unstaged at the same time, stage -- changes. Else toggle between staged and unstaged if the file is tracked, -- and between added and untracked if the file is untracked. if selection.status:sub(2) == ' ' then - os.execute('git restore --staged ' .. selection.value) + utils.get_os_command_output({ 'git', 'restore', '--staged', selection.value }, cwd) else - os.execute('git add ' .. selection.value) + utils.get_os_command_output({ 'git', 'add', selection.value }, cwd) end do_close(prompt_bufnr, true) require('telescope.builtin').git_status() |
