Persistent store with Git semantics: lazy reads, delayed writes, content-addressing
at perf 23 lines 793 B view raw
1(** Get command. *) 2 3let run ~repo ~branch ~output path = 4 let config = Config.load ~repo () in 5 let (module B : Common.BACKEND) = Common.backend_of_config config in 6 Eio_main.run @@ fun env -> 7 let fs = Eio.Stdenv.cwd env in 8 Eio.Switch.run @@ fun sw -> 9 let store = B.open_store ~sw ~fs ~config in 10 match B.checkout store ~branch with 11 | None -> 12 Common.error "Branch %a not found" Common.styled_cyan branch; 13 1 14 | Some tree -> ( 15 match B.tree_find tree (Common.path_of_string path) with 16 | None -> 17 Common.error "Path %a not found" Common.styled_cyan path; 18 1 19 | Some content -> 20 (match output with 21 | `Human -> print_string content 22 | `Json -> Fmt.pr {|{"path":%S,"content":%S}@.|} path content); 23 0)