jesseduffield / jesseduffield/lazygit

Show relative commit age in the compact commits view

Open
#6,010 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
82.4k
Forks
3k
Avg merge
2d 18h
Merged PRs (30d)
19

Description

### 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)` in `pkg/utils/date.go` converts a Unix
timestamp into the compact `s`, `m`, `h`, `d`, `w`, `M`, or `y` format.
- `pkg/commands/git_commands/branch_loader.go` uses `UnixToTimeAgo` when
populating `Branch.Recency`, which is rendered as the first column in the
branches panel.
- Stash entries use the same formatter.
- In `pkg/gui/presentation/commits.go`, `displayCommit` already has access to
`commit.UnixTimestamp`. However, its date column is populated only when
`fullDescription` is true:

descriptionString := ""
if fullDescription {
descriptionString = style.FgBlue.Sprint(
utils.UnixToDateSmart(
now,
commit.UnixTimestamp,
timeFormat,
shortTimeFormat,
),
)
}

- `fullDescription` is passed by the commits context when the screen mode is
not `SCREEN_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.go`
- `pkg/commands/git_commands/branch_loader.go`
- `pkg/gui/presentation/branches.go`
- `pkg/gui/presentation/commits.go`
- `pkg/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 uses `timeFormat` / `shortTimeFormat` rather 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 log` or `tig` view. 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.

Contributor guide

Open the contributing guide

Research direction

Start in pkg/gui/presentation/commits.go and inspect displayCommit and the fullDescription path, then compare the relative-age handling in pkg/commands/git_commands/branch_loader.go and pkg/gui/presentation/branches.go. Review pkg/gui/context/local_commits_context.go for the compact-view configuration or menu path. Done means an opt-in relative-age column appears in compact commit rows, while the existing compact layout remains the default.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, go
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.