From a31cafaf2573a69eec5f4e6676a80878360502b0 Mon Sep 17 00:00:00 2001 From: Thomas Gazagnaire Date: Fri, 12 Jun 2015 11:15:21 +0100 Subject: [PATCH 1/5] Simplify the mirage sync API to use conduit 0.8.4 --- lib/mirage/git_mirage.ml | 56 +++++++++++++++++++-------------------- lib/mirage/git_mirage.mli | 4 +-- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/lib/mirage/git_mirage.ml b/lib/mirage/git_mirage.ml index 7801b577b..c17457d74 100644 --- a/lib/mirage/git_mirage.ml +++ b/lib/mirage/git_mirage.ml @@ -238,18 +238,18 @@ end module FIO = Cohttp_mirage_io.Make(Fchannel) (* hanlde the git:// connections *) -module Git_protocol (Conduit: Conduit_mirage.S) = struct +module Git_protocol = struct - module Flow = Conduit.Flow + module Flow = Conduit_mirage.Flow module Channel = Channel.Make(Flow) include IO_helper (Channel) - let with_connection (resolver, ctx) uri ?init fn = + let with_connection (resolver, conduit) uri ?init fn = assert (Git.Sync.protocol uri = `Ok `Git); Log.debug "Connecting to %s" (Uri.to_string uri); Resolver_lwt.resolve_uri ~uri resolver >>= fun endp -> - Conduit.endp_to_client ~ctx endp >>= fun client -> - Conduit.connect ~ctx client >>= fun (flow, _, _) -> + Conduit_mirage.client endp >>= fun client -> + Conduit_mirage.connect conduit client >>= fun flow -> let ic = Channel.create flow in let oc = Channel.create flow in Lwt.finalize @@ -264,23 +264,22 @@ module Git_protocol (Conduit: Conduit_mirage.S) = struct end (* hanlde the http(s):// connections *) -module Smart_HTTP (Conduit: Conduit_mirage.S) = struct +module Smart_HTTP = struct - module Conduit_channel = Channel.Make(Conduit.Flow) + module Conduit_channel = Channel.Make(Conduit_mirage.Flow) module HTTP_IO = Cohttp_mirage_io.Make(Conduit_channel) module Net = struct module IO = HTTP_IO - type ctx = { resolver: Resolver_lwt.t; ctx: Conduit.ctx; } - let sexp_of_ctx { resolver; ctx} = - Sexplib.Type.List [ - Resolver_lwt.sexp_of_t resolver; - Conduit.sexp_of_ctx ctx - ] - let default_ctx = { resolver = Resolver_mirage.localhost; ctx = Conduit.default_ctx } + type ctx = { resolver: Resolver_lwt.t; conduit: Conduit_mirage.t; } + let sexp_of_ctx { resolver; _ } = Resolver_lwt.sexp_of_t resolver + let default_ctx = { + resolver = Resolver_mirage.localhost; + conduit = Conduit_mirage.empty; + } let connect_uri ~ctx uri = Resolver_lwt.resolve_uri ~uri ctx.resolver >>= fun endp -> - Conduit.endp_to_client ~ctx:ctx.ctx endp >>= fun client -> - Conduit.connect ~ctx:ctx.ctx client >>= fun (flow, _, _) -> + Conduit_mirage.client endp >>= fun client -> + Conduit_mirage.connect ctx.conduit client >>= fun flow -> let ch = Conduit_channel.create flow in return (flow, ch, ch) let close_in _ = () @@ -324,12 +323,12 @@ module Smart_HTTP (Conduit: Conduit_mirage.S) = struct end -module Make (Conduit: Conduit_mirage.S) = struct +module IO = struct - module G = Git_protocol(Conduit) - module H = Smart_HTTP(Conduit) + module G = Git_protocol + module H = Smart_HTTP - type ctx = Resolver_lwt.t * Conduit.ctx + type ctx = Resolver_lwt.t * Conduit_mirage.t module Flow = struct type 'a io = 'a Lwt.t @@ -371,11 +370,11 @@ module Make (Conduit: Conduit_mirage.S) = struct type oc = Channel.t let with_connection ?ctx uri ?init fn = - let resolver, ctx = match ctx with + let resolver, conduit = match ctx with | Some x -> x | None -> - let { H.Net.resolver; ctx } = H.Net.default_ctx in - resolver, ctx + let { H.Net.resolver; conduit } = H.Net.default_ctx in + resolver, conduit in match Git.Sync.protocol uri with | `Ok `SSH -> failwith "GIT+SSH is not supported with Mirage" @@ -385,9 +384,9 @@ module Make (Conduit: Conduit_mirage.S) = struct let oc = `Git (G.Channel.to_flow oc) in fn (Channel.create ic, Channel.create oc) in - G.with_connection (resolver, ctx) ?init uri fn + G.with_connection (resolver, conduit) ?init uri fn | `Ok `Smart_HTTP -> - let ctx = { H.Net.resolver; ctx } in + let ctx = { H.Net.resolver; conduit } in let fn (ic, oc) = let ic = `HTTP (H.Channel.to_flow ic) in let oc = `HTTP (H.Channel.to_flow oc) in @@ -401,9 +400,8 @@ module Make (Conduit: Conduit_mirage.S) = struct end -module Sync (Conduit: Conduit_mirage.S) = struct - module M = Make (Conduit) - module IO = M +module Sync = struct + module IO = IO module Result = Git.Sync.Result - module Make = Git.Sync.Make(M) + module Make = Git.Sync.Make(IO) end diff --git a/lib/mirage/git_mirage.mli b/lib/mirage/git_mirage.mli index 737df2d1c..07753ef25 100644 --- a/lib/mirage/git_mirage.mli +++ b/lib/mirage/git_mirage.mli @@ -32,8 +32,8 @@ end module FS (FS: FS): Git.FS.S (** Create a Irmin store from raw block devices hanlder. *) -module Sync (Conduit: Conduit_mirage.S): sig - module IO: Git.Sync.IO with type ctx = Resolver_lwt.t * Conduit.ctx +module Sync: sig + module IO: Git.Sync.IO with type ctx = Resolver_lwt.t * Conduit_mirage.t module Result: (module type of Git.Sync.Result with type fetch = Git.Sync.Result.fetch and type push = Git.Sync.Result.push) From 84ec2216c67d4c8738216223ac55c154ac08d872 Mon Sep 17 00:00:00 2001 From: Thomas Gazagnaire Date: Fri, 12 Jun 2015 11:22:05 +0100 Subject: [PATCH 2/5] Clean up the opam file, run the tests in test mode, add a git.install file --- git.install | 4 ++++ opam | 36 ++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 git.install diff --git a/git.install b/git.install new file mode 100644 index 000000000..4e4bbc9a2 --- /dev/null +++ b/git.install @@ -0,0 +1,4 @@ +bin: [ + "?_build/bin/ogit.byte" {"ogit"} + "?_build/bin/ogit.native" {"ogit"} +] \ No newline at end of file diff --git a/opam b/opam index d24198fda..acbc400c5 100644 --- a/opam +++ b/opam @@ -10,31 +10,31 @@ build: [ ["./configure" "--prefix" prefix "--%{mirage-http+mirage-flow+mirage-types-lwt:enable}%-mirage" - "--%{mirage-fs-unix+alcotest:enable}%-tests" "--%{conduit+cohttp+base-unix:enable}%-unix" ] [make] ] -install: [make "install"] -remove: [ - ["ocamlfind" "remove" "git"] - ["rm" "-f" "%{bin}%/ogit"] +build-test: [ + ["./configure" "--enable-tests"] + [make "test"] ] +install: [make "install"] +remove: ["ocamlfind" "remove" "git"] depends: [ - "mstruct" {>= "1.3.1"} - "dolog" {>= "1.0"} + "cmdliner" + "mstruct" {>= "1.3.1"} + "dolog" {>= "1.0"} "ocamlgraph" - "camlzip" {>= "1.05"} - "nocrypto" {>= "0.2.0"} - "uri" {>= "1.3.12"} - "lwt" {>= "2.4.7"} + "camlzip" {>= "1.05"} + "nocrypto" {>= "0.2.0"} + "uri" {>= "1.3.12"} + "lwt" {>= "2.4.7"} "hex" - "alcotest" {test} - "mirage-fs-unix" {test & >="1.1.4"} + "alcotest" {test} + "mirage-fs-unix" {test & >="1.1.4"} "mirage-types-lwt" {test} - "cohttp" {test} - "conduit" {test} - "cmdliner" + "cohttp" {test} + "conduit" {test} ] depopts: [ "cohttp" @@ -44,7 +44,7 @@ depopts: [ "mirage-flow" ] conflicts: [ - "cohttp" {<= "0.15.0"} - "conduit" {< "0.6.0"} + "cohttp" {< "0.18.0"} + "conduit" {< "0.8.4"} ] available: [ocaml-version >= "4.01.0"] From 964282641d0677beeee1c8b53b46cc51e5991807 Mon Sep 17 00:00:00 2001 From: Thomas Gazagnaire Date: Fri, 12 Jun 2015 11:26:06 +0100 Subject: [PATCH 3/5] Clean up in CHANGES --- CHANGES.md | 69 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 45f75da69..cfae9650b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,5 @@ -# 1.5.0 +### 1.5.0 + * Change `ogit cat-file` to behave exactly as `git cat-file`. The previous command is renamed to `ogit cat` (#75 by @codinuum) * `ogit` now supports short hashes instead of full SHA1 (#75 by @codinuum) @@ -13,7 +14,8 @@ (#75 by @codinuum) * Support synchronisation for MirageOS unikernels (#70) -# 1.4.11 +### 1.4.11 + * Fix multi round-trips in the smart HTTP protocol. This fixes depth-limited clones (#71) and fetches. * Create the `git.http` library for abstracting away bits of the @@ -21,15 +23,18 @@ * Add `User-Agent` in the headers of the smart HTTP protocol. This makes `bitbucket.org` happy. (#66, patch from @vklquevs) -## 1.4.10 +### 1.4.10 + * Fix support for the smart HTTP protocol (report by @talex5, mirage/irmin#138) -## 1.4.9 +### 1.4.9 + * Remove the `OGITTMPDIR` and alway store temp files under `git/tmp` (mirage/irmin#132) -## 1.4.8 +### 1.4.8 + * Fix LRU cache: SHA1 should be unique in the cache (regression introduced in 1.4.3). This was causing confusing read results under load. @@ -37,7 +42,8 @@ * Fix a regression in `ogit cat-file` which were displaying nothing for small objects. -## 1.4.7 +### 1.4.7 + * Fix the filesystem updates for non-bare repositories (reported by @avsm) * `Git.write_index` now takes an optional `index` argument * Index entries should be fixed alphabetically @@ -46,19 +52,22 @@ configured by write calls, and the default is `OGITTMPDIR` if set, then `Filename.get_temp_dir_name` -- as it was in 1.4.5, see #51 -## 1.4.6 +### 1.4.6 + * Expose `Git.Value.Cache.set_size` to change the LRU cache size * Reduce the default LRU cache size (in 1.4.4 it was set to 64k, now it's 512) * More precise type for commit dates * Add `git.top` to load toplevel printers for Git values -## 1.4.5 +### 1.4.5 + * Support `packed-refs` files, to read references packed by `git gc` (reported by Gregory Tsipenyuk) * Fix the filesystem backend when TMPDIR is not on the same partition as the Git repository (#51, patch from @vklquevs) -## 1.4.4 +### 1.4.4 + * Support the smart HTTP Git protocol (#26) * Best-effort creation of files when expanding the index into the filesystem: Skip the invalid filenames and continue. Users are expected to sanitize @@ -75,7 +84,8 @@ * Expose zlib compression level (#41) * Maintain a cache of opened files (#29, Pierre Chambart) -## 1.4.3 (2014-12-19) +### 1.4.3 (2014-12-19) + * Fix regression introduced in 1.4.3 appearing when synchronising big repositories (#38) * Fix concurrent read/write by using an atomic rename (#35) @@ -92,23 +102,28 @@ to oasis (#5, Simon Cruanes) * Use `Bytes` instead of `String` (#5, Simon Cruanes) -## 1.4.2 (2014-12-14) +### 1.4.2 (2014-12-14) + * Fix `Git_unix.IO.write_file` to work on empty files -## 1.4.1 (2014-12-4) +### 1.4.1 (2014-12-4) + * Fix `ogit --version` (#22) * Expose the backend type * Expose Git_unix.Sync.IO -## 1.4.0 (2014-11-20): +### 1.4.0 (2014-11-20) + * Port to Conduit 0.6.0 API. * Depend on `ocaml-hex` -## 1.3.0 (2014-10-16) +### 1.3.0 (2014-10-16) + * Remove the dependency on `core_kernel` * Use `ocaml-nocrypto` instead of `ocaml-sha1` -## 1.2.0: (2014-06-10) +### 1.2.0: (2014-06-10) + * Can consume Mirage's `V1_LWT.FS` signature to generate a persistent store. This allows to store Git repos directly inside raw block devices (no need of filesystem anymore). @@ -117,7 +132,8 @@ independent of Unix. * Simplify the ocamlfind packages: there's only `git` and `git.unix`. -## 1.1.0: (2014-06-02) +### 1.1.0: (2014-06-02) + * Support for push (not optimized at all) * Fix the generation of `.dot` file representing the Git repo * Fix serialization of executable files in the cache @@ -126,15 +142,18 @@ * USe `ocaml-uri` to specify Git Remote Identifiers * Depend the implementation of patience diff in pure OCaml (unused for now) -## 1.0.2: (2014-04-19) +### 1.0.2: (2014-04-19) + * Catch, improve and propagate Zlib inflation errors (which usually pop-ups on incomplete files) -## 1.0.1: (2014-04-10) +### 1.0.1: (2014-04-10) + * Escape invalid chars in path names * Do not link with camlp4 when using as a libray -## 1.0.0: (2014-02-10) +### 1.0.0: (2014-02-10) + * Support for reading and writing pack indexes * Support for reading and writing pack files * Refactor the API: each Git object has now its own file, with a consistent @@ -146,18 +165,21 @@ * Add `ogit ls-files [--all]` * Support for reading and writing cache files -## 0.10.2: (2014-01-20) +### 0.10.2: (2014-01-20) + * Strip the contents of references file * Improve the pretty-printing of SHA1 values * Add some info message when reading files in the local backend -## 0.10.1: (2014-01-15) +### 0.10.1: (2014-01-15) + * Add missing files (fix build) * Add `GitTypes.S.mem_reference` * Add `GitTypes.S.remove_reference` * Add `GitTypes.S.mem` to check if an object exists in the store -## 0.10.0: (2014-01-14) +### 0.10.0: (2014-01-14) + * Support for in-memory stores * Add `ogit cat-file` * Add `ogit ls-remote` @@ -165,5 +187,6 @@ * Add `ogit clone` * Switch non-blocking IO using Lwt -## 0.9.0: (2014-01-04) +### 0.9.0: (2014-01-04) + * Initial release From ca541e579b16106f8ae134950fd58994326becd5 Mon Sep 17 00:00:00 2001 From: Thomas Gazagnaire Date: Fri, 12 Jun 2015 11:30:48 +0100 Subject: [PATCH 4/5] Add new CHANGES --- CHANGES.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index cfae9650b..40dbddbea 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ ### 1.5.0 -* Change `ogit cat-file` to behave exactly as `git cat-file`. +* Compatibility with `cohttp.0.18.` (#80 by @rgrinberg) +* Simplify the mirage sync API to use `conduit 0.8.4` (breaking API changes) +* Change `ogit cat-file` to behave exactly as `git cat-file` The previous command is renamed to `ogit cat` (#75 by @codinuum) * `ogit` now supports short hashes instead of full SHA1 (#75 by @codinuum) * Add `Git.Pack.Raw.read` to read raw pack files (#75 by @codinuum) From d51c49d76864407fdfeeed6cae0638a802dc5d6a Mon Sep 17 00:00:00 2001 From: Thomas Gazagnaire Date: Fri, 12 Jun 2015 11:31:03 +0100 Subject: [PATCH 5/5] Add release dates in CHANGES --- CHANGES.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 40dbddbea..214e84543 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -### 1.5.0 +### 1.5.0 (2015-06-12) * Compatibility with `cohttp.0.18.` (#80 by @rgrinberg) * Simplify the mirage sync API to use `conduit 0.8.4` (breaking API changes) @@ -16,7 +16,7 @@ (#75 by @codinuum) * Support synchronisation for MirageOS unikernels (#70) -### 1.4.11 +### 1.4.11 (2015-03-11) * Fix multi round-trips in the smart HTTP protocol. This fixes depth-limited clones (#71) and fetches. @@ -25,17 +25,17 @@ * Add `User-Agent` in the headers of the smart HTTP protocol. This makes `bitbucket.org` happy. (#66, patch from @vklquevs) -### 1.4.10 +### 1.4.10 (2015-02-05) * Fix support for the smart HTTP protocol (report by @talex5, mirage/irmin#138) -### 1.4.9 +### 1.4.9 (2015-02-04) * Remove the `OGITTMPDIR` and alway store temp files under `git/tmp` (mirage/irmin#132) -### 1.4.8 +### 1.4.8 (2015-02-04) * Fix LRU cache: SHA1 should be unique in the cache (regression introduced in 1.4.3). This was causing confusing read results @@ -44,7 +44,7 @@ * Fix a regression in `ogit cat-file` which were displaying nothing for small objects. -### 1.4.7 +### 1.4.7 (2015-02-03) * Fix the filesystem updates for non-bare repositories (reported by @avsm) * `Git.write_index` now takes an optional `index` argument @@ -54,21 +54,21 @@ configured by write calls, and the default is `OGITTMPDIR` if set, then `Filename.get_temp_dir_name` -- as it was in 1.4.5, see #51 -### 1.4.6 +### 1.4.6 (2015-01-29) * Expose `Git.Value.Cache.set_size` to change the LRU cache size * Reduce the default LRU cache size (in 1.4.4 it was set to 64k, now it's 512) * More precise type for commit dates * Add `git.top` to load toplevel printers for Git values -### 1.4.5 +### 1.4.5 (2015-01-19) * Support `packed-refs` files, to read references packed by `git gc` (reported by Gregory Tsipenyuk) * Fix the filesystem backend when TMPDIR is not on the same partition as the Git repository (#51, patch from @vklquevs) -### 1.4.4 +### 1.4.4 (2015-01-12) * Support the smart HTTP Git protocol (#26) * Best-effort creation of files when expanding the index into the filesystem: