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

gitsigns_head shows nil instead of revision #949

Closed
Mikilio opened this issue Feb 26, 2024 · 0 comments · Fixed by #1002
Closed

gitsigns_head shows nil instead of revision #949

Mikilio opened this issue Feb 26, 2024 · 0 comments · Fixed by #1002
Labels
bug Something isn't working

Comments

@Mikilio
Copy link

Mikilio commented Feb 26, 2024

Description

When using vimdiff I wanted to display the revision of the current buffer on the statusline, however gitsigns_head only shows nil when no inside a branch. It would be nice to instead display a (shortened) commit hash.

Neovim version

NVIM v0.9.5 Build type: Release LuaJIT 2.1.1693350652 system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: " /nix/store/0mrn8874pisnpizlkkvcchkly3dkrhif-neovim-unwrapped-0.9.5/share/nvim "

Operating system and version

NixOS unstable

Expected behavior

Show (shortened) commit hash when in buffer at revision without pointing branch.

Actual behavior

Shows nil instead

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. nvim --clean -u minimal.lua inside git repo
  2. make a change to a file
  3. :Gitsigns diffthis
  4. :lua print(vim.b.gitsigns_head)

Gitsigns debug messages

No response

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