jesseduffield / lazygit

simple terminal UI for git commands
MIT License
48.05k stars 1.73k forks source link

Disable patch commands for commits on a different branch #3608

Open stefanhaller opened 1 month ago

stefanhaller commented 1 month ago

In the commits panel it is possible to show commits of all branches (by doing <c-l>, "Toggle show whole git graph"). You can then show the files of a commit that is not part of the current branch, build a custom patch from it, and then perform one of the commands

These will all fail with hard-to-understand errors. We should disable them when the commit is not part of the current branch (or the target commit, in case of "Move patch to selected commit").

Conversely, we may want to enable these commits if the patch was created from the branches panel, and the commit is part of the current branch. I'm not really sure this is useful, but it came up here and caused some confusion.

No matter what we decide about that last one, we should always include all commands in the menu, and strike out the ones that are not applicable, with tooltips explaining why.

stefanhaller commented 1 month ago

There are many other places in the code that rely on the assumption that all commits shown in the commits panel are part of the current branch. For example, <c-j> and <c-k> to move a commit up/down will fail with the same cryptic error when performed on a commit that's on a different branch.