Skip to content

Gitsigns change_base <branch_name> not setting the correct rev #1118

@Summon528

Description

@Summon528

Description

When running :Gitsigns change_base <branch_name> I expect Gitsigns to show the difference between the current file and the version that's on the tip of <branch_name>. However, it seems like Gitsigns is adding a ^ to the end of the revision string, thus causing unexpected diffs. Instead of comparing against, for example, master, Gitsigns is comparing against master^

Here's the code and the commit that's adding the ^, everything works as expected if I remove the ^ but I'm not sure if it's there to serve some other purposes.

local staged_rev = git_obj:from_tree() and git_obj.revision .. '^' or 'HEAD'

47c8e3e

Neovim version

NVIM v0.10.1

Operating system and version

openSUSE Tumbleweed 20240901

Expected behavior

After doing the reproduce steps, no git change line should be shown.

Actual behavior

image
A git change indicator was shown

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 1 > file
  5. git add file
  6. git commit -m 'commit msg'
  7. git switch -c branch
  8. nvim --clean -u minimal.lua file
  9. :Gitsigns change_base master

Gitsigns debug messages

9659.55 D cli.run: Running action 'change_base' with arguments { "master" }
9659.60 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/xxx/gitsigns_issue/.git -c core.quotepath=off ls-tree master /home/xxx/gitsigns_issue/file
9661.29 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/xxx/gitsigns_issue/.git show d00491fd7e5bb6fa28c517a0bb32b8b506539d4d
9663.12 D run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir /home/xxx/gitsigns_issue/.git show master^:file

Gitsigns cache

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions