Skip to content

Commit

Permalink
Merge pull request #82 from samoht/master
Browse files Browse the repository at this point in the history
Use conduit 0.8.4 API to simplify the Mirage sync API and prepare the release
  • Loading branch information
samoht committed Jun 12, 2015
2 parents 7c22215 + d51c49d commit eb580a7
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 73 deletions.
73 changes: 49 additions & 24 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 1.5.0
* Change `ogit cat-file` to behave exactly as `git cat-file`.
### 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)
* 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)
Expand All @@ -13,31 +16,36 @@
(#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.
* Create the `git.http` library for abstracting away bits of the
smart HTTP protocol.
* 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
under load.
* Reading objects now updates the LRU cache
* 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
* Index entries should be fixed alphabetically
Expand All @@ -46,19 +54,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 (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:
Skip the invalid filenames and continue. Users are expected to sanitize
Expand All @@ -75,7 +86,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)
Expand All @@ -92,23 +104,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).
Expand All @@ -117,7 +134,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
Expand All @@ -126,15 +144,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
Expand All @@ -146,24 +167,28 @@
* 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`
* Add `ogit fetch`
* Add `ogit clone`
* Switch non-blocking IO using Lwt

## 0.9.0: (2014-01-04)
### 0.9.0: (2014-01-04)

* Initial release
4 changes: 4 additions & 0 deletions git.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bin: [
"?_build/bin/ogit.byte" {"ogit"}
"?_build/bin/ogit.native" {"ogit"}
]
56 changes: 27 additions & 29 deletions lib/mirage/git_mirage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 _ = ()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions lib/mirage/git_mirage.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
36 changes: 18 additions & 18 deletions opam
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]

0 comments on commit eb580a7

Please sign in to comment.