Show relative commit age in the compact commits view
Is your feature request related to a problem? Please describe
I usually keep the commits panel in normal/compact screen mode. It shows the commit hash, author, graph, and subject, but not when each commit was created.
The timestamp becomes visible after enlarging the panel with +, but this
changes the layout and shows an absolute date or time. I would like to see the
relative age while keeping the compact one-line layout, especially when
scanning recent commits.
Describe the solution you'd like
Add an optional relative-age column to commit rows in the compact view:
82c03593 4m IL ○─ Merge pull request...
059c9ca0 2h IL ○ Leave the pause...
ece5ac1a 3d IL ○ Merge pull request...
Using the same short representation as the branches panel (4m, 2h, 3d)
would keep the column narrow and make the two panels consistent.
This could be exposed as either:
- a toggle in the commits Log menu, with the choice persisted; or
- an opt-in configuration setting such as
showCommitAgeInCompactView.
The existing compact layout should remain the default.
Current implementation
The required data and formatter already appear to exist:
Commits contain
UnixTimestamp.utils.UnixToTimeAgo(timestamp)inpkg/utils/date.goconverts a Unix timestamp into the compacts,m,h,d,w,M, oryformat.pkg/commands/git_commands/branch_loader.gousesUnixToTimeAgowhen populatingBranch.Recency, which is rendered as the first column in the branches panel.Stash entries use the same formatter.
In
pkg/gui/presentation/commits.go,displayCommitalready has access tocommit.UnixTimestamp. However, its date column is populated only whenfullDescriptionis true:descriptionString := "" if fullDescription { descriptionString = style.FgBlue.Sprint( utils.UnixToDateSmart( now, commit.UnixTimestamp, timeFormat, shortTimeFormat, ), ) }fullDescriptionis passed by the commits context when the screen mode is notSCREEN_NORMAL, which explains why the timestamp appears after pressing+but not in the normal compact view.
A possible implementation would therefore reuse UnixToTimeAgo for the
description column when compact relative ages are enabled, without requiring
another Git command or additional commit data.
Relevant files:
pkg/utils/date.gopkg/commands/git_commands/branch_loader.gopkg/gui/presentation/branches.gopkg/gui/presentation/commits.gopkg/gui/context/local_commits_context.go
Describe alternatives you've considered
- Enlarging the commits panel with
+. This shows a timestamp, but changes the layout and usestimeFormat/shortTimeFormatrather than relative age. - Customizing
branchLogCmd. It can display%cr, but only changes the branch log in the main panel and does not affect the interactive commits list. - Opening a separate
git logortigview. This loses the integrated lazygit commit workflow.
Additional context
PR #5846 proposes normal, comfortable, and spacious commit display
formats, with author and date on a second line in the latter two modes:
https://github.com/jesseduffield/lazygit/pull/5846
That proposal is related, but this request is specifically about showing a small relative-age column in the existing one-line compact layout.
Source: jesseduffield/lazygit