Skip to content

Range diff picker omits the current branch when opened from status view #1998

Description

@jeiea

Description

The range diff ref picker omits the current branch when opened from the status view with dr. HEAD is available and points to the same commit, but the branch name itself is absent.

Tested with Neogit v3.0.0-219-g37e0f22a (37e0f22a2345bad1bffe01b31970885882f46275).

Neovim version

NVIM v0.12.3
Build type: Release
LuaJIT 2.1.1774638290

Operating system and version

macOS 26.6 (25G72)

Steps to reproduce

  1. Create a repository with main and check out a branch named feature.
  2. Start Neovim in that repository with nvim -nu minimal.lua.
  3. Run :Neogit.
  4. Press d, then r.
  5. Inspect the Diff for range from choices.

Expected behavior

feature is offered as a range endpoint.

Actual behavior

The choices include main and HEAD, but not feature.

Minimal config

minimal.lua
vim.opt.runtimepath = { vim.env.VIMRUNTIME }

local root = vim.fn.fnamemodify(
  debug.getinfo(1, "S").source:sub(2),
  ":p:h"
) .. "/.min/plugins/"

local plugins = {
  plenary = "https://github.com/nvim-lua/plenary.nvim.git",
  diffview = "https://github.com/sindrets/diffview.nvim",
  neogit = "https://github.com/NeogitOrg/neogit",
}

vim.fn.mkdir(root, "p")

for name, url in pairs(plugins) do
  local path = root .. name

  if not vim.uv.fs_stat(path) then
    vim.fn.system({ "git", "clone", "--depth=1", url, path })
    assert(vim.v.shell_error == 0, "Failed to clone " .. name)
  end

  vim.opt.runtimepath:append(path)
end

require("neogit").setup({})

Additional context

The range action constructs its first candidate list as { commit, git.branch.current() or "HEAD" }. From the status view, commit is nil. Because util.merge uses ipairs, iteration stops before reaching the current branch at index 2. get_all_branches(false) also excludes the current branch, so no later candidate source adds it back.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions