The patch produced by commands like
pijul diff and
pijul change is not the same as that produced by diff. I guess this is because pijul needs more information to apply the patch.
But if pijul supports output in the
diff format, then it would be easier to communicate with other version control systems, and perhaps to facilitate the integration in editors, such as Emacs.
What do you think? Is there already a plan for doing this that I missed?
After some more thinking, I guess the biggest problem is that pijul works with generalized files, instead of regular files.
Even though pijul represents the generalized files as plain files somehow on the file system, that representation is not “faithful”, that is, not injective. Of course this is so because every file is a generalized file, so if we can find an inverse to the ordinary inclusion from files to generalized files, then the two are actually equal, and the generalization generalizes nothing.
Moreover, I think this is related to the problem of translating a pijul repository to a git one and back. Since every file is a generalized file, and if we translate a pijul repository to a git repository, then the git history can only contain versions of ordinary files, we can never be sure if a version passed back from a git repository actually represented a generalized file.
Thus I am led to believe that neither the conversion to standard diff format or the conversion to git repository can be done bijectively. Maybe we need to do something different. What do you think?
I think using a common diff format is important to interface with existing tools. But with the current set of commands, can you even extract a file in any other state than what is in the working folder?
This is a bit hand-wavy, but I think you’re right, it can’t be bijective. It seems like a Git repo is a retract of a Pijul repo (and, equivalently(?), a (unified) diff is a retract of a Pijul patch). That is,
pijulFromGit :: Git -> Pijul has a left-inverse
gitFromPijul :: Pijul -> Git, which means that
gitFromPijul . pijulFromGit :: Git -> Git should produce the same Git repo you started with. However, the reverse composition (
pijulFromGit . gitFromPijul :: Pijul -> Pijul) is merely idempotent (you get the same result no matter how often you apply it, but it may not be the original input).
And then the same thing for conversions between patches and diffs.
That said, I think a surjective function
pijul diff --unified would be very useful. And the properties of those conversions can be tested to prevent (some) regressions in the conversions.