Let's say I want to write a small helper that allows to append some metadata to a repository in a way that can propagate to clones via refs
. Simple example (a git-notes clone prototype that doesn't even attach the notes to any other git object):
hash=$(echo "Just a comment" | git hash-object -w --stdin)
git update-ref refs/comments/just $hash
i.e. I create a blob
with hash hash
and refer to that as refs/comments/just
so git fsck --unreachable
won't complain about it and git gc
will never prune
the object.
But that is of course a very simple example, in reality I'm interested in more complex features. And there, my question is, what can I "legally" do and what should I absolutely refrain from?
As an example, several posts on SE were about users having to recover from duplicate tree
entries. So one "don't" is therefore "don't create a tree
with duplicate entries". Another example is "do make sure your objects are reachable, so git prune
won't remove them". What else?
Can I create a custom object type? Use "invalid" filemodes for blobs in trees? Where can I find an overview? Or should I check git-fsck
's source manually to see what constitutes errors (and which ones are ignore-able)?