Re: Hacking git for managing machine readable "source" files
- From
Michael J Gruber <git@drmicha.warpmail.net>
- Date
- Oct 12, 2015, 08:07 UTC
- Message-ID
- <561B6A30.4060406@drmicha.warpmail.net>
- In-Reply-To
- <561B29DA.9050101@gna.org>
Christian Gagneraud venit, vidit, dixit 12.10.2015 05:32:
Show 14 quoted lines
> Hi git hackers, > > I have been scratching my head since quite a few weeks to see if and how > I could hack git to manage non-software-source-code files. Theses files > might be text-based (XML, JSON, custom format, ...) but are not intended > for humans, thus diffing and merging them using standard git features > doesn't really make sense (and so the whole "pack" stuff seems useless > as well). These files represent a non-software project developed using a > graphical SW application. I'm talking here about designing and > simulating electronic projects, but it could be apply to any sort of > engineering (mechanical design comes second to me) > > I would like to provide support for diffing, merging, branching and > forking such electronics projects.
[wall of text snipped]
I don't think you need to map the tree structure of your project to that of git's object store, nor am I sure you would benefit from it. (In case you do want to do it - look at the git-notes implementation.)
There are four handles in git's interface that you can use (and that have been used):
A) clean/smudge filters: They are meant to transform your working tree copy into a "standard/canonical form" which is stored in the repo (and back).
As an example, uncompressing compressed file formats, removing superfluous comments or time-stamps, sorting in default order (for unordered files) produces objects in the repo which are a better fit for packing and possibly also for git's default diff.
B) textconv filters: Possibly lossy filters that produce a human readable form of an object which possibly also lends itself to a meaningful git diff (but no way back). Can be cached.
C) external diff drivers: They are supposed to produce a meaningful diff in cases where textconv+default diff are not enough. They simply receive both objects to diff.
D) external merge drivers: They are supposed to merge (non-text) files that git cannot merge.
You'll find pointers in the manual pages for git-diff, git-merge and gitattributes.
Michael