@@ -22,12 +22,12 @@ exception InternalGitError of string
2222let git_fs commitish =
2323 ( module struct
2424 open Git_unix
25- module Search = Git.Search. Make (FS )
25+ module Search = Git.Search. Make (Store )
2626
2727 let rev_parse r =
2828 SysAbst. pread " git" [|" rev-parse" ; r ^ " ^{commit}" |]
2929 >> = fun s ->
30- try Lwt. return @@ Git_unix.Hash_IO . of_hex @@ String. prefix s 40
30+ try Lwt. return @@ Store.Hash . of_hex @@ String. prefix s 40
3131 with _ -> Lwt. fail (InternalGitError (" cannot parse rev " ^ r))
3232
3333 let doc = " Git rev " ^ commitish
@@ -56,7 +56,13 @@ let git_fs commitish =
5656 in
5757 recurse @@ (Sys. getcwd () , [] )
5858
59- let fs = git_root >> = fun (root , _ ) -> FS. create ~root ()
59+ let fs =
60+ let % lwt root, _ = git_root in
61+ match % lwt Store. v (Fpath. v root) with
62+ | Ok s ->
63+ Lwt. return s
64+ | Error e ->
65+ Lwt. fail (InternalGitError (Fmt. strf " %a" Store. pp_error e))
6066
6167 let theref = rev_parse commitish
6268
@@ -72,30 +78,31 @@ let git_fs commitish =
7278 (InternalGitError
7379 (" path not found: /" ^ String. concat ~sep: Filename. dir_sep path))
7480 | Some sha -> (
75- match % lwt FS . read t sha with
76- | Some a ->
81+ match % lwt Store . read t sha with
82+ | Ok a ->
7783 action a
78- | None ->
79- Lwt. fail (InternalGitError " sha not found " ) )
84+ | Error e ->
85+ Lwt. fail (InternalGitError ( Fmt. strf " %a " Store. pp_error e) ) )
8086
8187 let get_content filename =
8288 with_path filename
8389 @@ function
84- | Git .Value.Blob b ->
85- Lwt. return (Git. Blob.to_raw b)
90+ | Store .Value.Blob b ->
91+ Lwt. return (Store.Value. Blob.to_string b)
8692 | _ ->
8793 Lwt. fail (InternalGitError " not a valid path" )
8894
8995 let find_file filter t =
90- let open Git.Tree in
91- t
92- |> List. filter ~f: (fun e -> filter e.name)
93- |> List. map ~f: (fun e -> (e.name, Git.Hash. to_hex e.node))
96+ let open Store.Value.Tree in
97+ to_list t
98+ |> List. filter_map ~f: (fun {name; node; _} ->
99+ if filter name then Some (name, Store.Hash. to_hex node) else None
100+ )
94101
95102 let list_files pattern =
96103 with_path []
97104 @@ function
98- | Git .Value.Tree t ->
105+ | Store .Value.Tree t ->
99106 Lwt. return @@ find_file pattern t
100107 | _ ->
101108 Lwt. fail (InternalGitError " not a tree!" )
0 commit comments