jesseduffield / lazygit

simple terminal UI for git commands
MIT License
53.05k stars 1.85k forks source link

Apply patch from clipboard #3396

Open jesseduffield opened 7 months ago

jesseduffield commented 7 months ago

Is your feature request related to a problem? Please describe. We already have a couple ways of copying a patch to the clipboard:

But we don't have any keybindings for actually doing something with that patch once it's copied.

I had a use-case for this recently where I wanted to copy a patch from one repo to another (we were migrating to a monorepo). I had to apply the patch manually via pbpaste | git apply (works on mac).

Describe the solution you'd like I'm thinking this keybinding should live in the 'Patch options' menu, as an option labeled 'Apply patch from clipboard' (and 'Apply patch from clipboard in reverse'). Currently if custom patch mode is not active, we show an error rather than display the menu, so now we would instead just have that error appear as a disabled reason against each menu item that actually requires a custom patch.

To increase discoverability, we should add a tooltip to the file view's copy-diff-to-clipboard options mentioned above explaining how to go about applying the patch (i.e. press ctrl+p to bring up patch options menu and then select 'Apply patch from clipboard'). I also think we should add the file view's copy-diff-to-clipboard options to the patch options menu so that in order to satisfy the use case you only need to use one menu.

What do people think?

stefanhaller commented 7 months ago

A few thoughts:

mark2185 commented 7 months ago

but I feel without it the feature is not valuable enough

I beg to differ, "not able to apply a patch" vs "can apply patch (either am or apply) in reverse if need be" is a pretty big step up.

I don't have a good idea about providing the configuration of -p or --directory, sadly, but I do think it shouldn't be a part of the custom patch menu.

stefanhaller commented 7 months ago

I thought about this more during my morning run, some more thoughts: