Skip to content

Configuring hunk pager as git core.pager strips colors from other git commands #379

@esclear

Description

@esclear

What happened?

I installed hunk using the nix flake and enabled the git integration using the home-manager module and enabling enableGitIntegration.

I have git configured so that it highlights / colors the output of git log and git commands with aliases.
Try for example the following command:

git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset) %C(dim white)- %an%C(reset)%n''          %C(white)%s%C(reset)' --all

With hunk pager defined as git's core.pager, this is now colorless.

But using eg GIT_PAGER=less git log --graph <etc.>, it is colored.
I'm coming from difftastic, where this works, though it is configured as a diff.external command, which probably won't work for hunk due to its interactive UI.

I expected that hunk keeps the highlighting intact, as less does when used as pager.

Steps to reproduce

  • Use the home-manager module, enable hunk and its git integration
  • Go to a git repository with non-empty history
  • Run and compare the two git commands
    • git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset) %C(dim white)- %an%C(reset)%n'' %C(white)%s%C(reset)' --all is colorless
    • GIT_PAGER=less git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset) %C(dim white)- %an%C(reset)%n'' %C(white)%s%C(reset)' --all is colored

Expected behavior

Hunk doesn't strip the coloring of git log and friends

Version

0.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions