pack_refs(): split creation of packed refs and entry writing