Skip to content

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
@codacy-production
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.

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
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Sep 9, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) | minor | `v0.54.2` -> `v0.55.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>jesseduffield/lazygit (jesseduffield/lazygit)</summary>

### [`v0.55.0`](https://github.com/jesseduffield/lazygit/releases/tag/v0.55.0)

[Compare Source](jesseduffield/lazygit@v0.54.2...v0.55.0)

<!-- Release notes generated using configuration in .github/release.yml at v0.55.0 -->

#### What's Changed

##### Enhancements 🔥

- Allow filtering the keybindings menu by keybinding by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;4821](jesseduffield/lazygit#4821)
- Add support for suspending LazyGit with Ctrl+Z on Unix systems by [@&#8203;cowboy8625](https://github.com/cowboy8625) in [#&#8203;4757](jesseduffield/lazygit#4757)
- Add "CopyToClipboard" command to `ConfirmationController` by [@&#8203;kyu08](https://github.com/kyu08) in [#&#8203;4810](jesseduffield/lazygit#4810)
- Add a user config for using git's external diff command for paging by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;4832](jesseduffield/lazygit#4832)
- Log the hash of dropped stashes by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;4850](jesseduffield/lazygit#4850)

##### Fixes 🔧

- Fix right-alignment of divergence from base branch for branch checked out in a worktree by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;4824](jesseduffield/lazygit#4824)
- Support Azure DevOps vs-ssh.visualstudio.com SSH remotes as hosting provider by [@&#8203;Kahitar](https://github.com/Kahitar) in [#&#8203;4822](jesseduffield/lazygit#4822)
- Improve display of "esc" keybinding in the keybindings status bar by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;4819](jesseduffield/lazygit#4819)
- Use external diff command in stashes panel by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;4836](jesseduffield/lazygit#4836)
- Remove the git.paging.useConfig option by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;4837](jesseduffield/lazygit#4837)
- Don't auto-forward branches that are checked out in another worktree by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;4833](jesseduffield/lazygit#4833)
- Fix dropping range selection of filtered stashes by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;4849](jesseduffield/lazygit#4849)
- Fix rare crash in interactive rebase (merge command without comment) by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;4872](jesseduffield/lazygit#4872)
- Make it possible to rebind the Confirm keybinding by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;4860](jesseduffield/lazygit#4860)

##### Maintenance ⚙️

- Pass only Git-tracked Go files to gofumpt by [@&#8203;kyu08](https://github.com/kyu08) in [#&#8203;4809](jesseduffield/lazygit#4809)
- Update donation wording so that it's clear there's no strings attached by [@&#8203;jesseduffield](https://github.com/jesseduffield) in [#&#8203;4827](jesseduffield/lazygit#4827)
- Enhance MR/Issue templates readability by [@&#8203;kyu08](https://github.com/kyu08) in [#&#8203;4829](jesseduffield/lazygit#4829)
- Run label check workflow only on label events and open pr event by [@&#8203;kyu08](https://github.com/kyu08) in [#&#8203;4830](jesseduffield/lazygit#4830)

##### Docs 📖

- Add installation with gah by [@&#8203;marverix](https://github.com/marverix) in [#&#8203;4820](jesseduffield/lazygit#4820)
- docs(VISION): fix "Dicoverability" typo by [@&#8203;Rudxain](https://github.com/Rudxain) in [#&#8203;4866](jesseduffield/lazygit#4866)
- Add dev container feature as installation method to README by [@&#8203;HenningLorenzen-ext-bayer](https://github.com/HenningLorenzen-ext-bayer) in [#&#8203;4876](jesseduffield/lazygit#4876)

##### I18n 🌎

- Update translations from Crowdin by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;4873](jesseduffield/lazygit#4873)

#### New Contributors

- [@&#8203;marverix](https://github.com/marverix) made their first contribution in [#&#8203;4820](jesseduffield/lazygit#4820)
- [@&#8203;Kahitar](https://github.com/Kahitar) made their first contribution in [#&#8203;4822](jesseduffield/lazygit#4822)
- [@&#8203;cowboy8625](https://github.com/cowboy8625) made their first contribution in [#&#8203;4757](jesseduffield/lazygit#4757)
- [@&#8203;Rudxain](https://github.com/Rudxain) made their first contribution in [#&#8203;4866](jesseduffield/lazygit#4866)
- [@&#8203;HenningLorenzen-ext-bayer](https://github.com/HenningLorenzen-ext-bayer) made their first contribution in [#&#8203;4876](jesseduffield/lazygit#4876)

**Full Changelog**: <jesseduffield/lazygit@v0.54.2...v0.55.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS45Ny40IiwidXBkYXRlZEluVmVyIjoiNDEuOTcuNCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
@OliverJAsh
Copy link

@stefanhaller After migrating from externalDiffCommand to useExternalDiffGitConfig, I'm no longer able to selectively stage hunks/lines in files. Is that expected or a bug? For example this is what happens when I hit enter on a file:

Screen.Recording.2025-09-14.at.10.04.42.mov

@stefanhaller
Copy link
Collaborator Author

@OliverJAsh No, that's of course not expected, it's a silly bug. Please test the fix at #4895.

@rayluo How come you didn't notice this? Are you not actually using the feature yourself after all? (Not pointing fingers, I'm just surprised.)

@rayluo
Copy link

rayluo commented Sep 16, 2025

@rayluo How come you didn't notice this? Are you not actually using the feature yourself after all? (Not pointing fingers, I'm just surprised.)

  • Of course I AM using the useExternalDiffGitConfig: true. After all, this was a feature that I wanted for 5 years. I even added that config into my own dot-files repo since the release of lazygit 0.55, so I am always using it since then.
  • However, my test did not necessarily cover the "selectively stage hunks/lines in files" scenario. There are simply so many features in lazygit; I won't know which features would potentially be affected by useExternalDiffGitConfig: true, and I won't manually test all the lazygit features for the sake of testing. My test probably covered only the diff behavior itself.
  • That being said, I tested the "selectively stage hunks/lines in files" scenario just now. "hit enter on a file", and then hit a or space all work as expected on my machine (which is running a 64-bit Linux). So, I am not sure what issue you folks are talking about.
  • Last but not least, if a regression is considered too bad, I would suggest adding test cases into the code base. Currently, even the latest fix contains no test case. This regression might come back to bite us at a later time.

(Not making any excuse either. I am just equally surprised that this feature has a regression which I can't even reproduce; or perhaps I did not understand the bug report correctly.)

stefanhaller added a commit that referenced this pull request Sep 17, 2025
This new config was introduced in 0.55, but it made it impossible to
enter the staging view or custom patch building view.

Fixes
#4832 (comment).
@stefanhaller
Copy link
Collaborator Author

  • That being said, I tested the "selectively stage hunks/lines in files" scenario just now. "hit enter on a file", and then hit a or space all work as expected on my machine (which is running a 64-bit Linux). So, I am not sure what issue you folks are talking about.

It depends on the file type with your setup. Only those files that are covered by the "do-word-diff" diff driver will show the problem. Are you saying that it works even for those?

Anyway, no worries. Going to release a point update with the fix now.

@rayluo
Copy link

rayluo commented Sep 27, 2025

It depends on the file type with your setup. Only those files that are covered by the "do-word-diff" diff driver will show the problem. Are you saying that it works even for those?

Oh I see. Sorry my previous test did not cover that scenario. (For what it's worth, I was using the external diff for word diff effect, which is only useful for - thus only configured on - text files such as *.md and *.txt etc.; but I am not writing docs recently so I did not use "selectively stage hunks" for my .md files.)

I tested it just now. The 0.55.0 was indeed buggy and the 0.55.1 fixed it. Thanks again to you and the community for making lazygit better and better over time!

karolzwolak pushed a commit to karolzwolak/lazygit that referenced this pull request Sep 27, 2025
…esseduffield#4832)

### 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.
karolzwolak pushed a commit to karolzwolak/lazygit that referenced this pull request Sep 27, 2025
…duffield#4895)

This new config was introduced in 0.55, but it made it impossible to
enter the staging view or custom patch building view.

Fixes
jesseduffield#4832 (comment).
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.

4 participants