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: accept hunks and stage selected changes on git... #350

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

diasbruno
Copy link

using the -review we can interactively select
which changes we will accept.

a new option is added to allow users to accept
the patch and also automatically stage the changes (currently only git is supported).

closes #134

using the -review we can interactively select
which changes we will accept.

a new option is added to allow users to accept
the patch and also automatically stage the changes
(currently only git is supported).
@rvantonder
Copy link
Member

@diasbruno I gave this a try and looks good to me! If you're done making changes just let me know or request review, and I can go ahead with merge

@diasbruno
Copy link
Author

diasbruno commented Nov 17, 2022

There are a few cases I still need to check. Depending on whether the file is already versioned or not, the patch fails, and, some cases depending on the status of the file in the working tree.

If the file is not on the git tree, we may need to fallback to just do a normal patch, or, check it before presenting the option (remove the "g" option if the file isn't on git).

>>= fun status ->
match status with
| Lwt_unix.WEXITED x -> Lwt_io.printf "[debug] %d\n" x |> ignore; return (x == 0)
| _ -> return false
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rvantonder is it too much trouble to do this check?
It still not complete, need to check if the command is ok (if the git command fails because it doesn't exist or something...).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ok.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems reasonable! does this command work for all kinds of shells? bash / sh / zsh?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test is from coreutils, so it must be everywhere, except windows, maybe...

when applying to the stage area, if the file
is not already commited on the repository
the patch will fail.

we show the option only if the file
is already commited.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"git add -p" upon acceptance of a change with -review
2 participants