Skip to content

Commit 6617978

Browse files
authored
Merge pull request #1811 from hammerlink/feature/parameterize-commit-order
2 parents 4046f74 + e742bf1 commit 6617978

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ neogit.setup {
133133
-- Flag description: https://git-scm.com/docs/git-branch#Documentation/git-branch.txt---sortltkeygt
134134
-- Sorting keys: https://git-scm.com/docs/git-for-each-ref#_options
135135
sort_branches = "-committerdate",
136+
-- Value passed to the `--<commit_order>-order` flag of the `git log` command
137+
-- Determines how commits are traversed and displayed in the log / graph:
138+
-- "topo" topological order (parents always before children, good for graphs, slower on large repos)
139+
-- "date" chronological order by commit date
140+
-- "author-date" chronological order by author date
141+
-- "" disable explicit ordering (fastest, recommended for very large repos)
142+
commit_order = "topo"
136143
-- Default for new branch name prompts
137144
initial_branch_name = "",
138145
-- Change the default way of opening neogit

doc/neogit.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ to Neovim users.
147147
-- Flag description: https://git-scm.com/docs/git-branch#Documentation/git-branch.txt---sortltkeygt
148148
-- Sorting keys: https://git-scm.com/docs/git-for-each-ref#_options
149149
sort_branches = "-committerdate",
150+
-- Value passed to the `--<commit_order>-order` flag of the `git log` command
151+
-- Determines how commits are traversed and displayed in the log / graph:
152+
-- "topo" topological order (parents always before children, good for graphs, slower on large repos)
153+
-- "date" chronological order by commit date
154+
-- "author-date" chronological order by author date
155+
-- "" disable explicit ordering (fastest, recommended for very large repos)
156+
commit_order = "topo"
150157
-- Default for new branch name prompts
151158
initial_branch_name = "",
152159
-- Change the default way of opening neogit

lua/neogit/config.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,12 @@ end
310310
---| "ascii"
311311
---| "unicode"
312312
---| "kitty"
313+
---
314+
---@alias NeogitCommitOrder
315+
---| ""
316+
---| "topo"
317+
---| "author-date"
318+
---| "date"
313319

314320
---@class NeogitConfigStatusOptions
315321
---@field recent_commit_count? integer The number of recent commits to display
@@ -346,6 +352,7 @@ end
346352
---@field use_per_project_settings? boolean Scope persisted settings on a per-project basis
347353
---@field remember_settings? boolean Whether neogit should persist flags from popups, e.g. git push flags
348354
---@field sort_branches? string Value used for `--sort` for the `git branch` command
355+
---@field commit_order? NeogitCommitOrder Value used for `--<commit_order>-order` for the `git log` command
349356
---@field initial_branch_name? string Default for new branch name prompts
350357
---@field kind? WindowKind The default type of window neogit should open in
351358
---@field floating? NeogitConfigFloating The floating window style
@@ -408,6 +415,7 @@ function M.get_default_values()
408415
remember_settings = true,
409416
fetch_after_checkout = false,
410417
sort_branches = "-committerdate",
418+
commit_order = "topo",
411419
kind = "tab",
412420
floating = {
413421
relative = "editor",

lua/neogit/lib/git/log.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,17 @@ function M.register(meta)
425425
repo_state.recent = { items = {} }
426426

427427
local count = config.values.status.recent_commit_count
428-
local order = state.get({ "NeogitMarginPopup", "-order" }, "topo")
428+
local order = state.get({ "NeogitMarginPopup", "-order" }, config.values.commit_order)
429429

430430
if count > 0 then
431-
repo_state.recent.items = util.filter_map(
432-
M.list({ "--max-count=" .. tostring(count), "--" .. order .. "-order" }, {}, {}, true),
433-
M.present_commit
434-
)
431+
local args = { "--max-count=" .. tostring(count) }
432+
local graph = nil
433+
if order and order ~= "" then
434+
table.insert(args, "--" .. order .. "-order")
435+
graph = {}
436+
end
437+
438+
repo_state.recent.items = util.filter_map(M.list(args, graph, {}, false), M.present_commit)
435439
end
436440
end
437441
end

lua/neogit/popups/margin/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local popup = require("neogit.lib.popup")
2-
-- local config = require("neogit.config")
2+
local config = require("neogit.config")
33
local actions = require("neogit.popups.margin.actions")
44

55
local M = {}
@@ -13,7 +13,7 @@ function M.create(env)
1313
-- :option("n", "max-count", "256", "Limit number of commits", { default = "256", key_prefix = "-" })
1414
:switch(
1515
"o",
16-
"topo",
16+
config.values.commit_order,
1717
"Order commits by",
1818
{
1919
cli_suffix = "-order",

0 commit comments

Comments
 (0)