SuperBo / fugit2.nvim

Neovim git GUI powered by libgit2
MIT License
352 stars 7 forks source link

feature: reset a file/discard changes #11

Closed ceuk closed 4 months ago

ceuk commented 4 months ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

In other git TUI clients (e.g. lazygit) it's possible to press d on a file and have the option to "discard" staged/unstaged/all changes. This is a really useful feature. You can also do it per-line in a file in lazygit which is also handy.

Describe the solution you'd like

The ability to reset file changes or perform a checkout on a file

Describe alternatives you've considered

I don't think there are any

Additional context

No response

SuperBo commented 4 months ago

Because "d" is dedicated for "Diff" menu. I think I will need to bind this behaviour to "D" or "x" key.

SuperBo commented 4 months ago

Whole file discard is implemented via https://github.com/SuperBo/fugit2.nvim/pull/23. Now I need to implement per hunk discard.

jdrupal-dev commented 4 months ago

@SuperBo Cool, however this does not remove untracked (added) files. What about using https://libgit2.org/libgit2/#HEAD/group/reset/git_reset with reset_type = HARD?

SuperBo commented 4 months ago

Hi @jdrupal-dev, untracked files are files which is not managed by git. There are two cases here

So I think current behavior is safe and usable.

SuperBo commented 4 months ago

Hi, hunk/lines discard in unstaged patch view is enable via this patch https://github.com/SuperBo/fugit2.nvim/pull/24.

@ceuk, @jdrupal-dev , please help me confirm if it works for you.

ceuk commented 4 months ago

Seems to work great - the only thing I noticed is the selecting the no option looks a bit off

This is yes:

image

This is no:

image

SuperBo commented 4 months ago

@ceuk, another bug with UI :)). For now, you can press "y" to accept, "n" for no :D.

SuperBo commented 4 months ago

Fixed UI bug https://github.com/SuperBo/fugit2.nvim/commit/3b9a7799c6bee88d4436e1f5155635e1c6e0bfab.

Close this issue. Feel free to reopen if you find any other error @ceuk, @jdrupal-dev.