Skip to content

Gitsigns stops working after :Gitsigns show in a git submodule #1095

@Iskustvo

Description

@Iskustvo

Description

When inside of remote git submodule (couldn't reproduce the issue with local repository), it seems that Gitsigns is unable to properly attach to older snapshots of a file and therefore every following Gitsigns command is a no-op.

Neovim version

NVIM v0.10.0

Operating system and version

Arch Linux (x86_64) Kernel: 6.9.9-arch1-1

Expected behavior

After using Gitsigns show HEAD on a file in git submodule, I expect that following commands (be it blame, blame_line, diffthis, ...) continue working in showed file.

Actual behavior

None of the following command does anything at this point.

Minimal config

for name, url in pairs{
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim'
} 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
}

Steps to reproduce

  1. Create testing environment.
    mkdir gitsigns_test
    cd gitsigns_test
    git init
    git submodule add https://github.com/lewis6991/gitsigns.nvim.git
    git commit -m "initial commit"
  2. Open any file from gitsigns subrepository with minimal Neovim config.
    nvim --clean -u minimal.lua gitsigns.nvim/lua/gitsigns.lua
  3. Confirm that Gitsigns is currently working (e.g. by running blame_line command).
    :Gitsigns blame_line
  4. Show any (e.g. HEAD) snapshot of the opened file.
    :Gitsigns show HEAD
  5. Notice that Gitsigns commands (e.g. blame_line) no longer work.
    :Gitsigns blame_line

Gitsigns debug messages

0.52 D dprintf: Deriving GitSignsAdd from Added
0.59 D derive: Deriving GitSignsChange from Changed
0.63 D derive: Deriving GitSignsDelete from Removed
0.67 D derive: Deriving GitSignsChangedelete from GitSignsChange
0.71 D derive: Deriving GitSignsTopdelete from GitSignsDelete
0.76 D derive: Deriving GitSignsUntracked from GitSignsAdd
0.79 D derive: Deriving GitSignsAddNr from GitSignsAdd
0.81 D derive: Deriving GitSignsChangeNr from GitSignsChange
0.85 D derive: Deriving GitSignsDeleteNr from GitSignsDelete
0.87 D derive: Deriving GitSignsChangedeleteNr from GitSignsChangeNr
0.91 D derive: Deriving GitSignsTopdeleteNr from GitSignsDeleteNr
0.95 D derive: Deriving GitSignsUntrackedNr from GitSignsAddNr
0.98 D derive: Deriving GitSignsAddLn from DiffAdd
0.99 D derive: Deriving GitSignsChangeLn from DiffChange
1.02 D derive: Deriving GitSignsChangedeleteLn from GitSignsChangeLn
1.03 D derive: Deriving GitSignsUntrackedLn from GitSignsAddLn
1.05 D derive: Deriving GitSignsStagedAdd from GitSignsAdd
1.06 D derive: Deriving GitSignsStagedChange from GitSignsChange
1.08 D derive: Deriving GitSignsStagedDelete from GitSignsDelete
1.09 D derive: Deriving GitSignsStagedChangedelete from GitSignsChangedelete
1.12 D derive: Deriving GitSignsStagedTopdelete from GitSignsTopdelete
1.13 D derive: Deriving GitSignsStagedAddNr from GitSignsAddNr
1.15 D derive: Deriving GitSignsStagedChangeNr from GitSignsChangeNr
1.16 D derive: Deriving GitSignsStagedDeleteNr from GitSignsDeleteNr
1.19 D derive: Deriving GitSignsStagedChangedeleteNr from GitSignsChangedeleteNr
1.21 D derive: Deriving GitSignsStagedTopdeleteNr from GitSignsTopdeleteNr
1.22 D derive: Deriving GitSignsStagedAddLn from GitSignsAddLn
1.24 D derive: Deriving GitSignsStagedChangeLn from GitSignsChangeLn
1.25 D derive: Could not derive GitSignsStagedDeleteLn
1.26 D derive: Deriving GitSignsStagedChangedeleteLn from GitSignsChangedeleteLn
1.27 D derive: Could not derive GitSignsStagedTopdeleteLn
1.29 D derive: Deriving GitSignsAddPreview from DiffAdd
1.31 D derive: Deriving GitSignsDeletePreview from DiffDelete
1.33 D derive: Deriving GitSignsCurrentLineBlame from NonText
1.35 D derive: Deriving GitSignsAddInline from TermCursor
1.36 D derive: Deriving GitSignsDeleteInline from TermCursor
1.38 D derive: Deriving GitSignsChangeInline from TermCursor
1.39 D derive: Deriving GitSignsAddLnInline from GitSignsAddInline
1.40 D derive: Deriving GitSignsChangeLnInline from GitSignsChangeInline
1.42 D derive: Deriving GitSignsDeleteLnInline from GitSignsDeleteInline
1.43 D derive: Deriving GitSignsDeleteVirtLn from DiffDelete
1.45 D derive: Deriving GitSignsDeleteVirtLnInLine from GitSignsDeleteLnInline
1.46 D derive: Deriving GitSignsVirtLnum from GitSignsDeleteVirtLn
5.31 D attach(1): Attaching (trigger=BufReadPost)
5.41 D run_job: git --version
21.53 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
22.97 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns_test/.git/modules/gitsigns.nvim --work-tree /tmp/gitsigns_test/gitsigns.nvim config user.name
24.10 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns_test/.git/modules/gitsigns.nvim --work-tree /tmp/gitsigns_test/gitsigns.nvim -c core.quotepath=off ls-files --stage --others --excl
ude-standard --eol /tmp/gitsigns_test/gitsigns.nvim/lua/gitsigns.lua
25.75 D watch_gitdir(1): Watching git dir
25.87 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns_test/.git/modules/gitsigns.nvim --work-tree /tmp/gitsigns_test/gitsigns.nvim show 87367e7f30e90ca70596b65a56864857fbd037c6
29.04 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns_test/.git/modules/gitsigns.nvim --work-tree /tmp/gitsigns_test/gitsigns.nvim show HEAD:lua/gitsigns.lua
100.20 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
9570.05 D cli.run: Running action 'blame_line' with arguments {}
9570.56 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns_test/.git/modules/gitsigns.nvim --work-tree /tmp/gitsigns_test/gitsigns.nvim blame --contents - --incremental -- /tmp/gitsigns_te
st/gitsigns.nvim/lua/gitsigns.lua
26614.88 D cli.run: Running action 'blame_line' with arguments {}
29132.84 D cli.run: Running action 'show' with arguments { "HEAD" }
29133.15 D show(4): Detached
29133.15 D show(4): Cache was nil
29133.19 D attach(4): Attaching (trigger=BufFilePost)
29133.25 D show(4): Gitsigns buffer for file '/tmp/gitsigns_test/lua/gitsigns.lua' from path 'gitsigns:///tmp/gitsigns_test/.git/modules/gitsigns.nvim/HEAD:lua/gitsigns.lua' on commit 'modules/gitsigns.nvim/HEAD'
29133.29 D attach(4): Non-normal buffer
29133.46 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /tmp/gitsigns_test/.git/modules/gitsigns.nvim --work-tree /tmp/gitsigns_test/gitsigns.nvim show HEAD:lua/gitsigns.lua
29138.48 D attach(4): Attaching (trigger=BufReadCmd)
29138.52 D show(4): Gitsigns buffer for file '/tmp/gitsigns_test/lua/gitsigns.lua' from path 'gitsigns:///tmp/gitsigns_test/.git/modules/gitsigns.nvim/HEAD:lua/gitsigns.lua' on commit 'modules/gitsigns.nvim/HEAD'
29138.55 D attach(4): Non-normal buffer
29138.58 D show(1): bufname gitsigns:///tmp/gitsigns_test/.git/modules/gitsigns.nvim/HEAD:lua/gitsigns.lua
60041.73 D cli.run: Running action 'blame_line' with arguments {}

Gitsigns cache

{ {
    blame = { "...",
      length = 244
    },
    bufnr = 1,
    compare_text = { "...",
      head = "local async = require('gitsigns.async')",
      length = 245
    },
    compare_text_head = { "...",
      head = "local async = require('gitsigns.async')",
      length = 245
    },
    file = "/tmp/gitsigns_test/gitsigns.nvim/lua/gitsigns.lua",
    force_next_update = false,
    git_obj = {
      encoding = "utf-8",
      file = "/tmp/gitsigns_test/gitsigns.nvim/lua/gitsigns.lua",
      i_crlf = false,
      mode_bits = "100644",
      object_name = "87367e7f30e90ca70596b65a56864857fbd037c6",
      relpath = "lua/gitsigns.lua",
      repo = {
        abbrev_head = "main",
        detached = true,
        gitdir = "/tmp/gitsigns_test/.git/modules/gitsigns.nvim",
        toplevel = "/tmp/gitsigns_test/gitsigns.nvim",
        username = "Iskustvo"
      },
      w_crlf = false
    },
    gitdir_watcher = <userdata 1>,
    hunks = { "...",
      length = 0
    },
    hunks_staged = { "...",
      length = 0
    },
    staged_diffs = { "...",
      length = 0
    }
  } }

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