Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
matu3ba opened this issue Jun 7, 2023 · 4 comments · Fixed by #815
Closed

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

matu3ba opened this issue Jun 7, 2023 · 4 comments · Fixed by #815
Labels
bug Something isn't working

Comments

@matu3ba
Copy link

matu3ba commented Jun 7, 2023

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.

@matu3ba matu3ba added the bug Something isn't working label Jun 7, 2023
lewis6991 added a commit that referenced this issue Jun 14, 2023
@lewis6991
Copy link
Owner

Can you check if #815 fixes this?

lewis6991 added a commit that referenced this issue Jun 14, 2023
@matu3ba
Copy link
Author

matu3ba commented Jun 14, 2023

Was fixed, thanks alot. Now I can only get it showing an expected error, if I open the same branch in two windows.

@lewis6991
Copy link
Owner

lewis6991 commented Jun 14, 2023

Which error is that? If you open the same branch it should just reuse the same buffer.

@matu3ba
Copy link
Author

matu3ba commented Jun 14, 2023

My bad. I should have run :Lazy sync. It works now flawlessly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants