refs: introduce an iterator

This allows us to get a list of reference names in a loop instead of callbacks.
refdb_fs: don't crash when the repo doesn't have a path
Make sure the ref iterator works in an repo without physical presence