comby icon indicating copy to clipboard operation
comby copied to clipboard

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

Open Dieterbe opened this issue 4 years ago • 7 comments

Hi, long time codemod user here. One thing that has always annoyed me in the workflow of hunk-by-hunk interactively accepting changes, is that afterwards, I still have to add all the changes to the index using git add -p which is also interactive. (I could do git add . but i often have changes i don't want to commit)

consider this a low-priority request, but it would be nice that whenever i interactively accept a change, it (and only that particular change i just agreed to apply) could also be added to the git index.

Dieterbe avatar Nov 18 '19 10:11 Dieterbe

Thanks for sharing your experience and workflow. I wasn't aware of this one and its valuable to know about! Should be straightforward so I'll see if I can add it in the next release :-)

rvantonder avatar Nov 19 '19 20:11 rvantonder

I'd like to contribute. Can I give it a try on this one? @rvantonder

diasbruno avatar Sep 06 '22 01:09 diasbruno

hi @diasbruno go for it! I haven't too deeply about it but I think the easiest is to add a new apply_patch_with_git analogous to the existing apply_patch function in interactive.ml. Then just add another option in the review menu that says something like "accept as git patch" (I think somewhere around this code in the same file)

rvantonder avatar Sep 06 '22 01:09 rvantonder

Great. I'll see what I can do. When the functionality is ready we can decide for the cli command.

diasbruno avatar Sep 06 '22 01:09 diasbruno

shouldn't need to do anything for CLI options, can just make it part of the review menu when -review is set (and can detect whether the directory is a git repository, all in interactive.ml)

rvantonder avatar Sep 06 '22 01:09 rvantonder

hmmm...-review looks great. I was think if it would conflict with -in-place.

diasbruno avatar Sep 06 '22 02:09 diasbruno

Totally misunderstood the -review flag...I thought it was a new feature. :joy:

Finally, I got sometime to implement this. sorry for taking so long.

diasbruno avatar Nov 16 '22 23:11 diasbruno