From cbc8d4b20790a21f40d49bcab12755f26347f506 Mon Sep 17 00:00:00 2001 From: Andrzej Pacanowski Date: Wed, 12 Feb 2025 17:29:20 +0100 Subject: [PATCH 1/2] fix(git_status): Fix worktree not found when use_file_path=true --- lua/telescope/builtin/__git.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/telescope/builtin/__git.lua b/lua/telescope/builtin/__git.lua index b24267067d..23294b0ba2 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) From 6e3355e13155768085ec51d8bfa32532bf301967 Mon Sep 17 00:00:00 2001 From: Andrzej Pacanowski Date: Wed, 12 Feb 2025 17:41:16 +0100 Subject: [PATCH 2/2] stylua --- lua/telescope/builtin/__git.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lua/telescope/builtin/__git.lua b/lua/telescope/builtin/__git.lua index 23294b0ba2..9be59887c4 100644 --- a/lua/telescope/builtin/__git.lua +++ b/lua/telescope/builtin/__git.lua @@ -458,9 +458,7 @@ local try_worktrees = function(opts) end local current_path_toplevel = function() - local gitdir, ret, _ = utils.get_os_command_output( - {"git", "rev-parse", "--show-toplevel"}, - vim.fn.expand("%:p:h")) + 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