Encoding Metadata in a Git Repository
A fairly cheap kludge to encode metadata into a Git repository would use special directories that link to the files that need metadata. (I suggest prefixing the directory names with "...", as that is ignored by default in some popular OS shells.)
An example of this is probably easier. Say we have jenkins.our-config and git.our-hooks in our repo configuration:
configuration
jenkins.our-config
git.our-hooks
We want to include that both files are about our production server. If we set up a directory structure in the repo like this:
configuration
jenkins.our-config
git.our-hooks
...server=production
jenkins.our-config
git-our-hooks
with jenkins.our-config and git.our-hooks as links, then:
- Those files are not duplicated in the working tree;
- Those files are the same blob in the Git database (as they are links);
- Users do not ordinarily see ...server=production; and
- The metadata about those files (server=production) is encoded directly into the Git repository.
If you are on a filesystem without links, then you will have duplicate content in your working tree (but not in the database, as the blobs for jenkins.our-config and git.our-hooks are identical between configuration and configuration/...server=production). In that case, you could use a Git pre-commit hook to update the copies of the files in the special directories so they match the normal working files.
As I said, this is a kludge, but it would (a) work and (b) require little magic.
Leave a comment