resolve_gitlink_ref(): avoid memory allocation in many cases