jesseduffield / jesseduffield/lazygit

Mark commits which changed the selected file

Open
#2,653 1 comment 1 reaction 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.**
When I'm working on a branch locally, I might have five or so commits on my branch and I'll notice that I need to make a tweak to a file which was modified a few commits down. In order to find which commit I need to amend/fixup I often need to look at the commits themselves to see which files they've changed. This is laborious.

**Describe the solution you'd like**
When you select a file in the files panel, show in the commits panel which commits have changed the file.

There's a few UX things to consider:
### Speed
It's too expensive to look through the whole commit log to see which commits changed the file, so we'll need to limit the search somehow. There are a few options that come to mind:

* Check among the last X commits (e.g. 20). So only check within `HEAD~20..HEAD`. This is both fast and consistent, but means if you wanted to look back more than X commits you're out of luck
* Check the last X commits that changed the file. This can be slower than the prior option because git will keep looking until it finds X matches, or it reaches the root of the repo
* Perhaps some combination of the above? Do the first option to get a quick result and then merge it with the result from the second option?

The first option is all I need to satisfy my own use case.

### How to mark the commit

When icons are shown, we can swap out the icon for some other marker. For example (ignore my broken icons)
![image](https://github.com/jesseduffield/lazygit/assets/8456633/a22cc57d-9de7-4ad5-9006-4e5530fd411b)

We could be more specific and actually show what kind of change was made e.g. 'M', 'A', but we'd need to see how much slower that would make things.

### How to configure it
Should this only be invoked upon pressing some key on the file?
Should it be always-on, but toggleable from within Lazygit?
Should it be opt-in or opt-out in the config? I'm thinking opt-in at least while I test it: it might be a feature most users appreciate, but it's also potentially distracting if you don't need it while you flick through files in the files panel.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.