I'm trying to implement git add -p
in pygit2, so I can make an alternative frontend to it. So I need to be able to stage individual hunks, first and foremost.
I'm able to find the hunks by using diff_to_workdir
from the index, like this:
index.diff_to_workdir(0,1,1)[0].hunks
But I'm not sure exactly how to proceed from there. In fact, my intuition tells me that I don't stage things at all, but rather put together a commit myself and then hand it to the repo.
I have the sense that I ultimately need to be able to create a blob from the hunk and then use TreeBuilder to create a commit. But I just can't get there! It seems like I can only create blobs from files. Can anyone give a little guidance?