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

Error when opening a file revision with blame enabled #1093

Closed
stv17 opened this issue Jul 20, 2024 · 6 comments · Fixed by #1177 · May be fixed by #1040
Closed

Error when opening a file revision with blame enabled #1093

stv17 opened this issue Jul 20, 2024 · 6 comments · Fixed by #1177 · May be fixed by #1040
Labels
bug Something isn't working

Comments

@stv17
Copy link

stv17 commented Jul 20, 2024

Description

First of all, thanks for your work on this plugin. I mostly use it for signs but I appreciate the new features and hope it continues to evolve. This is my first issue report.

When viewing the revision of a file (like with :Gedit @^:% from vim-fugitive or :Gitsigns show @^ if you have option current_line_blame enabled then an error pops up. I think this started happening not long ago, but I can't say which version of gitsigns I was using at the time.

Do note that the option in question is given disabled by the README config.

Neovim version

NVIM v0.10.1-dev-55+g9c6efd0a6

Operating system and version

Debian stable (Bookworm)

Expected behavior

From the README comment on integration with fugitive I take the revision should show the signs relative to it's parent (as I think it always did).

Actual behavior

This error pops up:
image

The --contents flag is probably added by file "lua/gitsigns/git/blame.lua".

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,
    current_line_blame = true,
})

vim.opt.relativenumber = true

Steps to reproduce

A simple setup:

mkdir gitsigns_issue
touch minimal.lua
# -> copy the minimal config from above into the file
git init .
git add minimal.lua
git commit -m "first"
echo "-- a change" >> minimal.lua
git add minimal.lua
git commit -m "second"
nvim --clean -u minimal.lua minimal.lua

And now in neovim do :Gitsigns show @

Gitsigns debug messages

0.45 D dprintf: Deriving GitSignsAdd from Added
0.48 D derive: Deriving GitSignsChange from Changed
0.53 D derive: Deriving GitSignsDelete from Removed
0.57 D derive: Deriving GitSignsChangedelete from GitSignsChange
0.61 D derive: Deriving GitSignsTopdelete from GitSignsDelete
0.65 D derive: Deriving GitSignsUntracked from GitSignsAdd
0.68 D derive: Deriving GitSignsAddNr from GitSignsAdd
0.70 D derive: Deriving GitSignsChangeNr from GitSignsChange
0.75 D derive: Deriving GitSignsDeleteNr from GitSignsDelete
0.80 D derive: Deriving GitSignsChangedeleteNr from GitSignsChangeNr
0.83 D derive: Deriving GitSignsTopdeleteNr from GitSignsDeleteNr
0.85 D derive: Deriving GitSignsUntrackedNr from GitSignsAddNr
0.88 D derive: Deriving GitSignsAddLn from DiffAdd
0.90 D derive: Deriving GitSignsChangeLn from DiffChange
0.92 D derive: Deriving GitSignsChangedeleteLn from GitSignsChangeLn
0.94 D derive: Deriving GitSignsUntrackedLn from GitSignsAddLn
0.95 D derive: Deriving GitSignsStagedAdd from GitSignsAdd
0.97 D derive: Deriving GitSignsStagedChange from GitSignsChange
0.99 D derive: Deriving GitSignsStagedDelete from GitSignsDelete
1.01 D derive: Deriving GitSignsStagedChangedelete from GitSignsChangedelete
1.02 D derive: Deriving GitSignsStagedTopdelete from GitSignsTopdelete
1.04 D derive: Deriving GitSignsStagedAddNr from GitSignsAddNr
1.07 D derive: Deriving GitSignsStagedChangeNr from GitSignsChangeNr
1.09 D derive: Deriving GitSignsStagedDeleteNr from GitSignsDeleteNr
1.12 D derive: Deriving GitSignsStagedChangedeleteNr from GitSignsChangedeleteNr
1.14 D derive: Deriving GitSignsStagedTopdeleteNr from GitSignsTopdeleteNr
1.15 D derive: Deriving GitSignsStagedAddLn from GitSignsAddLn
1.17 D derive: Deriving GitSignsStagedChangeLn from GitSignsChangeLn
1.19 D derive: Could not derive GitSignsStagedDeleteLn
1.20 D derive: Deriving GitSignsStagedChangedeleteLn from GitSignsChangedeleteLn
1.22 D derive: Could not derive GitSignsStagedTopdeleteLn
1.23 D derive: Deriving GitSignsAddPreview from DiffAdd
1.27 D derive: Deriving GitSignsDeletePreview from DiffDelete
1.30 D derive: Deriving GitSignsCurrentLineBlame from NonText
1.32 D derive: Deriving GitSignsAddInline from TermCursor
1.35 D derive: Deriving GitSignsDeleteInline from TermCursor
1.36 D derive: Deriving GitSignsChangeInline from TermCursor
1.38 D derive: Deriving GitSignsAddLnInline from GitSignsAddInline
1.39 D derive: Deriving GitSignsChangeLnInline from GitSignsChangeInline
1.42 D derive: Deriving GitSignsDeleteLnInline from GitSignsDeleteInline
1.44 D derive: Deriving GitSignsDeleteVirtLn from DiffDelete
1.46 D derive: Deriving GitSignsDeleteVirtLnInLine from GitSignsDeleteLnInline
1.47 D derive: Deriving GitSignsVirtLnum from GitSignsDeleteVirtLn
7.04 D attach(1): Attaching (trigger=BufReadPost)
7.11 D run_job: git --version
20.86 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
23.27 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/stv/dotfiles/gitsigns-minimal-blame/.git config user.name
25.44 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/stv/dotfiles/gitsigns-minimal-blame/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol /home/stv/dotfiles/gitsigns-minimal-blame/minimal.lua
28.12 D watch_gitdir(1): Watching git dir
28.26 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/stv/dotfiles/gitsigns-minimal-blame/.git show 218dc52fdb7d9f1c587dd375520641e44b77565d
31.86 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/stv/dotfiles/gitsigns-minimal-blame/.git show HEAD:minimal.lua
1036.21 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/stv/dotfiles/gitsigns-minimal-blame/.git blame --contents - --incremental -- /home/stv/dotfiles/gitsigns-minimal-blame/minimal.lua
11195.60 D cli.run: Running action 'show' with arguments { "@" }
11195.99 D show(2): Detached
11196.00 D show(2): Cache was nil
11196.05 D attach(2): Attaching (trigger=BufFilePost)
11196.09 D show(2): Gitsigns buffer for file '/home/stv/dotfiles/gitsigns-minimal-blame/minimal.lua' from path 'gitsigns:///home/stv/dotfiles/gitsigns-minimal-blame/.git/@:minimal.lua' on commit '@'
11196.33 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/stv/dotfiles/gitsigns-minimal-blame/.git show @:minimal.lua
11198.10 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
11201.02 D show(1): bufname gitsigns:///home/stv/dotfiles/gitsigns-minimal-blame/.git/@:minimal.lua
11201.79 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/stv/dotfiles/gitsigns-minimal-blame/.git -c core.quotepath=off ls-tree @ /home/stv/dotfiles/gitsigns-minimal-blame/minimal.lua
11207.72 D show(2): Watching git dir
11207.75 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/stv/dotfiles/gitsigns-minimal-blame/.git show 218dc52fdb7d9f1c587dd375520641e44b77565d
11211.08 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/stv/dotfiles/gitsigns-minimal-blame/.git show @^:minimal.lua
12216.27 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/stv/dotfiles/gitsigns-minimal-blame/.git blame --contents - --incremental @ -- /home/stv/dotfiles/gitsigns-minimal-blame/minimal.lua
24402.27 D show(2): Detached
24402.67 D attach(3): Attaching (trigger=BufNewFile)
24405.21 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
24407.77 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/stv/dotfiles/gitsigns-minimal-blame/.git config user.name
24410.02 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/stv/dotfiles/gitsigns-minimal-blame/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol /home/stv/dotfiles/gitsigns-minimal-blame/asdf.log
24412.45 D attach(3): Not a file
45778.68 D cli.run: Running action 'debug_messages' with arguments {}

Gitsigns cache

No response

@stv17 stv17 added the bug Something isn't working label Jul 20, 2024
@lewis6991
Copy link
Owner

Works for me

Screen.Recording.2024-08-02.at.09.29.54.mov

Is it perhaps your version of git?

@lewis6991
Copy link
Owner

Can you run:

cat minimal.lua | git blame --contents - --incremental @ -- minimal.lua

@lewis6991 lewis6991 added the unable to reproduce Unable to reproduce problem label Aug 2, 2024
@stv17
Copy link
Author

stv17 commented Aug 2, 2024

Hello, indeed it'd appear to be the git version.
The command you suggested (cat minimal.lua | git blame --contents - --incremental @ -- minimal.lua) throws the same error I see in neovim:

fatal: cannot use --contents with final commit object name

My git version is:

git version 2.39.2

Further, looking at git-blame docs:

  • version 2.38.0 (link) shows a signature where --contents and revision cannot be specified at the same time, which would throw the error I see.
  • the next version of the docs is 2.41.0 (link) shows a signature where both --contents and revision can be specified at the same time.

So I bet you have git v2.41 or greater.
Thanks for your feedback, in my case this will be solved by the next git update from Debian.

@lewis6991
Copy link
Owner

Hmm I might be able to workaround this. If revision is specified, then most of the time --contents shouldn't be needed.

@lewis6991 lewis6991 removed the unable to reproduce Unable to reproduce problem label Sep 4, 2024
@hellohake

This comment was marked as spam.

lewis6991 added a commit that referenced this issue Jan 20, 2025
lewis6991 added a commit that referenced this issue Jan 20, 2025
@lewis6991 lewis6991 linked a pull request Jan 20, 2025 that will close this issue
lewis6991 added a commit that referenced this issue Jan 20, 2025
@lewis6991
Copy link
Owner

#1177 will avoid the issue most of the time but not completely.

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
3 participants