refs.c: change update_ref to use a transaction