jesseduffield / lazygit

simple terminal UI for git commands
MIT License
52.65k stars 1.84k forks source link

Searching by commit hash does not bring results #2862

Closed megasuperlexa closed 4 months ago

megasuperlexa commented 1 year ago

Topic Searching by commit hash does not bring results

Your thoughts I want lazygit to somehow do the same as git show command. I thought I should go to commits window and press / there, then commit hash. But this doesnt seem to work. git show a2c23fe1beec88637e81d05cc5814c2d0d72d232 works fine. Am I missing something?

stefanhaller commented 1 year ago

Searching by sha in the commits view does work if you keep two things in mind:

  1. it only searches what's displayed in the view, which means that searching for the whole sha won't find it. Searching for just the first 8 characters does.
  2. by default it only loads the first 300 commits, so if your sha isn't among those, it won't find it either. You can press > to jump to the end and force it to load the remaining commits; then it will find every sha.
jesseduffield commented 1 year ago

For the record, if we had filtering support in the commits view, you could paste in the whole hash, because filtering is not looking at the view itself but looking at the underlying model.

This is an annoying mismatch in behaviour. I would like to either update the search functionality so that it stops looking at the view itself, or just use filtering everywhere. To be honest, I'm leaning towards the latter for the sake of consistent UX. We already filter down the commits view when you're filtering path by path via lazygit -f <path> so there's a precedent for it. I know that searching is better for seeing a commit in context but you can always hit escape to see the surrounding commits again.

On a separate note, it seems like various git UIs offer a specific action to jump to a commit hash, so perhaps we should provide that as its own thing. I'd prefer to just use the filtering logic but there are some benefits to having a separate action, for example not trying to filter the list as the hash is typed in / pasted.

stefanhaller commented 1 year ago

I was planning to look into searching using the model instead of the view as a prerequisite to https://github.com/jesseduffield/lazygit/pull/2533. Just didn't get around to it yet.

I'm still pretty convinced that jumping from hit to hit is the better UI in the commits window so that you can see the context for each hit, and especially also see the graph, which we would probably need to disable when filtering (we do when filtering by path). If you really want to change that, I'd lobby for a config option.

stefanhaller commented 4 months ago

As of #3642, searching for a full commit hash now works.