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

Undoing patches #29

Open
amlwwalker opened this issue Jun 4, 2019 · 1 comment
Open

Undoing patches #29

amlwwalker opened this issue Jun 4, 2019 · 1 comment

Comments

@amlwwalker
Copy link

Hi
I am looking to use bsdiff to keep a record of the changes I make to a file. As I see it, I keep the original file and then I can keep patching all the diffs to that file to get to the current state of that file. However I have been wondering if I can go the other way around and if I have the current state of the file, can I "strip" off patches and get back to the original state of the file? I don't know if that reads sensically at all!
If I have a file, let's call them v0.x for example,
V0.1
V0.2
V0.3

Then bsdiff will give me the diffs between each version. If I then have v0.1 I can patch it twice to get to v0.3.
However if I have v0.3 is there a way I can patch it to get back to v0.2 and therefrom 0.1?
I have the diff between v0.2 and v0.3 but I guess that's not the same as having the diff of v0.3 and v0.2 is it?
I had wondered if there was a nifty XOR of the diff or something that could be done to go backwards??

I would appreciate any help you can give. Thanks

Alex

@nevercast
Copy link

nevercast commented Aug 19, 2019

Hello, an undo functionality is just creating patches that go in reverse. So when you create your diff, instead of using old, new, use new, old. This will give a diff that goes in reverse.

If however, you only have the patch files and you want to go backwards because you lost the old file, I don't know about that, which makes this comment not helpful. Good luck!

Edit: Assuming that bsdiff works anything like zdelta did, then no, because the patch file uses blocks of the old to reconstruct the new. If bsdiff does not use parts of the old file, then its still improbable that the old information is there. Since I'd suspect the patch file keeps pointers and run length + blocks to be written, but doesn't keep track of what was there previously (It would be size expensive to keep this redundent information).

So, after further thinking, I'd have to say its very likely not possible to create a reverse patch without the original file.

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

No branches or pull requests

2 participants