Skip to content

Unstage hunk #510

@rehno-lindeque

Description

@rehno-lindeque

Is your feature request related to a problem? Please describe.
I regularly use git reset --patch as the inverse of git add --patch and need to do this manually right now.

Describe the solution you'd like
It would be great if I could map <leader>hu to an unstage_hunk function instead of undo_stage_hunk which is limited to the last hunk that was staged.

Describe alternatives you've considered

  • At first I expected that undo_stage_hunk to match git reset --patch, but of course this is not the case.
  • I believe reset_hunk is effectively a --hard git reset, or git checkout --patch.
  • reset_buffer_index unstages everything in the buffer which is usually not what I want

So I normally use :!git reset -p % which is more time consuming.

Additional context

  • It's easy for me to understand the behavior of an unstage_hunk function because I frequently use git reset -p. However I expect it would be more clear to others if secondary signs as described in Sec #303 and Add signs for staged hunks #440. I expect that unstage_hunk would effectively operate on hunks indicated by secondary signs.

  • Adding an optional range argument, similar to the range argument in stage_hunk(range) would also be handy. I've often found it difficult to edit patches with git reset --patch, so I'm not sure if this would be tricky to implement in practice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions