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

Unable to blame_line in earlier snapshots of a file #1044

Closed
Iskustvo opened this issue Jun 15, 2024 · 4 comments
Closed

Unable to blame_line in earlier snapshots of a file #1044

Iskustvo opened this issue Jun 15, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@Iskustvo
Copy link

Iskustvo commented Jun 15, 2024

Description

After using Gitsigns show ... to open specific snapshot of a file, Gitsigns blame_line doesn't work correctly on that snapshot. It often just pops up Not Committed Yet window, instead of actually blaming the line.

Neovim version

NVIM v0.10.0

Operating system and version

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

Expected behavior

Gitsigns blame_line actually blames lines in older file snapshots.

Actual behavior

For some lines (both changed and unchanged by current snapshot), it just shows Not Committed Yet window, instead of actual commit.

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
echo -e "aaa\nbbb\nccc" > file
git add file
git commit -m "add 3 lines"
echo -e "aaaa\nbbbb\nccc" > file
git commit -am "modify first two lines"
echo -e "aaaa\nbbbbb\ncccc" > file
git commit -am "modify last two lines"
  1. Open test file with minimal Neovim config
nvim --clean -u minimal.lua file
  1. Show file snapshot of parent commit (modify first two lines)
:Gitsigns show HEAD^
  1. Observe correctly drawn "signs" on first two lines, indicating that this commit really changed the first two lines.
  2. Blame the first line (aaaa) in order to see who introduced it.
:Gitsigns blame_line
  1. Observe correct popup window claiming that commit modify first two lines introduced it.
  2. Navigate to second line (bbbb) which was introduced by the same modify first two lines commit.
  3. Blame the second line (bbbb) in order to see who introduced it.
:Gitsigns blame_line
  1. Observe incorrect Not Committed Yet popup, instead of modify first two lines.
  2. Navigate to third line (ccc) which wasn't modified by this commit.
  3. Blame the third line in order to see who introduced it.
:Gitsigns blame_line
  1. Observe incorrect Not Committed Yet popup, instead of initial commit add 3 lines.

Gitsigns debug messages

No response

@Iskustvo Iskustvo added the bug Something isn't working label Jun 15, 2024
@Iskustvo
Copy link
Author

Iskustvo commented Jul 13, 2024

Hey @lewis6991, I just retested this with latest changes and there is another issue on step 3., basically, just executing

:Gitsigns show HEAD^

echos the following error:

Error executing vim.schedule lua callback: ...gns_test/gitsigns_issue/gitsigns//lua/gitsigns/async.lua:92: attempt to call upvalue 'callback' (a table value)
stack traceback:
        ...gns_test/gitsigns_issue/gitsigns//lua/gitsigns/async.lua:92: in function 'cb'
        ...gns_test/gitsigns_issue/gitsigns//lua/gitsigns/async.lua:127: in function <...gns_test/gitsigns_issue/gitsigns//lua/gitsigns/async.lua:126>

Strangely enough, despite the error, everything works as expected in all later steps.
Would you prefer that I close this issue (since it's now solved) and open another one for this error or should I just wait and close this once the show error is fixed?

@lewis6991
Copy link
Owner

Up to you.

@lewis6991
Copy link
Owner

Fixed in d9f997d

@Iskustvo
Copy link
Author

Retested, everything works, thanks a lot!

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
Development

No branches or pull requests

2 participants