jesseduffield / lazygit

simple terminal UI for git commands
MIT License
47.94k stars 1.72k forks source link

Make opening git difftool more consistent #3691

Closed part22 closed 2 days ago

part22 commented 6 days ago

The default shortcut to open git difftool (ctrl+t) is not available on the "Local Branches" window. It is available when selecting a commit from a local branch, a remote branch, or a tag from the "Local Branches" window.

This is inconsistent since branches or tags are also commits, the shortcut should also work on them directly.

This commit remedies this inconsistency by allowing the use of the shortcut directly on a branch or a tag. The shortcut works both in the "standard" mode and the "diffing" mode.

Current Behaviour New Behaviour
  1. Select a branch
  2. Press enter to see the commits
  3. Select the head commit
  4. Press ctrl+t to open git difftool
  1. Select a branch
  2. Press ctrl+t to open git difftool
before-change after-change
stefanhaller commented 5 days ago

I'm not convinced that this behavior makes sense when not in diffing mode. In diffing mode it works as expected, opening difftool with the same diff that I'm seeing in the main window, which is a nice addition.

But outside of diffing mode it opens difftool with the diff of the last commit of the selected branch or tag, which doesn't make sense to me. What do users expect to see in this case? I can see two possibilities:

I suppose I would prefer either the second of the options above (calling difftool with only one argument), or disabling the command when not in diffing mode.

Curious about your thoughts on this.

part22 commented 5 days ago

Hi Stefan,

I think you are right, it is more consistent to have the same behaviour as the command line. We should chose the solution that will be the least surprising to git users.

I have modfied the behaviour so it matches the behaviour of git difftool <somebranch>.

Thanks for your feedback!

stefanhaller commented 2 days ago

Great work, thanks for bearing with my nitpicking. Looks very good now, merging.