I want a function that accepts two strings and generates a diff patch string, a la git diff foo
.
I am working on a wiki-style system with history. To implement history, I thought it would be effective to store document patch contents only, rather than full copies of each version of the document. Replaying patches seems like a nice way to reproduce any version of the document. git
already does this well. I want to use git's version control ability without creating a git index for every document, and instead using my database as a lesser capable version store.
I'm planning on using https://docs.rs/git2/latest/git2/index.html, but cannot figure out yet:
- how to create an empty, in mem git index
- load my document v1 into the git index
- diff my document v1 with document v2
- extract the patch file text
Any advice would be great! I'm tagging with libcgit2 as well, because despite using rust, I'm confident I could port C examples to the rust bindings.