Skip to content

Add a user config for using git's external diff command for paging #4832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2025

Conversation

stefanhaller
Copy link
Collaborator

PR Description

This is similar to using lazygit's Git.Paging.ExternalDiffCommand config, except that the command is configured in git. This can be done either with git's diff.external config, or through .gitattributes, so it gives a bit more flexibility.

We could consider removing the Git.Paging.ExternalDiffCommand config now, because its functionality is covered by the new config. I decided to keep it though, because I don't want to make this a breaking change, and also because some users might want to have the external diff command only in lazygit but not on the command line.

@stefanhaller stefanhaller added the enhancement New feature or request label Aug 18, 2025
Copy link

codacy-production bot commented Aug 18, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 86934ce1 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (86934ce) Report Missing Report Missing Report Missing
Head commit (40e9894) 57545 49988 86.87%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4832) 10 10 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@rayluo
Copy link

rayluo commented Aug 18, 2025

PR Description

This is similar to using lazygit's Git.Paging.ExternalDiffCommand config, except that the command is configured in git. This can be done either with git's diff.external config, or through .gitattributes, so it gives a bit more flexibility.

We could consider removing the Git.Paging.ExternalDiffCommand config now, because its functionality is covered by the new config. I decided to keep it though, because I don't want to make this a breaking change, and also because some users might want to have the external diff command only in lazygit but not on the command line.

Took a quick glance. The rationale of introducing a new parameter while keeping the old one for backward compatibility makes sense.

Which panel(s) will pick up this new feature? I am not that familiar with lazygit's internal structure to know which panels the "commit.go", "diff.go", and "worktree.go" are affecting.

@stefanhaller
Copy link
Collaborator Author

Which panel(s) will pick up this new feature?

Files and Commits.

I just noticed that Stashes use neither the pager command nor the external diff command, I'll see if I can fix that as part of this PR.

@@ -309,6 +309,9 @@ git:
# e.g. 'difft --color=always'
externalDiffCommand: ""

# If true, Lazygit will use git's `diff.external` config for paging. The advantage over `externalDiffCommand` is that this can be configured per file type in .gitattributes; see https://git-scm.com/docs/gitattributes#_defining_an_external_diff_driver.
useExternalDiffGitConfig: false
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have tested this feature branch. Indeed, a useExternalDiffGitConfig: true config will have lazygit honor git's existing external diff setup, in Files panel and in Commits panel. Ship it!

@stefanhaller
Copy link
Collaborator Author

@rayluo And now it should work for stashes too.

@rayluo
Copy link

rayluo commented Aug 19, 2025

@rayluo And now it should work for stashes too.

@stefanhaller And now it is also tested for stashes too. :-)

This is similar to using lazygit's Git.Paging.ExternalDiffCommand config, except
that the command is configured in git. This can be done either with git's
`diff.external` config, or through .gitattributes, so it gives a bit more
flexibility.
@stefanhaller stefanhaller marked this pull request as ready for review August 20, 2025 08:40
@stefanhaller stefanhaller enabled auto-merge August 20, 2025 08:40
@stefanhaller stefanhaller merged commit 8beec9a into master Aug 20, 2025
12 checks passed
@stefanhaller stefanhaller deleted the external-diff-config branch August 20, 2025 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants