diff --git a/lua/neogit/lib/git/log.lua b/lua/neogit/lib/git/log.lua index 196d4ce22..54ac725b7 100644 --- a/lua/neogit/lib/git/log.lua +++ b/lua/neogit/lib/git/log.lua @@ -2,6 +2,7 @@ local git = require("neogit.lib.git") local util = require("neogit.lib.util") local config = require("neogit.config") local record = require("neogit.lib.record") +local state = require("neogit.lib.state") ---@class NeogitGitLog local M = {} @@ -420,13 +421,17 @@ function M.parent(commit) end function M.register(meta) - meta.update_recent = function(state) - state.recent = { items = {} } + meta.update_recent = function(repo_state) + repo_state.recent = { items = {} } local count = config.values.status.recent_commit_count + local order = state.get({ "NeogitMarginPopup", "-order" }, "topo") + if count > 0 then - state.recent.items = - util.filter_map(M.list({ "--max-count=" .. tostring(count) }, nil, {}, true), M.present_commit) + repo_state.recent.items = util.filter_map( + M.list({ "--max-count=" .. tostring(count), "--" .. order .. "-order" }, {}, {}, true), + M.present_commit + ) end end end diff --git a/lua/neogit/popups/margin/init.lua b/lua/neogit/popups/margin/init.lua index 5079c0802..154d4f6b4 100644 --- a/lua/neogit/popups/margin/init.lua +++ b/lua/neogit/popups/margin/init.lua @@ -11,15 +11,20 @@ function M.create(env) .builder() :name("NeogitMarginPopup") -- :option("n", "max-count", "256", "Limit number of commits", { default = "256", key_prefix = "-" }) - -- :switch("o", "topo", "Order commits by", { - -- cli_suffix = "-order", - -- options = { - -- { display = "", value = "" }, - -- { display = "topo", value = "topo" }, - -- { display = "author-date", value = "author-date" }, - -- { display = "date", value = "date" }, - -- }, - -- }) + :switch( + "o", + "topo", + "Order commits by", + { + cli_suffix = "-order", + options = { + { display = "", value = "" }, + { display = "topo", value = "topo" }, + { display = "author-date", value = "author-date" }, + { display = "date", value = "date" }, + }, + } + ) -- :switch("g", "graph", "Show graph", { -- enabled = true, -- internal = true, diff --git a/spec/popups/margin_popup_spec.rb b/spec/popups/margin_popup_spec.rb index fe26666fb..f834c940f 100644 --- a/spec/popups/margin_popup_spec.rb +++ b/spec/popups/margin_popup_spec.rb @@ -8,7 +8,7 @@ [ " Arguments ", # " -n Limit number of commits (--max-count=256) ", - # " -o Order commits by (--[topo|author-date|date]-order) ", + " -o Order commits by (--[topo|author-date|date]-order) ", # " -g Show graph (--graph) ", # " -c Show graph in color (--color) ", " -d Show refnames (--decorate) ",