lewis6991 / gitsigns.nvim

Git integration for buffers
MIT License
4.86k stars 186 forks source link

`blame_line({ full = true })` shows all lines in file being added instead of just the hunk #1065

Closed heygarrett closed 2 months ago

heygarrett commented 2 months ago

Description

Using require("gitsigns").blame_line({ full = true }) shows all lines in the file being added instead of just the changes in the commit. Here's a screenshot of the floating window next to the output of git show for the same commit:
CleanShot 2024-06-21 at 13 39 27@2x

Neovim version

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1716656478
Run "nvim -V1 -v" for more info

Operating system and version

macOS 14.5 (23F79)

Expected behavior

Only the changes in the commit for the blamed line would be displayed in the floating window.

Actual behavior

The floating window shows the changes as all lines in the file being added.

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. mkdir gitsigns_issue
  2. cd gitsigns_issue
  3. git init
  4. echo 'first line' >> example.txt
  5. git add example.txt
  6. git commit -m 'initial commit'
  7. echo 'second line' >> example.txt
  8. git commit -am 'second commit'
  9. nvim --clean -u minimal.lua example.txt
  10. j (go to second line)
  11. :lua require('gitsigns').blame_line({ full = true })

Gitsigns debug messages

1.18 D dprintf: Deriving GitSignsAdd from Added
1.40 D derive: Deriving GitSignsChange from Changed
1.61 D derive: Deriving GitSignsDelete from Removed
1.69 D derive: Deriving GitSignsChangedelete from GitSignsChange
1.74 D derive: Deriving GitSignsTopdelete from GitSignsDelete
1.81 D derive: Deriving GitSignsUntracked from GitSignsAdd
1.89 D derive: Deriving GitSignsAddNr from GitSignsAdd
1.97 D derive: Deriving GitSignsChangeNr from GitSignsChange
2.07 D derive: Deriving GitSignsDeleteNr from GitSignsDelete
2.12 D derive: Deriving GitSignsChangedeleteNr from GitSignsChangeNr
2.19 D derive: Deriving GitSignsTopdeleteNr from GitSignsDeleteNr
2.24 D derive: Deriving GitSignsUntrackedNr from GitSignsAddNr
2.35 D derive: Deriving GitSignsAddLn from DiffAdd
2.47 D derive: Deriving GitSignsChangeLn from DiffChange
2.52 D derive: Deriving GitSignsChangedeleteLn from GitSignsChangeLn
2.56 D derive: Deriving GitSignsUntrackedLn from GitSignsAddLn
2.61 D derive: Deriving GitSignsStagedAdd from GitSignsAdd
2.65 D derive: Deriving GitSignsStagedChange from GitSignsChange
2.70 D derive: Deriving GitSignsStagedDelete from GitSignsDelete
2.75 D derive: Deriving GitSignsStagedChangedelete from GitSignsChangedelete
2.79 D derive: Deriving GitSignsStagedTopdelete from GitSignsTopdelete
2.84 D derive: Deriving GitSignsStagedAddNr from GitSignsAddNr
2.88 D derive: Deriving GitSignsStagedChangeNr from GitSignsChangeNr
2.94 D derive: Deriving GitSignsStagedDeleteNr from GitSignsDeleteNr
3.23 D derive: Deriving GitSignsStagedChangedeleteNr from GitSignsChangedeleteNr
3.31 D derive: Deriving GitSignsStagedTopdeleteNr from GitSignsTopdeleteNr
3.40 D derive: Deriving GitSignsStagedAddLn from GitSignsAddLn
3.44 D derive: Deriving GitSignsStagedChangeLn from GitSignsChangeLn
3.56 D derive: Could not derive GitSignsStagedDeleteLn
3.60 D derive: Deriving GitSignsStagedChangedeleteLn from GitSignsChangedeleteLn
3.68 D derive: Could not derive GitSignsStagedTopdeleteLn
3.79 D derive: Deriving GitSignsAddPreview from DiffAdd
3.91 D derive: Deriving GitSignsDeletePreview from DiffDelete
3.97 D derive: Deriving GitSignsCurrentLineBlame from NonText
4.01 D derive: Deriving GitSignsAddInline from TermCursor
4.06 D derive: Deriving GitSignsDeleteInline from TermCursor
4.10 D derive: Deriving GitSignsChangeInline from TermCursor
4.14 D derive: Deriving GitSignsAddLnInline from GitSignsAddInline
4.23 D derive: Deriving GitSignsChangeLnInline from GitSignsChangeInline
4.28 D derive: Deriving GitSignsDeleteLnInline from GitSignsDeleteInline
4.39 D derive: Deriving GitSignsDeleteVirtLn from DiffDelete
4.43 D derive: Deriving GitSignsDeleteVirtLnInLine from GitSignsDeleteLnInline
4.48 D derive: Deriving GitSignsVirtLnum from GitSignsDeleteVirtLn
14.49 D attach(1): Attaching (trigger=BufReadPost)
14.61 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 config user.name
20.85 D run_job: git --version
29.48 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --ab
solute-git-dir --abbrev-ref HEAD
36.68 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /Users/garrett/dev/s
crap/gitsigns_issue/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol /Users/garrett/de
v/scrap/gitsigns_issue/example.txt
56.50 D watch_gitdir(1): Watching git dir
56.84 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /Users/garrett/dev/s
crap/gitsigns_issue/.git show 06fcdd77c9348567c50638b30d406500f521c304
63.52 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /Users/garrett/dev/s
crap/gitsigns_issue/.git show HEAD:example.txt
16853.05 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /Users/garrett/de
v/scrap/gitsigns_issue/.git blame --contents - --incremental -- /Users/garrett/dev/scrap/gitsigns_issue/example.txt
16873.25 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /Users/garrett/de
v/scrap/gitsigns_issue/.git show -s --format=%B 8eac01b6022d51e1023971b85af483aad7922b8e
16884.55 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /Users/garrett/de
v/scrap/gitsigns_issue/.git show 8eac01b6022d51e1023971b85af483aad7922b8e:example.txt
25298.61 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /Users/garrett/de
v/scrap/gitsigns_issue/.git show -s --format=%B 3a73a5a2ab5e4c4966a9973f9283fd151fe63b58
25318.89 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /Users/garrett/de
v/scrap/gitsigns_issue/.git show 3a73a5a2ab5e4c4966a9973f9283fd151fe63b58:example.txt
196431.56 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /Users/garrett/d
ev/scrap/gitsigns_issue/.git show -s --format=%B 3a73a5a2ab5e4c4966a9973f9283fd151fe63b58
196449.08 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /Users/garrett/d
ev/scrap/gitsigns_issue/.git show 3a73a5a2ab5e4c4966a9973f9283fd151fe63b58:example.txt
202774.44 D cli.run: Running action 'debug_messages' with arguments {}
215360.47 D cli.run: Running action 'debug_messages' with arguments {}

### Gitsigns cache

```lua
{ {
    blame = { "...",
      length = 2
    },
    bufnr = 1,
    compare_text = { "...",
      head = "first line",
      length = 3
    },
    compare_text_head = { "...",
      head = "first line",
      length = 3
    },
    file = "/Users/garrett/dev/scrap/gitsigns_issue/example.txt",
    force_next_update = false,
    git_obj = {
      encoding = "utf-8",
      file = "/Users/garrett/dev/scrap/gitsigns_issue/example.txt",
      i_crlf = false,
      mode_bits = "100644",
      object_name = "06fcdd77c9348567c50638b30d406500f521c304",
      relpath = "example.txt",
      repo = {
        abbrev_head = "main",
        detached = false,
        gitdir = "/Users/garrett/dev/scrap/gitsigns_issue/.git",
        toplevel = "/Users/garrett/dev/scrap/gitsigns_issue",
        username = "Garrett Oreilly"
      },
      w_crlf = false
    },
    gitdir_watcher = <userdata 1>,
    hunks = { "...",
      length = 0
    },
    hunks_staged = { "...",
      length = 0
    },
    staged_diffs = { "...",
      length = 0
    }
  } }
Ask-786 commented 2 months ago

Having the same issue :(

renxzen commented 2 months ago

anyone facing this, locking to version 0.9.0 might help you with lazy.nvim

{
    "lewis6991/gitsigns.nvim",
    version = "0.9.0",
    config = true,
}