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 change_base <branch_name> not setting the correct rev #1118

Open
Summon528 opened this issue Sep 7, 2024 · 0 comments
Open

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

Summon528 opened this issue Sep 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Summon528
Copy link

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

@Summon528 Summon528 added the bug Something isn't working label Sep 7, 2024
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

1 participant