I'd like to be able to invoke some pre-processing on files before Git tries to merge them, and the post-process the merged result. The general idea here is that some files are difficult to automatically merge as-is, but can be converted to an easier form for processing. Here's my concrete use case:
I have a repository of mostly not-very-sensitive data. Within that repository, I have a little bit of encrypted sensitive data, in a file called sensitive.pgp
. I like this arrangement because I don't have to trust that my repository is being managed securely, I just have to trust the encryption and the password. The catch of course it that Git can't possibly merge encrypted text, so if sensitive.pgp
is modified in two checkouts at once, there's no merging available -- even if the changes to the clear text are easily separated. The manual work-flow is like this:
- Merge conflict for
sensitive.pgp
detected. - Start git-mergetool. Tool fails to merge PGP files, too.
- Now I have temporary files for my version, the base version, and the remote version.
- Decrypt all three files.
- Invoke my merge tool on the decrypted versions.
- Encrypt the result.
- git-add the new
sensitive.pgp
.
I'd like to tell Git to apply my pre- and post-processing before it even tries to merge, so it can handle this automatically. I can imagine lots of other scenarios with the same general pattern: Pretty much any time you have a compressed file format with a text-like underlying structure (e.g. PDF, OpenOffice, Word), for example.
Any suggestions?