Skip to content

Wrong assertion on fugitive directory buffers #1198

@TheLeoP

Description

@TheLeoP

Description

When I open a fugitive buffer by :Gedit somebranch:somedir (openning somedir in the branch somebranch), gitsigns throws the following error

Error executing luv callback:
...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:71: The async coroutine failed: ...local/share/nvim/lazy/gitsigns
.nvim/lua/gitsigns/git.lua:218: assertion failed!
stack traceback:
        [C]: in function 'assert'
        ...local/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/git.lua:218: in function 'file_info'
        ...local/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/git.lua:82: in function 'update'
        ...local/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/git.lua:431: in function 'new'
        ...al/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/attach.lua:221: in function 'fn'
        .../share/nvim/lazy/gitsigns.nvim/lua/gitsigns/debounce.lua:68: in function 'attach_throttled'
        ...al/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/attach.lua:374: in function <...al/share/nvim/lazy/gitsigns.nvim/lua
/gitsigns/attach.lua:373>
stack traceback:
        [C]: in function 'error'
        ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:71: in function 'callback'
        ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:107: in function 'on_exit'
        ...e/nvim/lazy/gitsigns.nvim/lua/gitsigns/system/compat.lua:257: in function <...e/nvim/lazy/gitsigns.nvim/lua/gitsig
ns/system/compat.lua:227>

This is because here

https://github.com/lewis6991/gitsigns.nvim/blob/c6fedfd0b1715ee624384b134becec0a7b0a3d28/lua/gitsigns/git.lua

the value of objtype is "tree"

Also, sometimes, when using . as somedir, a different error is thrown

Error executing luv callback:
/tmp/gitsigns_issue/gitsigns//lua/gitsigns/async.lua:71: The async coroutine failed: /tmp/gitsigns_issue/gitsigns//lua/gitsig
ns/git.lua:206: fatal: empty string is not a valid pathspec. please use . instead if you meant to match all paths

stack traceback:
        [C]: in function 'error'
        /tmp/gitsigns_issue/gitsigns//lua/gitsigns/debug/log.lua:136: in function 'eprint'
        /tmp/gitsigns_issue/gitsigns//lua/gitsigns/debug/log.lua:141: in function 'eprint'
        /tmp/gitsigns_issue/gitsigns//lua/gitsigns/git.lua:206: in function 'file_info'
        /tmp/gitsigns_issue/gitsigns//lua/gitsigns/git.lua:82: in function 'update'
        /tmp/gitsigns_issue/gitsigns//lua/gitsigns/git.lua:431: in function 'new'
        /tmp/gitsigns_issue/gitsigns//lua/gitsigns/attach.lua:221: in function 'fn'
        /tmp/gitsigns_issue/gitsigns//lua/gitsigns/debounce.lua:68: in function 'attach_throttled'
        /tmp/gitsigns_issue/gitsigns//lua/gitsigns/attach.lua:374: in function </tmp/gitsigns_issue/gitsigns//lua/gitsigns/at
tach.lua:373>
stack traceback:
        [C]: in function 'error'
        /tmp/gitsigns_issue/gitsigns//lua/gitsigns/async.lua:71: in function 'callback'
        /tmp/gitsigns_issue/gitsigns//lua/gitsigns/async.lua:107: in function 'on_exit'
        .../gitsigns_issue/gitsigns//lua/gitsigns/system/compat.lua:257: in function <.../gitsigns_issue/gitsigns//lua/gitsig
ns/system/compat.lua:227>

Neovim version

NVIM v0.10.4 Build type: RelWithDebInfo LuaJIT 2.1.1731601260 Run ":verbose version" for more info

Operating system and version

Arch Linux current

Expected behavior

Gitsigns shouldn't throw an error on vim-fugitive buffers

Actual behavior

Gitsigns throws an error on vim-fugitive buffers

Minimal config

for name, url in pairs({
	gitsigns = "https://github.com/lewis6991/gitsigns.nvim",
	-- ADD OTHER PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE
	fugitive = "https://github.com/tpope/vim-fugitive",
}) 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
	-- ADD GITSIGNS CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE
})

-- ADD INIT.LUA SETTINGS THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE

Steps to reproduce

  1. git clone https://github.com/lewis6991/gitsigns.nvim
  2. nvim --clean -u minimal.lua gitsigns.nvim/lua/gitsigns.lua
  3. :cd %:p:h:h
  4. :Gedit origin/actionval:lua/
  5. G (go to last entry on directory, should be gitsigns/ )
  6. <cr> (open gitsigns/ dir)

The first error is show

  1. :Gedit origin/actionval:.

The second error is shown

Gitsigns debug messages

1.72 D dprintf: Deriving GitSignsAdd from Added
1.82 D derive: Deriving GitSignsChange from Changed
1.99 D derive: Deriving GitSignsDelete from Removed
2.04 D derive: Deriving GitSignsChangedelete from GitSignsChange
2.09 D derive: Deriving GitSignsTopdelete from GitSignsDelete
2.15 D derive: Deriving GitSignsUntracked from GitSignsAdd
2.20 D derive: Deriving GitSignsAddNr from GitSignsAdd
2.30 D derive: Deriving GitSignsChangeNr from GitSignsChange
2.39 D derive: Deriving GitSignsDeleteNr from GitSignsDelete
2.42 D derive: Deriving GitSignsChangedeleteNr from GitSignsChangeNr
2.46 D derive: Deriving GitSignsTopdeleteNr from GitSignsDeleteNr
2.53 D derive: Deriving GitSignsUntrackedNr from GitSignsAddNr
2.60 D derive: Deriving GitSignsAddLn from DiffAdd
2.67 D derive: Deriving GitSignsChangeLn from DiffChange
2.75 D derive: Deriving GitSignsChangedeleteLn from GitSignsChangeLn
2.78 D derive: Deriving GitSignsTopdeleteLn from GitSignsDeleteLn
2.82 D derive: Deriving GitSignsUntrackedLn from GitSignsAddLn
2.85 D derive: Deriving GitSignsAddCul from GitSignsAdd
2.98 D derive: Deriving GitSignsChangeCul from GitSignsChange
3.01 D derive: Deriving GitSignsDeleteCul from GitSignsDelete
3.05 D derive: Deriving GitSignsChangedeleteCul from GitSignsChangeCul
3.09 D derive: Deriving GitSignsTopdeleteCul from GitSignsDeleteCul
3.14 D derive: Deriving GitSignsUntrackedCul from GitSignsAddCul
3.17 D derive: Deriving GitSignsStagedAdd from GitSignsAdd
3.21 D derive: Deriving GitSignsStagedChange from GitSignsChange
3.24 D derive: Deriving GitSignsStagedDelete from GitSignsDelete
3.28 D derive: Deriving GitSignsStagedChangedelete from GitSignsChangedelete
3.31 D derive: Deriving GitSignsStagedTopdelete from GitSignsTopdelete
3.39 D derive: Deriving GitSignsStagedUntracked from GitSignsUntracked
3.45 D derive: Deriving GitSignsStagedAddNr from GitSignsAddNr
3.49 D derive: Deriving GitSignsStagedChangeNr from GitSignsChangeNr
3.52 D derive: Deriving GitSignsStagedDeleteNr from GitSignsDeleteNr
3.55 D derive: Deriving GitSignsStagedChangedeleteNr from GitSignsChangedeleteNr
3.59 D derive: Deriving GitSignsStagedTopdeleteNr from GitSignsTopdeleteNr
3.62 D derive: Deriving GitSignsStagedUntrackedNr from GitSignsUntrackedNr
3.65 D derive: Deriving GitSignsStagedAddLn from GitSignsAddLn
3.69 D derive: Deriving GitSignsStagedChangeLn from GitSignsChangeLn
3.73 D derive: Deriving GitSignsStagedChangedeleteLn from GitSignsChangedeleteLn
3.79 D derive: Could not derive GitSignsStagedTopdeleteLn
3.83 D derive: Deriving GitSignsStagedUntrackedLn from GitSignsUntrackedLn
3.88 D derive: Deriving GitSignsStagedAddCul from GitSignsAddCul
3.92 D derive: Deriving GitSignsStagedChangeCul from GitSignsChangeCul
3.95 D derive: Deriving GitSignsStagedDeleteCul from GitSignsDeleteCul
3.99 D derive: Deriving GitSignsStagedChangedeleteCul from GitSignsChangedeleteCul
4.03 D derive: Deriving GitSignsStagedTopdeleteCul from GitSignsTopdeleteCul
4.08 D derive: Deriving GitSignsStagedUntrackedCul from GitSignsUntrackedCul
4.12 D derive: Deriving GitSignsAddPreview from DiffAdd
4.17 D derive: Deriving GitSignsDeletePreview from DiffDelete
4.21 D derive: Deriving GitSignsCurrentLineBlame from NonText
4.25 D derive: Deriving GitSignsAddInline from TermCursor
4.30 D derive: Deriving GitSignsDeleteInline from TermCursor
4.34 D derive: Deriving GitSignsChangeInline from TermCursor
4.38 D derive: Deriving GitSignsAddLnInline from GitSignsAddInline
4.43 D derive: Deriving GitSignsChangeLnInline from GitSignsChangeInline
4.57 D derive: Deriving GitSignsDeleteLnInline from GitSignsDeleteInline
4.62 D derive: Deriving GitSignsDeleteVirtLn from DiffDelete
4.68 D derive: Deriving GitSignsDeleteVirtLnInLine from GitSignsDeleteLnInline
4.75 D derive: Deriving GitSignsVirtLnum from GitSignsDeleteVirtLn
15.59 D attach(1): Attaching (trigger=BufReadPost)
15.82 D run_job: git --version
42.33 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
44.90 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns.nvim/.git config user.name
47.10 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns.nvim/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol /tmp/gitsigns.nvim/lua/gitsigns.lua
51.31 D watch_gitdir(1): Watching git dir
51.48 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns.nvim/.git show 4ea369a5c61dae12c62b39fcc9a7fdb99ddc6474
58.25 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns.nvim/.git show HEAD:lua/gitsigns.lua
16350.47 D attach(2): Attaching (trigger=BufReadPost)
16350.62 D parse_git_path: Fugitive buffer for file '' from path 'nil' on commit '8cb80be5a0f4c8b0fdd35c7858ed126eda792129'
16355.39 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns.nvim/.git rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
16357.90 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns.nvim/.git config user.name
16360.66 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns.nvim/.git -c core.quotepath=off ls-tree 8cb80be5a0f4c8b0fdd35c7858ed126eda792129 
16363.31 E /tmp/gitsigns_issue/gitsigns//lua/gitsigns/git.lua<206>: fatal: empty string is not a valid pathspec. please use . instead if you meant to match all paths

stack traceback:
	/tmp/gitsigns_issue/gitsigns//lua/gitsigns/debug/log.lua:134: in function 'eprint'
	/tmp/gitsigns_issue/gitsigns//lua/gitsigns/debug/log.lua:141: in function 'eprint'
	/tmp/gitsigns_issue/gitsigns//lua/gitsigns/git.lua:206: in function 'file_info'
	/tmp/gitsigns_issue/gitsigns//lua/gitsigns/git.lua:82: in function 'update'
	/tmp/gitsigns_issue/gitsigns//lua/gitsigns/git.lua:431: in function 'new'
	/tmp/gitsigns_issue/gitsigns//lua/gitsigns/attach.lua:221: in function 'fn'
	/tmp/gitsigns_issue/gitsigns//lua/gitsigns/debounce.lua:68: in function 'attach_throttled'
	/tmp/gitsigns_issue/gitsigns//lua/gitsigns/attach.lua:374: in function </tmp/gitsigns_issue/gitsigns//lua/gitsigns/attach.lua:373>
34948.91 D attach(5): Attaching (trigger=BufReadPost)
34949.01 D parse_git_path: Fugitive buffer for file 'lua/' from path 'nil' on commit '8cb80be5a0f4c8b0fdd35c7858ed126eda792129'
34951.79 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns.nvim/.git rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
34954.57 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns.nvim/.git -c core.quotepath=off ls-tree 8cb80be5a0f4c8b0fdd35c7858ed126eda792129 lua/
34958.02 D attach(5): Not a file
92323.92 D attach(7): Attaching (trigger=BufReadPost)
92324.02 D parse_git_path: Fugitive buffer for file 'lua/gitsigns' from path 'nil' on commit '8cb80be5a0f4c8b0fdd35c7858ed126eda792129'
92327.42 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns.nvim/.git rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
92330.14 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns.nvim/.git -c core.quotepath=off ls-tree 8cb80be5a0f4c8b0fdd35c7858ed126eda792129 lua/gitsigns
158400.57 D cli.run: Running action 'debug_messages' with arguments {}
170233.42 D cli.run: Running action 'debug_messages' with arguments {}
232019.65 D cli.run: Running action 'debug_messages' with arguments {}

Gitsigns cache

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions