Skip to content

Commit

Permalink
Merge pull request #30 from samoht/master
Browse files Browse the repository at this point in the history
Minor API improvements
  • Loading branch information
samoht committed Dec 4, 2014
2 parents e5b9794 + 2fb227e commit 476eb68
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 54 deletions.
26 changes: 15 additions & 11 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
1.4.0 (2014-11-20):
## 1.4.1 (2014-12-4)
* Fix `ogit --version` (#22)
* Depend on ocaml-hex

## 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 @@ -15,7 +19,7 @@
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 @@ -25,15 +29,15 @@
* 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 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,
Expand All @@ -45,24 +49,24 @@
* 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
8 changes: 4 additions & 4 deletions _oasis
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OASISFormat: 0.4
Name: git
Version: 1.4.0
Version: 1.4.1
Synopsis: A low-level interface to Git in pure OCaml
Authors: Thomas Gazagnaire
License: ISC
Expand All @@ -13,7 +13,7 @@ Flag unix

Flag mirage
Description: build the Mirage library
Default: false
Default: true

Library git
Pack: true
Expand Down Expand Up @@ -57,8 +57,8 @@ Executable test_git
MainIs: test.ml
CompiledObject: best
Install: false
BuildDepends: alcotest, git, git.unix,
git.mirage, io-page.unix, mirage-fs-unix
BuildDepends: alcotest, git, git.unix, git.mirage,
io-page.unix, mirage-fs-unix

Test test_git
Run$: flag(tests) && flag(unix) && flag(mirage)
Expand Down
16 changes: 15 additions & 1 deletion _tags
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,18 @@ true: annot, bin_annot
<lib_test/*.ml{,i,y}>: use_git-unix
# OASIS_STOP
true: debug, bin_annot
<lib/*.ml{,i}>: pkg_sexplib.syntax
<lib/object.mli>: pkg_sexplib.syntax
<lib/SHA.ml>: pkg_sexplib.syntax
<lib/cache.ml>: pkg_sexplib.syntax
<lib/tag.ml>: pkg_sexplib.syntax
<lib/commit.ml>: pkg_sexplib.syntax
<lib/misc.ml>: pkg_sexplib.syntax
<lib/pack_index.ml{,i}>: pkg_sexplib.syntax
<lib/packed_value.ml{,i}>: pkg_sexplib.syntax
<lib/value.mli>: pkg_sexplib.syntax
<lib/pack.ml>: pkg_sexplib.syntax
<lib/tree.ml>: pkg_sexplib.syntax
<lib/user.ml>: pkg_sexplib.syntax
<lib/value.ml>: pkg_sexplib.syntax
<lib/object_type.ml>: pkg_sexplib.syntax
<lib/reference.ml>: pkg_sexplib.syntax
14 changes: 8 additions & 6 deletions bin/ogit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,14 @@ let clone = {
run begin
S.create ~root:dir () >>= fun t ->
printf "Cloning into '%s' ...\n%!" (Filename.basename (S.root t));
Sync.clone t ?deepen ~unpack ~bare remote >>= fun r ->
match r.Result.head with
| None -> return_unit
| Some head ->
S.write_cache t head >>= fun () ->
printf "HEAD is now at %s\n" (SHA.Commit.to_hex head);
Sync.clone t ?deepen ~unpack remote >>= fun r ->
if not bare then match r.Result.head with
| None -> return_unit
| Some head ->
S.write_cache t head >>= fun () ->
printf "HEAD is now at %s\n" (SHA.Commit.to_hex head);
return_unit
else
return_unit
end in
Term.(mk clone $ backend $ depth $ bare $ unpack $ remote $ directory)
Expand Down
2 changes: 2 additions & 0 deletions lib/FS.ml
Original file line number Diff line number Diff line change
Expand Up @@ -511,4 +511,6 @@ let write_cache t head =
printf "\rChecking out files: 100%% (%d/%d), done.%!\n" !all !all;
return_unit

let kind = `Disk

end
4 changes: 3 additions & 1 deletion lib/FS.mli
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ module type IO = sig
(** List the subfiles. *)

val rec_files: string -> string list Lwt.t
(** List of the subfiles, recursively. *)
(** [rec_files dir] is the list of the files recursively present in
[dir] and all of its sub-directories. Return filenames prefixed
by [dir]. *)

val read_file: string -> Cstruct.t Lwt.t
(** mmap a file and return a mutable C-like structure with its
Expand Down
8 changes: 4 additions & 4 deletions lib/META
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OASIS_START
# DO NOT EDIT (digest: 0816239473a08d14cba1a7b0dc361851)
version = "1.3.1"
# DO NOT EDIT (digest: 196f62903956d450a406a0cb4a574a8f)
version = "1.4.0"
description = "A low-level interface to Git in pure OCaml"
requires =
"mstruct dolog ocamlgraph zip nocrypto uri lwt conduit.lwt uri.services hex"
Expand All @@ -10,7 +10,7 @@ archive(native) = "git.cmxa"
archive(native, plugin) = "git.cmxs"
exists_if = "git.cma"
package "unix" (
version = "1.3.1"
version = "1.4.0"
description = "A low-level interface to Git in pure OCaml"
requires = "git lwt.unix conduit.lwt-unix"
archive(byte) = "git-unix.cma"
Expand All @@ -21,7 +21,7 @@ package "unix" (
)

package "mirage" (
version = "1.3.1"
version = "1.4.0"
description = "A low-level interface to Git in pure OCaml"
requires = "git mirage-types.lwt io-page"
archive(byte) = "git-mirage.cma"
Expand Down
6 changes: 5 additions & 1 deletion lib/git_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,12 @@ module D = struct
end

module Sync = struct
module IO = M
module Result = Sync.Result
module Make = Sync.Make(M)
end

module FS = Git.FS.Make(D)
module FS = struct
module IO = D
include Git.FS.Make(D)
end
14 changes: 8 additions & 6 deletions lib/git_unix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@

open Git

(** {2 Synchronisation primitives} *)

(** Implementation of the Git protocol using [Lwt_unix] and [Lwt_io]
IO functions. *)
module Sync: sig
module IO: Sync.IO
module Result: (module type of Sync.Result with type fetch = Sync.Result.fetch
and type push = Sync.Result.push)
module Make (S: Store.S): Sync.S with type t = S.t
(** Implementation of the Git protocol using [Lwt_unix] and [Lwt_io]
IO functions. *)
end

(** Filesystem. *)

module FS: FS.S
(** Implementation of the on-disk Git protocol. *)
(** Implementation of the on-disk Git protocol using [Lwt_unix]. *)
module FS: sig
module IO: FS.IO
include FS.S
end
2 changes: 2 additions & 0 deletions lib/memory.ml
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,5 @@ let read_cache _t =

let write_cache _t _head =
failwith "Memory.update_cache: TODO"

let kind = `Memory
3 changes: 3 additions & 0 deletions lib/store.mli
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,7 @@ module type S = sig
(** Update the cache of files for the given revision. XXX: need a
merge stategy. *)

val kind: [`Memory | `Disk]
(** The kind of backend. *)

end
18 changes: 4 additions & 14 deletions lib/sync.ml
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,6 @@ module Make (IO: IO) (Store: Store.S) = struct
fail (Failure ("TODO: " ^ msg))

type clone = {
bare : bool;
deepen: int option;
unpack: bool;
}
Expand Down Expand Up @@ -811,24 +810,15 @@ module Make (IO: IO) (Store: Store.S) = struct
Log.debugf "NEW OBJECTS";
printf "remote: Counting objects: %d, done.\n%!"
(List.length sha1s);
let bare = match op with
| Clone { bare } -> bare
| _ -> true in
if not bare then (
Log.debugf "EXPANDING THE FILESYSTEM";
return { Result.head = Some head; references; sha1s }
) else (
Log.debugf "BARE REPOSITORY";
return { Result.head = None; references; sha1s }
)
return { Result.head = Some head; references; sha1s }
)

let ls t gri =
fetch_pack t gri Ls >>= function
{ Result.references } -> return references

let clone t ?(bare=false) ?deepen ?(unpack=false) gri =
fetch_pack t gri (Clone { bare; deepen; unpack })
let clone t ?deepen ?(unpack=false) gri =
fetch_pack t gri (Clone { deepen; unpack })

let fetch t ?deepen ?(unpack=false) gri =
Store.list t >>= fun haves ->
Expand All @@ -844,6 +834,6 @@ module type S = sig
type t
val ls: t -> Gri.t -> SHA.Commit.t Reference.Map.t Lwt.t
val push: t -> branch:Reference.t -> Gri.t -> Result.push Lwt.t
val clone: t -> ?bare:bool -> ?deepen:int -> ?unpack:bool -> Gri.t -> Result.fetch Lwt.t
val clone: t -> ?deepen:int -> ?unpack:bool -> Gri.t -> Result.fetch Lwt.t
val fetch: t -> ?deepen:int -> ?unpack:bool -> Gri.t -> Result.fetch Lwt.t
end
2 changes: 1 addition & 1 deletion lib/sync.mli
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module type S = sig
val push: t -> branch:Reference.t -> Gri.t -> Result.push Lwt.t
(** Push a local branch to a remote store. *)

val clone: t -> ?bare:bool -> ?deepen:int -> ?unpack:bool -> Gri.t -> Result.fetch Lwt.t
val clone: t -> ?deepen:int -> ?unpack:bool -> Gri.t -> Result.fetch Lwt.t
(** [clone t address] clones the contents of [address] into the
store [t]. *)

Expand Down
2 changes: 1 addition & 1 deletion lib_test/test_mirage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module S = FS(M)

let suite =
{
name = "MIR-FS-unix";
name = "MIR-FS-mirage";
init = M.init;
clean = unit;
store = (module S);
Expand Down
8 changes: 4 additions & 4 deletions setup.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(* setup.ml generated for the first time by OASIS v0.4.1 *)

(* OASIS_START *)
(* DO NOT EDIT (digest: e4ba2fb3a416a01c4650b8e7cf43aa59) *)
(* DO NOT EDIT (digest: f8e9ea0b9e1a6e4220f3375faab839d4) *)
(*
Regenerated by OASIS v0.4.5
Visit http://oasis.forge.ocamlcore.org for more information and
Expand Down Expand Up @@ -6861,7 +6861,7 @@ let setup_t =
alpha_features = [];
beta_features = [];
name = "git";
version = "1.3.1";
version = "1.4.0";
license =
OASISLicense.DEP5License
(OASISLicense.DEP5Unit
Expand Down Expand Up @@ -6932,7 +6932,7 @@ let setup_t =
},
{
flag_description = Some "build the Mirage library";
flag_default = [(OASISExpr.EBool true, false)]
flag_default = [(OASISExpr.EBool true, true)]
});
Library
({
Expand Down Expand Up @@ -7219,7 +7219,7 @@ let setup_t =
};
oasis_fn = Some "_oasis";
oasis_version = "0.4.5";
oasis_digest = Some "ªF´brÐüãV\132\157i¶8²\138";
oasis_digest = Some "K¾8wz\016)Èq\015\140Ë\145\156\030Ò";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false
Expand Down

0 comments on commit 476eb68

Please sign in to comment.