Range diff picker omits the current branch when opened from status view
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 5.6k
- Forks
- 357
- Avg merge
- 15h 47m
- Merged PRs (30d)
- 2
Description
Description
The range diff ref picker omits the current branch when opened from the status view with d → r. 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
- Create a repository with
mainand check out a branch namedfeature. - Start Neovim in that repository with
nvim -nu minimal.lua. - Run
:Neogit. - Press
d, thenr. - Inspect the
Diff for range fromchoices.
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the status-view flow with d then r, then inspect lua/neogit/popups/diff/actions.lua around range candidate construction and lua/neogit/lib/util.lua around util.merge. Verify how a nil first candidate affects the merged choices and confirm the current branch is offered as a range endpoint when the issue is fixed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, lua, neovim
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100