Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Discard changes to work tree #38

Open
Piturnah opened this issue Jul 10, 2023 · 2 comments
Open

Feature: Discard changes to work tree #38

Piturnah opened this issue Jul 10, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@Piturnah
Copy link
Owner

Would be cool to be able to press d to discard changes to a hunk or file. I really think this should have a confirmation though, at least by default.

@Piturnah Piturnah added the enhancement New feature or request label Jul 10, 2023
@Piturnah Piturnah changed the title Feature: Discard changes Feature: Discard changes to work tree Jul 10, 2023
@Piturnah
Copy link
Owner Author

Note: this is essentially gonna be resetting the changes to HEAD, I believe

@Piturnah
Copy link
Owner Author

Ok, so it looks like Git does not support directly resetting a particular hunk. I have a proposed workaround for this, but it could be risky if it doesn't work as I expect under some edge cases.

Option 1

Under the hood, when you go to reset a hunk, gex can:

  1. Stage everything other than the selected hunk
  2. Commit
  3. Reset hard to HEAD
  4. Reset --soft to the previous commit

While typing this out I just though already of a super common case where this won't work: the case where you already have some hunks/files staged. Ugh. Leaving here just in case I think of a way to include that case

Option 2

We find some way to do this using libgit since we are already depending on it anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant