Fix up "for_each_ref()" to be more usable, and use it in git-fsck-cache