Skip to content

git_status { use_file_path = true } on worktree #3409

@P4Cu

Description

@P4Cu

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:

E5108: Error executing lua: ...data/lazy/telescope.nvim/lua/telescope/builtin/__git.lua:443: attempt to concatenate local 'worktrees' (a nil value)
stack traceback:
...data/lazy/telescope.nvim/lua/telescope/builtin/__git.lua:443: in function 'try_worktrees'...data/lazy/telescope.nvim/lua/telescope/builtin/__git.lua:477: in function 'set_opts_cwd'
...data/lazy/telescope.nvim/lua/telescope/builtin/__git.lua:507: in function 'v'
...-data/lazy/telescope.nvim/lua/telescope/builtin/init.lua:587: in function 'git_status'
...-data/lazy/AstroNvim/lua/astronvim/plugins/telescope.lua:27: in function <...-data/lazy/AstroNvim/lua/astronvim/plugins/telescope.lua:27>

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

NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

Operating system and version

windows 11

Telescope version / branch / rev

415af52

checkhealth telescope

==============================================================================
telescope: health#telescope#check

Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.

Checking external dependencies ~
- OK rg: found ripgrep 14.1.1 (rev 4649aa9700)
- OK fd: found fd 10.2.0

===== Installed extensions ===== ~

Telescope Extension: `aerial` ~
- No healthcheck provided

Telescope Extension: `dap` ~
- No healthcheck provided

Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured

Telescope Extension: `notify` ~
- No healthcheck provided

Steps to reproduce

  • nvim -nu minimal.lu
  • cd /some/git/worktree/path
  • :lua require("telescope.builtin").git_status { use_file_path = true } FAIL
  • :lua require("telescope.builtin").git_status { use_file_path = true } WORKS

Expected behavior

<worktree>/.git file is resolved and path for git is found.

Actual behavior

Fails with message.

Minimal config

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs { "config", "data", "state", "cache" } do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
  vim.fn.system {
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  }
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "nvim-telescope/telescope.nvim",
    dependencies = {
      "nvim-lua/plenary.nvim",
    },
    config = function()
      -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
      require("telescope").setup {}
    end,
  },
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions