refs.c: make delete_ref use a transaction