jesseduffield / jesseduffield/lazygit

Fallback to file-based approach for finding appropriate commit to amend

Open
#3,466 2 comments 0 reactions 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.**
I just had a situation where I had two commits on a branch (i.e. two ahead of the main branch) and one staged file which was included in the first of the two commits. The change to that file was in a separate part of the file (it was updating an import statement at the top of the file).

Upon trying to find the appropriate commit, I was told that multiple base commits were found, neither of which were my two branch commits.

**Describe the solution you'd like**
What I would like in this case is for lazygit to fall back to just looking to see if there is a single commit on the current branch which changed the staged file(s). If there are multiple such commits, we can just return an error, and if there is one such commit, we can show a confirmation popup saying something like 'We couldn't do a perfect match but we did find one commit which changed the staged files, jump to commit?' (I personally don't think the confirmation is necessary but I suspect you would want this @stefanhaller ).

**Additional context**
@stefanhaller we have definitely talked about this in the past, and we considered having a separate keybinding for taking the file-based approach, but in this case I didn't know ahead of time whether the patch-based approach would work or not (I assumed that it would), so now I think we should just extend the logic of the existing keybinding.

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.