Skip to content

hunk pager strips Git colors from LazyGit's non-diff output (branch log) #702

Description

@DanielCarmingham

With hunk pager configured as LazyGit's pager, the branch-log panel loses all of Git's colors. Diffs are unaffected — only non-diff output is stripped.

Released hunkdiff@0.18.0 — colors stripped

LazyGit branch log with released hunk 0.18.0, rendered in a single color

With the fix — Git's colors preserved

LazyGit branch log with the fix, showing per-ref colors

Same repo, same commit, same terminal size. Only the pager binary differs. Note the [0] Log panel: commit SHAs and the (HEAD → main, origin/main, origin/HEAD) decoration go from flat gray to their normal per-ref palette.

Cause

Captured pager hosts like LazyGit advertise TERM=dumb while rendering ANSI in their own panel. Hunk already detects this for diffs — isCapturedPagerHost in src/app/startup.ts is what routes those hosts to the static colored renderer instead of launching the TUI. Non-diff input returns passthrough before reaching that point, and passthrough strips SGR unconditionally.

This is the LazyGit-shaped gap left by #381 (which closed #379). That fix preserves color via pagePlainText, but captured hosts never reach pagePlainTextTERM=dumb sends them down the passthrough path first.

The fix is to reuse the existing detection rather than add a second heuristic: the same predicate that already tells the diff path "this host renders ANSI" decides whether passthrough preserves it. Genuinely dumb terminals still get plain text.

Steps to reproduce

  1. Configure LazyGit with git.paging.pager: hunk pager and colorArg: always
  2. Open LazyGit in any repo with history
  3. Select the [3] Local branches panel
  4. The branch log in the main panel renders in a single color; with GIT_PAGER=less it is colored

Environment

  • hunkdiff 0.18.0 (npm)
  • LazyGit 0.64.0, macOS arm64, git 2.53.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions