Yes, you can totally put more fields called “git commit extra headers” in
there. They’ll show up with git cat-file -p, but the only way I see to get them in there in the first place with the standard git client is by
editing the git source and recompiling.
In
commit.h,
there is a struct for extra headers, along with functions to add them when
committing, and to read them out later.
struct commit_extra_header {
struct commit_extra_header *next;
char *key;
char *value;
size_t len;
};
int commit_tree_extended(const char *msg, size_t msg_len,
const struct object_id *tree,
struct commit_list *parents,
struct object_id *ret, const char *author,
const char *sign_commit,
struct commit_extra_header *);
struct commit_extra_header *read_commit_extra_headers(struct commit *, const char **);
commit.c contains a list of ‘standard’ header fields:
static inline int standard_header_field(const char *field, size_t len)
{
return ((len == 4 && !memcmp(field, "tree", 4)) ||
(len == 6 && !memcmp(field, "parent", 6)) ||
(len == 6 && !memcmp(field, "author", 6)) ||
(len == 9 && !memcmp(field, "committer", 9)) ||
(len == 8 && !memcmp(field, "encoding", 8)));
}
with everything else showing up as an ‘extra’ header.
Doing a quick grep of the source code, the only current use I found of this
is the gpgsig header used to include GPG signatures on commits.
Kiln
Harmony,
now discontinued, used fields such as kilnhgusername and
kilnhgrawdescription here.
git help notesfor a way to attach arbitrary text to a commit.git hash-objectto create an object of any type (blob,tree,commit,tag) by hand, but you have to provide properly formatted input. I haven't looked into what kind of verificationhash-objectdoes on the various types of objects, and it's quite possible that it may reject a commit object that has extra headers. If that doesn't work, you can try to fake it by manuallyzlibcompressing a file with correct headers prepended and naming it appropriately to be part ofgits object database (based onsha1sum). That's quite low-level and brittle, though...