write_ref_sha1(): move write elision test to callers