A command like git-annex oldkeys $file that lists the keys used for all previous versions of the file.

It would allow a workflow like eg:

edit foo
git-annex add foo
git commit -m new\ foo
git-annex oldkeys foo | git-annex move --batch-keys --to bar

Or this, to send someone the current version of a file, and also all old versions:

git-annex copy foo --to baz
git-annex oldkeys foo | git-annex copy --to baz

Or like this:

git-annex oldkeys foo | git-annex get --batch-keys
# proceed to diff between old versions of the file 
# (although git-annex-diffdriver --get is another way to do this)

Or this to make every old version visible as files to flip through in a slideshow:

n=0
for k in $(git-annex oldkeys my.gif); do
    $n=$(expr $n + 1)
    ln -s $(git-annex examinkey $k --format='${objectpath}') my.$n.gif
done

Is oldkeys the best name for this? git-annex log is already taken.

Since this would be implemented on top of git log --raw, it would be possible to support multiple files at once, or whole directories.

If an old key is the same as the current key, should it list the old key or not? If it did, then the move example above would move the current version of the file away. And there are tricky cases involving renames and reverts. So it seems that it ought to avoid ever listing a key currently used by the file(s) it is run on as an old key.

done --Joey