NeogitOrg / neogit

An interactive and powerful Git interface for Neovim, inspired by Magit
MIT License
4.08k stars 241 forks source link

"Recent commits" section does not show if there are unmerged commits #1378

Closed fnune closed 5 months ago

fnune commented 5 months ago

Description

This is what Neogit looks like without unmerged commits:

image

As soon as there are unmerged commits, I see that the "Recent commits" sections is out:

image

I want the "Recent commits" section to show always, like it did before recent updates.

Neovim version

~/Development/memfault => nvim --version NVIM v0.10.0 Build type: Release LuaJIT 2.1.1713773202 Run "nvim -V1 -v" for more info

Operating system and version

Linux feanor 6.8.12 #1-NixOS SMP PREEMPT_DYNAMIC Thu May 30 07:49:53 UTC 2024 x86_64 GNU/Linux

Steps to reproduce

Expected behavior

No response

Actual behavior

No "Recent commits" section if unmerged commits exist

Minimal config

-- NOTE: See the end of this file if you are reporting an issue, etc. Ignore all the "scary" functions up top, those are
-- used for setup and other operations.
local M = {}

local base_root_path = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h") .. "/.min"
function M.root(path)
  return base_root_path .. "/" .. (path or "")
end

function M.load_plugin(plugin_name, plugin_url)
  local package_root = M.root("plugins/")
  local install_destination = package_root .. plugin_name
  vim.opt.runtimepath:append(install_destination)

  if not vim.loop.fs_stat(package_root) then
    vim.fn.mkdir(package_root, "p")
  end

  if not vim.loop.fs_stat(install_destination) then
    print(string.format("> Downloading plugin '%s' to '%s'", plugin_name, install_destination))
    vim.fn.system({
      "git",
      "clone",
      "--depth=1",
      plugin_url,
      install_destination,
    })
    if vim.v.shell_error > 0 then
      error(string.format("> Failed to clone plugin: '%s' in '%s'!", plugin_name, install_destination),
        vim.log.levels.ERROR)
    end
  end
end

---@alias PluginName string The plugin name, will be used as part of the git clone destination
---@alias PluginUrl string The git url at which a plugin is located, can be a path. See https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols for details
---@alias MinPlugins table<PluginName, PluginUrl>

---Do the initial setup. Downloads plugins, ensures the minimal init does not pollute the filesystem by keeping
---everything self contained to the CWD of the minimal init file. Run prior to running tests, reproducing issues, etc.
---@param plugins? table<PluginName, PluginUrl>
function M.setup(plugins)
  vim.opt.packpath = {}                      -- Empty the package path so we use only the plugins specified
  vim.opt.runtimepath:append(M.root(".min")) -- Ensure the runtime detects the root min dir

  -- Install required plugins
  if plugins ~= nil then
    for plugin_name, plugin_url in pairs(plugins) do
      M.load_plugin(plugin_name, plugin_url)
    end
  end

  vim.env.XDG_CONFIG_HOME = M.root("xdg/config")
  vim.env.XDG_DATA_HOME = M.root("xdg/data")
  vim.env.XDG_STATE_HOME = M.root("xdg/state")
  vim.env.XDG_CACHE_HOME = M.root("xdg/cache")

  -- NOTE: Cleanup the xdg cache on exit so new runs of the minimal init doesn't share any previous state, e.g. shada
  vim.api.nvim_create_autocmd("VimLeave", {
    callback = function()
      vim.fn.system({
        "rm",
        "-r",
        "-f",
        M.root("xdg")
      })
    end
  })
end

-- NOTE: If you have additional plugins you need to install to reproduce your issue, include them in the plugins
-- table within the setup call below.
M.setup({
  plenary = "https://github.com/nvim-lua/plenary.nvim.git",
  telescope = "https://github.com/nvim-telescope/telescope.nvim",
  diffview = "https://github.com/sindrets/diffview.nvim",
  neogit = "https://github.com/NeogitOrg/neogit"
})
-- WARN: Do all plugin setup, test runs, reproductions, etc. AFTER calling setup with a list of plugins!
-- Basically, do all that stuff AFTER this line.
require("neogit").setup({}) -- For instance, setup Neogit
CKolkey commented 5 months ago

Not a bug; this is how Magit renders the status buffer with unmerged commits. You could add a "show_recent_despite_unmerged_commits" config option if you're so inclined :)

fnune commented 5 months ago

I see, sorry to have characterized it as such. I did so because the previous behavior was to keep showing "Recent commits".

If this is the design, then :+1:

THX!

CKolkey commented 5 months ago

No worries :)

wrobell commented 3 months ago

Please consider the following.

I have list of recent commits and I would like to rebase

  1. Go to the commit
  2. Hit r to rebase
  3. Rebase

Now, I commit a change and I would like to rebase to previous commit

  1. Move away from the commit (or the below is not possible)
  2. Hit r for rebase
  3. There is a list of commits, but I am at the bottom of the screen, therefore move to the top of the screen
  4. Select the commit
  5. Rebase

Is there a way to simplify the 2nd scenario without list of recent commits?

CKolkey commented 3 months ago

I'm not sure if this answers your question, but you can invoke the rebase popup from both the reflog and log buffers to use the commit under your cursor as the "selection" for rebasing.

wrobell commented 3 months ago

@CKolkey It seems then, after a commit, the flow could be

  1. Enter log buffer
  2. I am at the bottom of the screen, move to the top of the screen
  3. Select commit
  4. Rebase

IMHO, if there was simply list of recent commits, there would be less friction.

Alternatively, when my cursor is on "Head", "Merge" or other top-lines in the neogit buffer, then hitting r could directly go to rebase screen selecting that commit. At the moment, hitting r opens log buffer (with cursor located at the bottom).

wrobell commented 2 months ago

BTW. For last couple of weeks rebasing from log buffer is broken (ll) - first line is empty instead of showing selected commit. This happens when rebase window opens to the right. It works OK if opens to the bottom.

Works as expected when using recent commits.