lewis6991 / gitsigns.nvim

Git integration for buffers
MIT License
5.12k stars 192 forks source link

Gitsigns assertion error in folder not using git #989

Closed Kayzels closed 6 months ago

Kayzels commented 6 months ago

Description

Whenever I open a file in a folder that isn't part of a git repo, I get an error about an assertion failure.

As this file is not in a git repo, I don't expect gitsigns to be running, or providing error messages.

Neovim version

NVIM v0.10.0-dev-2930+g47ba96a6b Build type: RelWithDebInfo LuaJIT 2.1.1710088188

Operating system and version

Windows 10 Pro 22H2 19045.3803

Expected behavior

No popup or error for folders not part of a git repo

Actual behavior

Popup about assertion error executing luv callback:

Error executing luv callback:
... Gitsigns\gitsigns_issue\gitsigns/lua/gitsigns/async.lua:85: The coroutine failed with this message: ...im Gitsigns\gitsigns_issue\gitsigns/lua/gitsigns/git.lua:337: assertion failed!
stack traceback:
    [C]: in function 'assert'
    ...im Gitsigns\gitsigns_issue\gitsigns/lua/gitsigns/git.lua:337: in function 'try_yadm'
    ...im Gitsigns\gitsigns_issue\gitsigns/lua/gitsigns/git.lua:372: in function 'new'
    ...im Gitsigns\gitsigns_issue\gitsigns/lua/gitsigns/git.lua:829: in function 'new'
    ...Gitsigns\gitsigns_issue\gitsigns/lua/gitsigns/attach.lua:270: in function 'fn'
    ...tsigns\gitsigns_issue\gitsigns/lua/gitsigns/debounce.lua:68: in function 'attach_throttled'
    ...Gitsigns\gitsigns_issue\gitsigns/lua/gitsigns/attach.lua:424: in function <...Gitsigns\gitsigns_issue\gitsigns/lua/gitsigns/attach.lua:423>
stack traceback:
    [C]: in function 'error'
    ... Gitsigns\gitsigns_issue\gitsigns/lua/gitsigns/async.lua:85: in function 'cb'
    ... Gitsigns\gitsigns_issue\gitsigns/lua/gitsigns/async.lua:127: in function 'on_exit'
    ...gram Files\Neovim\share\nvim\runtime/lua/vim/_system.lua:300: in function <...gram Files\Neovim\share\nvim\runtime/lua/vim/_system.lua:270>

Minimal config

for name, url in pairs{
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
} do
  local install_path = vim.fn.fnamemodify('gitsigns_issue/'..name, ':p')
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
  vim.opt.runtimepath:append(install_path)
end

require('gitsigns').setup{
  debug_mode = true, -- You must add this to enable debug messages
}

Steps to reproduce

  1. nvim --clean -u minimal.lua
  2. Open a file not in a git repo (including the minimal.lua above)

Gitsigns debug messages

Excluding the lines for deriving the signs

signs.init: Using extmark signs
attach(1): Attaching (trigger=BufReadPost)
run_job: git --no-pager --literal-pathspecs -c gc.auto=0 config user.name
run_job: git --version
run_job: git --no-pager --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
cli.run: Running action 'debug_messages' with arguments {}
cli.run: Running action 'debug_messages' with arguments {}
lewis6991 commented 6 months ago

Thanks for the report. Should be fixed.