It would be nice to have support for storing extended attributes in git-annex.
There are some useful proposed metadata attributes:
- user.xdg.comment: A comment specified by the user. This comment could be displayed by file managers
- user.xdg.origin.url: Set on a file downloaded from a url. Its value should equal the url it was downloaded from.
- user.xdg.origin.email.subject: Set on an email attachment when saved to disk. It should get its value from the originating message's "Subject" header
- user.xdg.origin.email.from: Set on an email attachment when saved to disk. It should get its value from the originating messsage's "From" header. For example '"John Doe" jdoe@example.com', or 'jdoe@example.com'
- user.xdg.origin.email.message-id: Set on an email attachment when saved to disk. It should get its value from the originating message's "Message-Id" header.
At least curl --xattr
saves xdg.origin.url
.
Perhaps git-annex-metadata
could be leveraged to automatically store and restore xattrs? Might even work that addition of xattrs would always have to be done through a git-annex command, but restoration would be done automatically if git-annex noticed there are xattrs stored in metadata, and the file system is mounted with user_xattr
.
The user
namespace is used for user xattrs and thus for "proposed metadata attributes" above. These attributes are valid git-annex metadata fields as-is.
I wrote a quick and dirty script to store xattrs in a git repo, because I wanted to keep my OSX labels and other metadata like resource forks in my annex. But it only works on OSX at the moment.
https://github.com/unqueued/git-xattr
I think maybe metadata storage would be best implemented as a hook.
I also would rather see this as a hook than built into git-annex. It's something that git-annex's metadata can be leveraged for, perhaps, but different use cases call for different amounts of data.
I suppose the thing to provide a hook into is whenever git-annex adds an object content to .git/annex/objects. That will allow the hook to store the current xattrs after
git annex add
, and to restore them after eggit annex get
.But, suppose you run:
git annex add file; git annex move file --to remote
Then the remote won't have the updated git-annex branch yet when it stores the object content, and so the hook run on it won't be able to do anything.When new git-annex branch version adds/changes xattr values, the local repository would need to be updated to reflect them. So, there would also need to be a hook that's run when git-annex metadata has changed.
See also: lockdown hooks which have different use cases, but seem to call for the same kind of hooks.