Skip to content

:Gitsigns show upstream/master fails with message that buffer already is opened #808

@matu3ba

Description

@matu3ba

Description

Can not open previously opened buffer to show upstream master version of file.

Neovim version

NVIM v0.10.0-dev-472+g0370e4def

Operating system and version

Linux pc 6.3.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 30 May 2023 13:44:01 +0000 x86_64 GNU/Linux

Expected behavior

If the buffer already exists, gitsigns should find it and open it without error message.

Actual behavior

:Gitsigns show upstream/master
Error executing Lua callback: ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:105: The coroutine failed with this message: .../share/nvim/lazy/gitsigns.nvim/lua/gitsigns/diffthis.lua:83: Vim:E95: Ein Puffer mit diesem Namen exis
tiert bereits
stack traceback:
        [C]: in function 'nvim_buf_set_name'
        .../share/nvim/lazy/gitsigns.nvim/lua/gitsigns/diffthis.lua:83: in function 'run'
        .../share/nvim/lazy/gitsigns.nvim/lua/gitsigns/diffthis.lua:157: in function 'show'
        ...l/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/actions.lua:1113: in function 'f'
        ...local/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/cli.lua:101: in function <...local/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/cli.lua:73>
stack traceback:
        [C]: in function 'error'
        ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:105: in function 'step'
        ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:129: in function 'run'
        ...on/.local/share/nvim/lazy/gitsigns.nvim/lua/gitsigns.lua:101: in function <...on/.local/share/nvim/lazy/gitsigns.nvim/lua/gitsigns.lua:100>

Translation: Vim:E95 A buffer with this name already exists.

Minimal config

vim.o.packpath = '/tmp/nvim/site'

local plugins = {
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
  -- ADD OTHER PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE
}

for name, url in pairs(plugins) do
  local install_path = '/tmp/nvim/site/pack/test/start/'..name
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
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. Setup worktree with fish:
  function makeWorkTree -d "create worktree into cwd from https url with ending .git"
    if test (count $argv) -eq 1
      set worktreesfolder (basename -s .git "$argv[1]")
      echo "$worktreesfolder"
      mkdir "$worktreesfolder"
      cd "$worktreesfolder"
      git clone --bare "$argv[1]" .bare
      # make sure git knows where the gitdir is
      echo "gitdir: ./.bare" > .git
      git worktree add master
    else
      echo "invalid argument number"
    end
  end
  makeWorkTree https://github.com/ziglang/zig
  1. Have a gitconfig, which fetches all branches (for convenience):
[core]
	repositoryformatversion = 0
	filemode = true
	bare = true
[remote "upstream"]
	url = https://github.com/ziglang/zig.git
	fetch = +refs/heads/*:refs/remotes/upstream/*
	fetch = +refs/pull/*/head:refs/remotes/upstream/pr/*
	gh-resolved = base
  1. git remote rename origin downstream
  2. git fetch
  3. nvim --clean -u minimal.lua
  4. :Gitsign show upstream/master
  5. Escape or do another cancellation quickly
  6. Try :Gitsign show upstream/master again and get aforementioned error message.

Gitsigns debug messages

There should be no debug messages necessary.

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