read-cache: move shared add/checkout/commit code