-
-
Notifications
You must be signed in to change notification settings - Fork 855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
git_status { use_file_path = true } on worktree #3409
Comments
If somebody points me how the path should be resolved I might prepare a PR or maybe it's actually a good case to try out |
So the solution is super simple and only bound to that command. We're looking for diff --git a/lua/telescope/builtin/__git.lua b/lua/telescope/builtin/__git.lua
index b242670..23294b0 100644
--- a/lua/telescope/builtin/__git.lua
+++ b/lua/telescope/builtin/__git.lua
@@ -458,11 +458,13 @@ local try_worktrees = function(opts)
end
local current_path_toplevel = function()
- local gitdir = vim.fn.finddir(".git", vim.fn.expand "%:p" .. ";")
- if gitdir == "" then
+ local gitdir, ret, _ = utils.get_os_command_output(
+ {"git", "rev-parse", "--show-toplevel"},
+ vim.fn.expand("%:p:h"))
+ if ret ~= 0 or gitdir == nil then
return nil
end
- return Path:new(gitdir):parent():absolute()
+ return Path:new(gitdir[1]):absolute()
end
local set_opts_cwd = function(opts) |
neovim has a builtin api So a simpler method: local gitdir = vim.fs.root(0, '.git') this work both on dir |
Simpler, but a bit less portable due to that fact. Either of those fixes is good to me so I can update PR. |
Hey @Conni2461 I think this is ready for review/merge. |
Description
I've noticed that when I try to
:lua require("telescope.builtin").git_status { use_file_path = true }
for a git-worktree I get:Doing
:lua require("telescope.builtin").git_status { use_file_path = false }
works just fine.use_file_path = true
unfortunately is a default of Astronvim<leader>gt
binding.Neovim version
Operating system and version
windows 11
Telescope version / branch / rev
415af52
checkhealth telescope
Steps to reproduce
:lua require("telescope.builtin").git_status { use_file_path = true }
FAILExpected behavior
<worktree>/.git
file is resolved and path for git is found.Actual behavior
Fails with message.
Minimal config
The text was updated successfully, but these errors were encountered: