pygit2
pygit2 copied to clipboard
how to diff one file in working dir against a Blob?
pygit2 version python3-pygit2-0.23.3-2.fc23.x86_64
I cannot figure out how I can get a diff for only one file.
How do I arrange to have pygit2 return the diff of a Blob against the working dir file?
I looked at calling diff_to_working on a new Index(), but that fails because the new Index() does not self._repo filled in.
TreeBuilder() seems is unable to help as it requires putting tree objects into the repo to allow for the folder structure, for example to diff Source/file.py. needs a tree for Source. I clearly do not want to be writting files into the repo to do a diff.
Did I miss something in API?
There's git_diff_blob_to_buffer()
which lets you choose an arbitrary buffer and an arbitrary blob to compare.
But if you want to perform a diff but filter for a single file, the diff options allow you to pass in a list of pathspecs to limit the diff.
Neither of these have wrapped in pygit2 yet.
please consider this a request to wrap that API
An option to pass in a list of pathspecs to limit the diff would be a good feature to have 👍