One of git's unavoidable quirks is its inability to store and retrieve metadata about a file. For example, on the mac, labels are stored with "extended attributes" (accessible with xattr
), and any checkout/reset/merge/pull command will erase those attributes if the file is affected by the checkout.
I've looked around to see if someone has written metadata-saving scripts already, but I came up dry.
So what I'd like to do is use Git's hook system to:
- Read extended attributes when files are committed,
- Write the attributes to a file stored in the repository that also gets committed,
- Apply the extended attributes to files that are modified in a merge/checkout/reset.
Which of the hooks should I use? Are post-receive
and pre-commit
all that I need? Can pre-commit
also add a file to the commit (i.e., after writing the new attributes)?