re-apply commit e0b3105 (write tree fragment string, not pointer)