NeogitOrg / neogit

An interactive and powerful Git interface for Neovim, inspired by Magit
MIT License
3.92k stars 231 forks source link

Neogit consistently throwing errors in specific repo (unable to pin point difference between working repo and this repo) #1486

Open LarssonMartin1998 opened 1 week ago

LarssonMartin1998 commented 1 week ago

Description

Hey,

I only get this issue in our specific repository at work where I am completely unable to use Neogit, it flat out doesnt' work. When I run the :Neogit command to open and interact with git, it doesn't load for a few seconds and says v Head: 000000 (no commits). After a few seconds it throws an error log.

Given the log, at first I thought it was some issue with the serialized session, however, clearing the session and disabling the auto_session plugin made no difference.

Unfortunately, I haven't been able to pin point what the difference is in this repo versus all other repos where this plugin works wonders.

Neovim version

NVIM v0.11.0-dev-604+g3b87fa406 Build type: Release LuaJIT 2.1.1724512491

Operating system and version

macOS 14.6.1

Steps to reproduce

Difficult to reproduce unless you're in a git repo with this same issue which I am unable to pin point. Otherwise, start neovim, enter :Neogit, and observe the issue.

Expected behavior

No response

Actual behavior

https://github.com/user-attachments/assets/244d0d73-d266-4b3e-a074-f6212a944aac

Here is the log:

Error executing vim.schedule lua callback: vim/_editor.lua:0: nvim_exec2(): Vim(buffer):E86: Buffer 8 does not exist
stack traceback:
    [C]: in function 'nvim_exec2'
    vim/_editor.lua: in function 'cmd'
    ...on/.local/share/nvim/lazy/neogit/lua/neogit/lib/util.lua:602: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>
Error executing vim.schedule lua callback: vim/_editor.lua:0: nvim_exec2(): Vim(buffer):E86: Buffer 8 does not exist
stack traceback:
    [C]: in function 'nvim_exec2'
    vim/_editor.lua: in function 'cmd'
    ...on/.local/share/nvim/lazy/neogit/lua/neogit/lib/util.lua:602: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>
Error executing vim.schedule lua callback: vim/_editor.lua:0: nvim_exec2(): Vim(buffer):E86: Buffer 8 does not exist
stack traceback:
    [C]: in function 'nvim_exec2'
    vim/_editor.lua: in function 'cmd'
    ...on/.local/share/nvim/lazy/neogit/lua/neogit/lib/util.lua:602: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>
Error executing vim.schedule lua callback: vim/_editor.lua:0: nvim_exec2(): Vim(buffer):E86: Buffer 8 does not exist
stack traceback:
    [C]: in function 'nvim_exec2'
    vim/_editor.lua: in function 'cmd'
    ...on/.local/share/nvim/lazy/neogit/lua/neogit/lib/util.lua:602: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>
Error executing vim.schedule lua callback: vim/_editor.lua:0: nvim_exec2(): Vim(buffer):E86: Buffer 8 does not exist
stack traceback:
    [C]: in function 'nvim_exec2'
    vim/_editor.lua: in function 'cmd'
    ...on/.local/share/nvim/lazy/neogit/lua/neogit/lib/util.lua:602: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>
Error executing vim.schedule lua callback: vim/_editor.lua:0: nvim_exec2(): Vim(buffer):E86: Buffer 8 does not exist
stack traceback:
    [C]: in function 'nvim_exec2'
    vim/_editor.lua: in function 'cmd'
    ...on/.local/share/nvim/lazy/neogit/lua/neogit/lib/util.lua:602: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>
...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:18: The coroutine failed with this message: .../.local/share/nvim/lazy/neogit/lua/neogit/lib/buffer.lua:369: Invalid buffer id: 8
stack traceback:
    [C]: in function 'error'
    ...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:18: in function 'callback_or_next'
    ...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:45: in function 'step'
    ...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:48: in function 'execute'
    ...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:118: in function 'callback'
    ...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:25: in function 'callback_or_next'
    ...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:45: in function 'saved_callback'
    ...are/nvim/lazy/plenary.nvim/lua/plenary/async/control.lua:126: in function 'tx'
    .../share/nvim/lazy/plenary.nvim/lua/plenary/async/util.lua:71: in function 'callback'
    ...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:25: in function 'callback_or_next'
    ...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:45: in function 'cb'
    ...son/.local/share/nvim/lazy/neogit/lua/neogit/process.lua:299: in function <...son/.local/share/nvim/lazy/neogit/lua/neogit/process.lua:264>

Minimal config

-- NOTE: See the end of this file if you are reporting an issue, etc. Ignore all the "scary" functions up top, those are
-- used for setup and other operations.
local M = {}

local base_root_path = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h") .. "/.min"
function M.root(path)
  return base_root_path .. "/" .. (path or "")
end

function M.load_plugin(plugin_name, plugin_url)
  local package_root = M.root("plugins/")
  local install_destination = package_root .. plugin_name
  vim.opt.runtimepath:append(install_destination)

  if not vim.loop.fs_stat(package_root) then
    vim.fn.mkdir(package_root, "p")
  end

  if not vim.loop.fs_stat(install_destination) then
    print(string.format("> Downloading plugin '%s' to '%s'", plugin_name, install_destination))
    vim.fn.system({
      "git",
      "clone",
      "--depth=1",
      plugin_url,
      install_destination,
    })
    if vim.v.shell_error > 0 then
      error(string.format("> Failed to clone plugin: '%s' in '%s'!", plugin_name, install_destination),
        vim.log.levels.ERROR)
    end
  end
end

---@alias PluginName string The plugin name, will be used as part of the git clone destination
---@alias PluginUrl string The git url at which a plugin is located, can be a path. See https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols for details
---@alias MinPlugins table<PluginName, PluginUrl>

---Do the initial setup. Downloads plugins, ensures the minimal init does not pollute the filesystem by keeping
---everything self contained to the CWD of the minimal init file. Run prior to running tests, reproducing issues, etc.
---@param plugins? table<PluginName, PluginUrl>
function M.setup(plugins)
  vim.opt.packpath = {}                      -- Empty the package path so we use only the plugins specified
  vim.opt.runtimepath:append(M.root(".min")) -- Ensure the runtime detects the root min dir

  -- Install required plugins
  if plugins ~= nil then
    for plugin_name, plugin_url in pairs(plugins) do
      M.load_plugin(plugin_name, plugin_url)
    end
  end

  vim.env.XDG_CONFIG_HOME = M.root("xdg/config")
  vim.env.XDG_DATA_HOME = M.root("xdg/data")
  vim.env.XDG_STATE_HOME = M.root("xdg/state")
  vim.env.XDG_CACHE_HOME = M.root("xdg/cache")

  -- NOTE: Cleanup the xdg cache on exit so new runs of the minimal init doesn't share any previous state, e.g. shada
  vim.api.nvim_create_autocmd("VimLeave", {
    callback = function()
      vim.fn.system({
        "rm",
        "-r",
        "-f",
        M.root("xdg")
      })
    end
  })
end

-- NOTE: If you have additional plugins you need to install to reproduce your issue, include them in the plugins
-- table within the setup call below.
M.setup({
  plenary = "https://github.com/nvim-lua/plenary.nvim.git",
  telescope = "https://github.com/nvim-telescope/telescope.nvim",
  diffview = "https://github.com/sindrets/diffview.nvim",
  neogit = "https://github.com/NeogitOrg/neogit"
})
-- WARN: Do all plugin setup, test runs, reproductions, etc. AFTER calling setup with a list of plugins!
-- Basically, do all that stuff AFTER this line.
require("neogit").setup({}) -- For instance, setup Neogit
paolomissagia commented 2 days ago

I think I am having the same issue here - that only happens on one of my repo as well.

I had a look on the code and I think the issue is coming from the name of the repository/folder open. Mine had a "%" symbol on it and after renaming the folder I was able to open Neogit without an issue.

Can you maybe try renaming it @LarssonMartin1998 ?

CKolkey commented 2 days ago

I'd be very curious if that's the issue, or if there's something else going on here.

LarssonMartin1998 commented 20 hours ago

I think I am having the same issue here - that only happens on one of my repo as well.

I had a look on the code and I think the issue is coming from the name of the repository/folder open. Mine had a "%" symbol on it and after renaming the folder I was able to open Neogit without an issue.

Can you maybe try renaming it @LarssonMartin1998 ?

I just tried renaming it and it didn't have an effect.

This was the original path to the root: /Users/martin.larsson/Projs/Repos/NameOfProject I also tried: /Users/martin.larsson/Projs/Repos/nop with the same issue.

This is an enterprise repo so I changed the name of the repo in this comment but it has the exact same spacing and capitalization.

Since this is an enterprise repo, it is on my work computer which has crowdstrike on it and the path is setup in CS to ignore some checks as to not impede our development (otherwise it drastically slows git and other things down). At first I thought that had something to do with it, but I moved the entire thing to ~/dev/git/nop and I still got the same issue

CKolkey commented 19 hours ago

Alright, could you grab some logs for me?

NEOGIT_LOG_LEVEL="debug" NEOGIT_LOG_FILE="true" NEOGIT_DEBUG=true nvim

the logfile probably lives at ~/.cache/nvim/neogit.log

LarssonMartin1998 commented 18 hours ago

Alright, could you grab some logs for me?

NEOGIT_LOG_LEVEL="debug" NEOGIT_LOG_FILE="true" NEOGIT_DEBUG=true nvim

the logfile probably lives at ~/.cache/nvim/neogit.log

Absolutely, here is the log:

[D 9.50.131] lib/state.lua:10               [STATE]: Reading file: '/Users/martin.larsson/.local/state/nvim/neogit/%Users%martin.larsson%Dev%git%nop'
[D 9.50.131] lib/state.lua:10               [STATE]: Loaded: '/Users/martin.larsson/.local/state/nvim/neogit/%Users%martin.larsson%Dev%git%nop'
[D 9.54.988] lib/git/repository.lua:188     [REPO]: Registered Repository for: /Users/martin.larsson/Dev/git/nop
[D 9.54.988] lib/git/repository.lua:200     [REPO]: Initializing Repository
[D 9.55.015] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "status", "--porcelain=2", "-b" }
[D 9.55.016] lib/git/repository.lua:235     [REPO]: Refreshed update_rebase_status in 0 ms
[D 9.55.017] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "log", "--format=ref_name%x1D%D%x1Fparent%x1D%P%x1Frel_date%x1D%cr%x1Fcommitter_date%x1D%cD%x1Fsanitized_subject_line%x1D%f%x1Fcommitter_name%x1D%cN%x1Ftree%x1D%T%x1Fcommit_notes%x1D%N%x1Fauthor_email%x1D%aE%x1Fabbreviated_parent%x1D%p%x1Fabbreviated_tree%x1D%t%x1Fsubject%x1D%s%x1Fabbreviated_commit%x1D%h%x1Fbody%x1D%b%x1Foid%x1D%H%x1Fcommitter_email%x1D%cE%x1Fauthor_date%x1D%aD%x1Fauthor_name%x1D%aN%x1Fencoding%x1D%e%x1E", "--no-patch", "--max-count=10" }
[D 9.55.018] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "rev-parse", "HEAD" }
[D 9.55.019] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "describe", "--long", "--tags", "HEAD" }
[D 9.55.019] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "status", "--porcelain=2", "-b" }
[D 9.55.020] lib/git/repository.lua:235     [REPO]: Refreshed update_bisect_information in 0 ms
[D 9.55.020] lib/git/repository.lua:235     [REPO]: Refreshed update_merge_status in 0 ms
[D 9.55.020] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "stash", "list" }
[D 9.55.020] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "status", "--porcelain=2", "-b" }
[D 9.55.021] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "status", "-z", "--porcelain=2" }
[D 9.55.021] buffers/status/init.lua:30     [STATUS] Registering instance for: /Users/martin.larsson/Dev/git/nop
[D 9.55.025] lib/buffer.lua:584             [BUFFER:8] Showing buffer in window 1006
[D 9.55.025] lib/buffer.lua:587             [BUFFER:8] Setting buffer options
[D 9.55.025] lib/buffer.lua:599             [BUFFER:8] Setting filetype: NeogitStatus
[D 9.55.029] lib/buffer.lua:604             [BUFFER:8] Building user key-mappings
[D 9.55.030] lib/buffer.lua:613             [BUFFER:8] Setting key-mappings
[D 9.55.030] lib/buffer.lua:634             [BUFFER:8] Initializing buffer
[D 9.55.031] lib/buffer.lua:639             [BUFFER:8] Setting window options
[D 9.55.031] lib/buffer.lua:663             [BUFFER:8] Rendering buffer
[D 9.55.032] lib/buffer.lua:668             [BUFFER:8] Setting autocmd for: FocusGained
[D 9.55.032] lib/buffer.lua:677             [BUFFER:8] Setting user autocmd for: NeogitRebase
[D 9.55.032] lib/buffer.lua:677             [BUFFER:8] Setting user autocmd for: NeogitFetchComplete
[D 9.55.033] lib/buffer.lua:677             [BUFFER:8] Setting user autocmd for: NeogitPullComplete
[D 9.55.033] lib/buffer.lua:677             [BUFFER:8] Setting user autocmd for: NeogitPushComplete
[D 9.55.033] lib/buffer.lua:677             [BUFFER:8] Setting user autocmd for: NeogitStash
[D 9.55.033] lib/buffer.lua:677             [BUFFER:8] Setting user autocmd for: NeogitReset
[D 9.55.033] lib/buffer.lua:677             [BUFFER:8] Setting user autocmd for: NeogitMerge
[D 9.55.033] lib/buffer.lua:695             [BUFFER:8] Running config.after callback
[D 9.55.033] watcher.lua:72                 [WATCHER] Watching git dir: /Users/martin.larsson/Dev/git/nop/.git
[D 9.55.033] lib/buffer.lua:702             [BUFFER:8] Setting up on_detach callback
[D 9.55.033] lib/buffer.lua:712             [BUFFER:8] Setting up context highlighting
[D 9.55.033] lib/buffer.lua:753             [BUFFER:8] Setting up foldmarkers
[D 9.55.033] lib/buffer.lua:794             [BUFFER:8] Setting CWD to: /Users/martin.larsson/Dev/git/nop
[D 9.55.033] buffers/status/init.lua:261    [STATUS] Beginning refresh from UNKNOWN
[D 9.55.034] lib/git/repository.lua:243     [REPO] Callback registered
[D 9.55.034] lib/git/repository.lua:266     [REPO] Already running - abort
[D 9.55.075] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "log", "--format=ref_name%x1D%D%x1Fparent%x1D%P%x1Frel_date%x1D%cr%x1Fcommitter_date%x1D%cD%x1Fsanitized_subject_line%x1D%f%x1Fcommitter_name%x1D%cN%x1Ftree%x1D%T%x1Fcommit_notes%x1D%N%x1Fauthor_email%x1D%aE%x1Fabbreviated_parent%x1D%p%x1Fabbreviated_tree%x1D%t%x1Fsubject%x1D%s%x1Fabbreviated_commit%x1D%h%x1Fbody%x1D%b%x1Foid%x1D%H%x1Fcommitter_email%x1D%cE%x1Fauthor_date%x1D%aD%x1Fauthor_name%x1D%aN%x1Fencoding%x1D%e%x1E", "--no-patch", "HEAD", "--max-count=1", "--topo-order" }
[D 9.55.099] lib/git/repository.lua:235     [REPO]: Refreshed update_stashes in 79 ms
[D 9.55.371] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "remote" }
[D 9.55.390] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "rev-parse", "release/6.48.2" }
[D 9.55.393] lib/git/repository.lua:235     [REPO]: Refreshed update_recent in 376 ms
[D 9.55.406] lib/git/repository.lua:235     [REPO]: Refreshed update_tags in 388 ms
[D 9.55.880] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "log", "--format=%x1E%H%x00", "--graph", "--color", "HEAD", "--max-count=1", "--topo-order" }
[D 9.56.418] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "log", "--max-count=1", "--format=%s", "5d0c0ebacf5cd237e598f50261b45212ea5171ee" }
[D 9.56.433] lib/git/repository.lua:235     [REPO]: Refreshed update_sequencer_status in 1415 ms
[D 9.57.016] lib/buffer.lua:587             [BUFFER:9] Setting buffer options
[D 9.57.016] lib/buffer.lua:599             [BUFFER:9] Setting filetype: NeogitConsole
[D 9.57.020] lib/buffer.lua:613             [BUFFER:9] Setting key-mappings
[D 9.57.020] lib/buffer.lua:668             [BUFFER:9] Setting autocmd for: WinLeave
[D 9.57.020] lib/buffer.lua:702             [BUFFER:9] Setting up on_detach callback
[D 9.57.024] lib/buffer.lua:587             [BUFFER:9] Setting buffer options
[D 9.57.025] lib/buffer.lua:599             [BUFFER:9] Setting filetype: NeogitConsole
[D 9.57.028] lib/buffer.lua:613             [BUFFER:9] Setting key-mappings
[D 9.57.028] lib/buffer.lua:668             [BUFFER:9] Setting autocmd for: WinLeave
[D 9.57.028] lib/buffer.lua:702             [BUFFER:9] Setting up on_detach callback
[D 9.57.028] lib/buffer.lua:587             [BUFFER:9] Setting buffer options
[D 9.57.028] lib/buffer.lua:599             [BUFFER:9] Setting filetype: NeogitConsole
[D 9.57.031] lib/buffer.lua:613             [BUFFER:9] Setting key-mappings
[D 9.57.031] lib/buffer.lua:668             [BUFFER:9] Setting autocmd for: WinLeave
[D 9.57.031] lib/buffer.lua:702             [BUFFER:9] Setting up on_detach callback
[D 9.57.032] lib/buffer.lua:587             [BUFFER:9] Setting buffer options
[D 9.57.032] lib/buffer.lua:599             [BUFFER:9] Setting filetype: NeogitConsole
[D 9.57.034] lib/buffer.lua:613             [BUFFER:9] Setting key-mappings
[D 9.57.034] lib/buffer.lua:668             [BUFFER:9] Setting autocmd for: WinLeave
[D 9.57.034] lib/buffer.lua:702             [BUFFER:9] Setting up on_detach callback
[D 9.57.904] lib/buffer.lua:688             [BUFFER:8] Clearing autocmd group
[D 9.57.904] lib/buffer.lua:705             [BUFFER:8] Running on_detach
[D 9.57.904] watcher.lua:84                 [WATCHER] Stopped watching git dir: /Users/martin.larsson/Dev/git/nop/.git
[D 9.79.708] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "branch", "--show-current" }
[D 9.79.710] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "rev-parse", "--short", "5d0c0ebacf5cd237e598f50261b45212ea5171ee" }
[D 9.79.712] lib/git/repository.lua:235     [REPO]: Refreshed update_status in 24690 ms
[D 9.79.712] lib/git/config.lua:102         [Config] Rebuilding git config_cache
[D 9.79.713] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "config", "--list", "--null", "--local" }
[D 9.79.722] lib/git/cli.lua:1056           Running command async failed - awaiting instead
[D 9.79.733] lib/git/repository.lua:235     [REPO]: Refreshed update_unpulled in 24714 ms
[D 9.79.734] lib/git/repository.lua:235     [REPO]: Refreshed update_unmerged in 24713 ms
[D 9.79.734] lib/git/cli.lua:1053           Running command async: { "git", "--no-pager", "--literal-pathspecs", "--no-optional-locks", "-c", "core.preloadindex=true", "-c", "color.ui=always", "log", "--max-count=1", "--format=%s", "5d0c0ebacf5cd237e598f50261b45212ea5171ee" }
[D 9.79.746] lib/git/repository.lua:235     [REPO]: Refreshed update_branch_information in 24731 ms
[D 9.79.746] lib/git/repository.lua:287     [REPO]: Refreshes complete in 24731 ms
[D 9.79.746] lib/git/repository.lua:249     [REPO]: Running refresh callback (1)
[D 9.79.746] buffers/status/init.lua:288    [STATUS] Rendering UI