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

git blame fails -- looks like the git command is incorrect #975

Closed
tkinz27 opened this issue Apr 5, 2024 · 3 comments · Fixed by #1002
Closed

git blame fails -- looks like the git command is incorrect #975

tkinz27 opened this issue Apr 5, 2024 · 3 comments · Fixed by #1002
Labels
bug Something isn't working

Comments

@tkinz27
Copy link

tkinz27 commented Apr 5, 2024

Description

Recently updated plugin now fails to git blame the current line. The output from :messages

My config (pretty close to LazyVim configuration just with the added blame configuration). The minimal reproduction config below works too.

My version of gitsigns plugin

~/.local/share/nvim/lazy/gitsigns.nvim main
❯ git rev-parse HEAD
fa052c20aa7cc62ce6a328c7f3bd556c93b5370e

Maybe related to #974 ?

Neovim version

❯ nvim --version NVIM v0.10.0-dev-2410+g6d8bbfe19-Homebrew Build type: Release LuaJIT 2.1.1710088188 Run "nvim -V1 -v" for more info

Operating system and version

MacOS (apple silicon)

Expected behavior

git blame integration works without error.

Actual behavior

Error running git-blame: usage: git blame [<options>] [<rev-opts>] [<rev>] [--] <file>

    <rev-opts> are documented in git-rev-list(1)

    --[no-]incremental    show blame entries as we find them, incrementally
    -b                    do not show object names of boundary commits (Default: off)
    --[no-]root           do not treat root commits as boundaries (Default: off)
    --[no-]show-stats     show work cost statistics
    --[no-]progress       force progress reporting
    --[no-]score-debug    show output score for blame entries
    -f, --[no-]show-name  show original filename (Default: auto)
    -n, --[no-]show-number
                          show original linenumber (Default: off)
    -p, --[no-]porcelain  show in a format designed for machine consumption
    --[no-]line-porcelain show porcelain format with per-line commit information
    -c                    use the same output mode as git-annotate (Default: off)
    -t                    show raw timestamp (Default: off)
    -l                    show long commit SHA1 (Default: off)
    -s                    suppress author name and timestamp (Default: off)
    -e, --[no-]show-email show author email instead of name (Default: off)
    -w                    ignore whitespace differences
    --[no-]ignore-rev <rev>
                          ignore <rev> when blaming
    --[no-]ignore-revs-file <file>
                          ignore revisions from <file>
    --[no-]color-lines    color redundant metadata from previous line differently
    --[no-]color-by-age   color lines by age
    --[no-]minimal        spend extra cycles to find better match
    -S <file>             use revisions from <file> instead of calling git-rev-list
    --[no-]contents <file>
                          use <file>'s contents as the final image
    -C[<score>]           find line copies within and across files
    -M[<score>]           find line movements within and across files
    -L <range>            process only line range <start>,<end> or function :<funcname>
    --[no-]abbrev[=<n>]   use <n> digits to display object names

Error executing vim.schedule lua callback: ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:85: The coroutine failed with this message: ...l/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/actions.lua:938: assertion failed!
stack traceback:
        [C]: in function 'assert'
        ...l/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/actions.lua:938: in function <...l/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/actions.lua:905>
stack traceback:
        [C]: in function 'error'
        ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:85: in function 'cb'
        ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:127: in function <...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:126>

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
        current_line_blame = true,
      current_line_blame_opts = { delay = 1000, virt_text_priority = 100, virt_text = true, virt_text_pos = 'eol' },
      debug_mode = true,
}

-- ADD INIT.LUA SETTINGS THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE

Steps to reproduce

  1. nvim --clean -u minimal.lua
  2. ...

Gitsigns debug messages

relevant lines

run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/tony.kinsley/code/github.com/braincorp/titanium/.git blame --contents - --incremental -- /Users/tony.kinsley/code/github.com/braincorp/titanium/api/proto/autoroboapi/v1/alerts.proto --igno
re-revs-file /Users/tony.kinsley/code/github.com/braincorp/titanium/.git-blame-ignore-revs
run_job: git --no-pager --literal-pathspecs -c gc.auto=0 --git-dir /Users/tony.kinsley/code/github.com/braincorp/titanium/.git blame --contents - --incremental -- /Users/tony.kinsley/code/github.com/braincorp/titanium/api/proto/autoroboapi/v1/alerts.proto --igno
re-revs-file /Users/tony.kinsley/code/github.com/braincorp/titanium/.git-blame-ignore-revs
@tkinz27 tkinz27 added the bug Something isn't working label Apr 5, 2024
@kevinmcgill
Copy link

FYI. If my project contains a .git-blame-ignore-revs file then I see the error outlined above, if I remove the file and relaunch Neovim everything works as expected.

@tkinz27
Copy link
Author

tkinz27 commented Apr 5, 2024

Ahh thank you for that. Looks like the --ignore-revs-file option is in the wrong place. I think this patch would fix it, but would need to figure out how to get my neovim to point at the custom version of this plugin to actually test it. If no one else submits a PR first I'll try to find some time to figure that out when i get the chance.

❯ git --no-pager diff
diff --git a/lua/gitsigns/git.lua b/lua/gitsigns/git.lua
index ce50b0f..2101043 100644
--- a/lua/gitsigns/git.lua
+++ b/lua/gitsigns/git.lua
@@ -591,14 +591,15 @@ function Obj:run_blame(lines, lnum, opts)
   end

   args[#args + 1] = opts.rev
-  args[#args + 1] = '--'
-  args[#args + 1] = self.file

   local ignore_file = self.repo.toplevel .. '/.git-blame-ignore-revs'
   if uv.fs_stat(ignore_file) then
     vim.list_extend(args, { '--ignore-revs-file', ignore_file })
   end

+  args[#args + 1] = '--'
+  args[#args + 1] = self.file
+
   local results, stderr = self:command(args, { stdin = lines, ignore_error = true })
   if stderr then
     error_once('Error running git-blame: ' .. stderr)

@skoch13
Copy link

skoch13 commented Apr 5, 2024

but would need to figure out how to get my neovim to point at the custom version of this plugin to actually test it

@tkinz27 one of the ways if to fork this repo, make a change in your fork and point the package manager to your forked repo.

@kevinmcgill indeed this looks like a root cause for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment