refs.c: move dwim_ref()/dwim_log() from sha1_name.c