From 3a7fa41857394cd2d90d00891413c12fada039c3 Mon Sep 17 00:00:00 2001 From: Simon Hauser Date: Tue, 9 Feb 2021 18:25:57 +0100 Subject: fix: all git builtin respect cwd now (#517) --- lua/telescope/actions/init.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lua/telescope/actions/init.lua') 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() -- cgit v1.2.3