Skip to content

New buffer created from saveas is attached to the old file #1021

@przepompownia

Description

@przepompownia

Description

Nothing more than in the title.

Neovim version

v0.11.0-dev-76+g8db9a0e5a

Operating system and version

Debian Sid

Expected behavior

No response

Actual behavior

Using gitsigns on the new file affects (only) the old one.

Minimal config

for name, url in pairs{
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
  -- ADD OTHER PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE
} 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. Prepare some already versioned oldfile
  2. nvim --clean -u minimal.luaoldfile`
  3. execute :saveas newfile inside
  4. add some changes to newfile
  5. run :Gitsigns stage_buffer there
  6. quit Neovim and see output from git diff and git diff --cached. For me only oldfile is shown.

Gitsigns debug messages

(from attach):

attach(1): Attaching (trigger=setup)
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 config user.name
run_job: git --version
run_job: git --version
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir .../2024-05-24-14.03.21-gitsigns-saveas/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol .../2024-05-24-14.03.21-gitsigns-saveas/oldfile
watch_gitdir(1): Watching git dir
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir .../2024-05-24-14.03.21-gitsigns-saveas/.git show e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
cli.run: Running action 'debug_messages' with arguments {}
cli.run: Running action 'debug_messages' with arguments {}
attach(1): Already attached
cli.run: Running action 'stage_buffer' with arguments {}
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir .../2024-05-24-14.03.21-gitsigns-saveas/.git apply --whitespace=nowarn --cached --unidiff-zero -
watcher_cb(1): Git dir update: 'index.lock' { rename = true } (ignoring)
watcher_cb(1): Git dir update: 'index.lock' { change = true } (ignoring)
watcher_cb(1): Git dir update: 'index.lock' { rename = true } (ignoring)
watcher_cb(1): Git dir update: 'index' { rename = true }
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir .../2024-05-24-14.03.21-gitsigns-saveas/.git show e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir .../2024-05-24-14.03.21-gitsigns-saveas/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol .../2024-05-24-14.03.21-gitsigns-saveas/oldfile
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir .../2024-05-24-14.03.21-gitsigns-saveas/.git show 1a09f84cdecb5aec927ac553af7161376c35465f
cli.run: Running action 'debug_messages' with arguments {}

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