GithubHelp home page GithubHelp logo

craigfe / ocaml-git Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mirage/ocaml-git

0.0 2.0 0.0 9.99 MB

Pure OCaml Git format and protocol

License: ISC License

Makefile 0.01% OCaml 99.99%

ocaml-git's Introduction

ocaml-git -- Git format and protocol in pure OCaml

Support for on-disk and in-memory Git stores. Can read and write all the Git objects: the usual blobs, trees, commits and tags but also the pack files, pack indexes and the index file (where the staging area lives).

All the objects share a consistent API, and convenience functions are provided to manipulate the different objects. For instance, it is possible to make a pack file position independent (as the Zlib compression might change the relative offsets between the packed objects), to generate pack indexes from pack files, or to expand the filesystem of a given commit.

The library comes with some command-line tools called ogit-* as a Proof-of-concept of the core library which shares a similar interface with git, but where all operations are mapped to the API exposed ocaml-git (and hence using only OCaml code). However, these tools are not done to be use. They are just examples of how to use ocaml-git.

The API documentation is available online.

Build Status

Build and Install Instructions

To build and install the project, simply run:

$ opam install git

What is supported

  • The loose object files can be read and written;

  • The pack files (collections of compressed loose objects using a binary-diff representation) and pack indexes (indexes of pack files) can be read and written). The binary diff hunks are exposed using a high-level position-independent representation so that they can be manipulated more easily. Pack file can be created and is compressed.

  • The index file (used as for managing the staging area) are fully supported. Which means that git diff and git status will work as expected on a repository created by the library.

  • Cloning and fetching (using various options) are fully supported for the Git protocol, the smart-HTTP protocol and git+ssh. A subset of the protocol capabilities are implemented (mainly thin-pack, ofs-delta, side-band-64k and allow-reachable-sha1-in-want).

  • Pushing is still experimental and needs more testing.

  • An abstraction for Git Store Is available. Various store implementations are available:

What is not supported

  • No server-side operations are currently supported.
  • No GC.
  • Updates, merge and rebase are not supported. Use irmin instead.

Performance

Performance is comparable to the Git tool.

Example

# #require "git.unix";;
# open Git_unix;;
# module Search = Git.Search.Make(FS);;

# let read filename =
    let open Lwt_result.Infix in
    Store.v (Fpath.v ".") >>= fun t ->
    Store.Ref.resolve Store.Reference.master >>= fun head ->
    let open Lwt.Infix in
    Search.find t head (`Commit (`Path filename)) >|= function
    | None -> Lwt.return (Error `Not_found)
    | Some hash -> Store.read t hash
val read : string list -> (Store.Value.t, Store.error) Lwt_result.t
    
# let pp =
    let ok ppf = function
      | Store.Value.Blob blob ->
        Fmt.string ppf (Store.Value.Blob.to_string blob)
      | _ -> Fmt.string ppf "#git-object" in
    Fmt.pp_result ~ok ~error:Store.pp_error
val pp : (Store.Value.t, Store.error) Fmt.t

# Lwt_main.run Lwt.Infix.(read [ "README.md" ] >|= pp Fmt.stdout)

ocaml-git -- Git format and protocol in pure OCaml

Support for on-disk and in-memory Git stores. Can read and write all
the Git objects: the usual blobs, trees, commits and tags but also
the pack files, pack indexes and the index file (where the staging area
lives).

[...]

License

MIT, see LICENSE.md file for its text.

ocaml-git's People

Contributors

samoht avatar dinosaure avatar codinuum avatar yomimono avatar avsm avatar talex5 avatar yallop avatar olleolleolle avatar hannesm avatar smeruelo avatar rgrinberg avatar g2p avatar vklquevs avatar clecat avatar chris00 avatar jnavila avatar altgr avatar chambart avatar xandkar avatar vbmithr avatar waldyrious avatar zshipko avatar linse avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.