diff --git a/README.md b/README.md index ecf42db47..ff5be1813 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,13 @@ neogit.setup { -- Flag description: https://git-scm.com/docs/git-branch#Documentation/git-branch.txt---sortltkeygt -- Sorting keys: https://git-scm.com/docs/git-for-each-ref#_options sort_branches = "-committerdate", + -- Value passed to the `---order` flag of the `git log` command + -- Determines how commits are traversed and displayed in the log / graph: + -- "topo" topological order (parents always before children, good for graphs, slower on large repos) + -- "date" chronological order by commit date + -- "author-date" chronological order by author date + -- "" disable explicit ordering (fastest, recommended for very large repos) + commit_order = "topo" -- Default for new branch name prompts initial_branch_name = "", -- Change the default way of opening neogit diff --git a/doc/neogit.txt b/doc/neogit.txt index 5d1cb0276..73f776473 100644 --- a/doc/neogit.txt +++ b/doc/neogit.txt @@ -147,6 +147,13 @@ to Neovim users. -- Flag description: https://git-scm.com/docs/git-branch#Documentation/git-branch.txt---sortltkeygt -- Sorting keys: https://git-scm.com/docs/git-for-each-ref#_options sort_branches = "-committerdate", + -- Value passed to the `---order` flag of the `git log` command + -- Determines how commits are traversed and displayed in the log / graph: + -- "topo" topological order (parents always before children, good for graphs, slower on large repos) + -- "date" chronological order by commit date + -- "author-date" chronological order by author date + -- "" disable explicit ordering (fastest, recommended for very large repos) + commit_order = "topo" -- Default for new branch name prompts initial_branch_name = "", -- Change the default way of opening neogit diff --git a/lua/neogit/config.lua b/lua/neogit/config.lua index 67d79e6cd..6f65ac032 100644 --- a/lua/neogit/config.lua +++ b/lua/neogit/config.lua @@ -310,6 +310,12 @@ end ---| "ascii" ---| "unicode" ---| "kitty" +--- +---@alias NeogitCommitOrder +---| "" +---| "topo" +---| "author-date" +---| "date" ---@class NeogitConfigStatusOptions ---@field recent_commit_count? integer The number of recent commits to display @@ -346,6 +352,7 @@ end ---@field use_per_project_settings? boolean Scope persisted settings on a per-project basis ---@field remember_settings? boolean Whether neogit should persist flags from popups, e.g. git push flags ---@field sort_branches? string Value used for `--sort` for the `git branch` command +---@field commit_order? NeogitCommitOrder Value used for `---order` for the `git log` command ---@field initial_branch_name? string Default for new branch name prompts ---@field kind? WindowKind The default type of window neogit should open in ---@field floating? NeogitConfigFloating The floating window style @@ -408,6 +415,7 @@ function M.get_default_values() remember_settings = true, fetch_after_checkout = false, sort_branches = "-committerdate", + commit_order = "topo", kind = "tab", floating = { relative = "editor", diff --git a/lua/neogit/lib/git/log.lua b/lua/neogit/lib/git/log.lua index 54ac725b7..4958f433b 100644 --- a/lua/neogit/lib/git/log.lua +++ b/lua/neogit/lib/git/log.lua @@ -425,13 +425,17 @@ function M.register(meta) repo_state.recent = { items = {} } local count = config.values.status.recent_commit_count - local order = state.get({ "NeogitMarginPopup", "-order" }, "topo") + local order = state.get({ "NeogitMarginPopup", "-order" }, config.values.commit_order) if count > 0 then - repo_state.recent.items = util.filter_map( - M.list({ "--max-count=" .. tostring(count), "--" .. order .. "-order" }, {}, {}, true), - M.present_commit - ) + local args = { "--max-count=" .. tostring(count) } + local graph = nil + if order and order ~= "" then + table.insert(args, "--" .. order .. "-order") + graph = {} + end + + repo_state.recent.items = util.filter_map(M.list(args, graph, {}, false), M.present_commit) end end end diff --git a/lua/neogit/popups/margin/init.lua b/lua/neogit/popups/margin/init.lua index 154d4f6b4..272838737 100644 --- a/lua/neogit/popups/margin/init.lua +++ b/lua/neogit/popups/margin/init.lua @@ -1,5 +1,5 @@ local popup = require("neogit.lib.popup") --- local config = require("neogit.config") +local config = require("neogit.config") local actions = require("neogit.popups.margin.actions") local M = {} @@ -13,7 +13,7 @@ function M.create(env) -- :option("n", "max-count", "256", "Limit number of commits", { default = "256", key_prefix = "-" }) :switch( "o", - "topo", + config.values.commit_order, "Order commits by", { cli_suffix = "-order",