{"id":13726133,"url":"https://github.com/mirage/ocaml-git","last_synced_at":"2025-04-08T01:37:10.117Z","repository":{"id":7402724,"uuid":"8733116","full_name":"mirage/ocaml-git","owner":"mirage","description":"Pure OCaml Git format and protocol","archived":false,"fork":false,"pushed_at":"2025-02-27T17:04:13.000Z","size":13841,"stargazers_count":364,"open_issues_count":19,"forks_count":69,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-04-01T00:35:14.188Z","etag":null,"topics":["git","ocaml"],"latest_commit_sha":null,"homepage":"","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jingtao910429/RYTableFormList","license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mirage.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-03-12T16:54:35.000Z","updated_at":"2025-02-27T17:04:14.000Z","dependencies_parsed_at":"2023-09-28T11:27:57.698Z","dependency_job_id":"d3478ac0-7d8d-41dc-abbd-c02252560681","html_url":"https://github.com/mirage/ocaml-git","commit_stats":{"total_commits":2276,"total_committers":43,"mean_commits":52.93023255813954,"dds":0.4692442882249561,"last_synced_commit":"fd2b5c8b4125fa9091b1e51eb9082395f20af9f9"},"previous_names":[],"tags_count":92,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirage%2Focaml-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirage%2Focaml-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirage%2Focaml-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirage%2Focaml-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mirage","download_url":"https://codeload.github.com/mirage/ocaml-git/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247761050,"owners_count":20991531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","ocaml"],"created_at":"2024-08-03T01:02:53.557Z","updated_at":"2025-04-08T01:37:10.094Z","avatar_url":"https://github.com/mirage.png","language":"OCaml","funding_links":[],"categories":["OCaml","System Programming"],"sub_categories":[],"readme":"## ocaml-git -- Git format and protocol in pure OCaml\n\nSupport for on-disk and in-memory Git stores. Can read and write all the Git\nobjects: blobs, trees, commits and tags. It can also handle pack files, pack\nindexes and index files (where the staging area lives - only for `git-unix`\npackage).\n\nAll the objects share a consistent API, and convenience functions are provided\nto manipulate the different objects. For instance, it is possible to make a pack\nfile position independent (as the Zlib compression might change the relative\noffsets between the packed objects), to generate pack indexes from pack files,\nor to expand the filesystem of a given commit.\n\nThe library comes with some command-line tools called `ogit-*` as a\nProof-of-concept of the core library which shares a similar interface with\n`git`, but where all operations are mapped to the API exposed by `ocaml-git` (and\nhence using only OCaml code). However, these tools are not meant to be used. They\nare just examples of how to use `ocaml-git`.\n\n`ocaml-git` wants to be a low-level library for [irmin][irmin]. By this fact,\nhigh-level commands such as a ([patience][patience-diff]) diff, `git status`,\netc. are not implemented.\n\nAs a MirageOS project, `ocaml-git` is system agnostic. However, it provides a\n`git-unix` package which uses UNIX _syscall_ and is able to introspect a usual Git\nrepository in a filesystem. However, `ocaml-git` handles only Git objects\nand does not _populate_ your filesystem as `git` does. For example, `Git_unix.Sync.fetch` \ndoes not give you files fetched from the repository but only synchronizes `.git` with \nthat repository.\n\nThe API documentation is available [online][documentation].\n\n[![Build Status](https://travis-ci.org/mirage/ocaml-git.svg?branch=master)](https://travis-ci.org/mirage/ocaml-git)\n\n### Build, Install Instructions and Packages\n\nTo build and install the project, simply run:\n```sh\n$ opam install git\n$ opam install git-unix\n$ opam install git-mirage\n```\n\n### _Linking-trick_\n\n`ocaml-git` uses 2 libraries with the linking-trick:\n* [digestif][digestif]\n* [checkseum][checkseum]\n\nThese libraries provide a C implementation and an OCaml implementation (mostly\nto be compatible with `js_of_ocaml`). However, `utop` or any a build-system such\nas `ocamlbuild` are not able to choose between these implementations. So, you\nmust __explicitely__ choose one.\n\nThese libraries use [virtual-library][virtual-library] available with `dune`. If\nyour build-system is `dune`, you should not have any problem about that where\n`dune` is able to take the _default_ implementation of these libraries.\n\n### What is supported\n\n* The loose object files can be read and written;\n  - [blobs][blob] (files)\n  - [trees][tree] (directories)\n  - [commits][commit] (revision history)\n  - [tags][tag] (annotated tags)\n  - [references][reference] (branch names)\n\n* The [PACK files][pack-file] (collections of compressed loose objects using a\n  binary-diff representation) and [PACK indexes][pack-index] (indexes of pack\n  files) can be read and written). The binary diff hunks are exposed using a\n  high-level position-independent representation so that they can be manipulated\n  more easily. Pack file can be created and is compressed.\n\n* The [INDEX file][index] (used as for managing the staging area) are fully\n  supported, which means that `git diff` and `git status` will work as expected\n  on a repository created by the library. This feature is only available for\n  `git-unix` when it needs to introspect a file-system.\n\n* [Cloning and fetching][git-sync] (using various options) are fully supported\n  for the Git protocol, the smart-HTTP protocol and `git+ssh`. A subset of the\n  protocol capabilities are implemented (mainly `thin-pack`, `ofs-delta`,\n  `side-band-64k` and `allow-reachable-sha1-in-want`).\n\n* Pushing is still experimental and needs more testing.\n\n* An abstraction for Git [Store][git-store]\n  Is available. Various store implementations are available:\n  - An [in-memory][git-store-memory] implementation;\n  - A [unix filesystem][git-store-unix] implementation;\n\n### What is *not* supported\n\n* No server-side operations are currently supported.\n* No GC.\n* Updates, merge and rebase are not supported. Use [irmin][irmin] instead.\n\n### Performance\n\nPerformance is comparable to the Git tool.\n\n### Example\n\nThis `utop` example must run into the `ocaml-git` repository when the given path\nis `.`.\n\n```ocaml\n# ;; load necessary modules\n# #require \"checkseum.c\" ;;\n# #require \"digestif.c\" ;;\n# #require \"git-unix\" ;;\n\n# ;; we are going to use this project's local repository\n# module Store = Git_unix.Store ;; \nmodule Store = Git_unix.Store\n\n# ;; this module is useful for finding git objects in a git store\n# module Search = Git.Search.Make (Digestif.SHA1) (Store) ;;\nmodule Search :\n  sig\n    type hash = Store.hash\n    type store = Store.t\n    type pred =\n        [ `Commit of hash\n        | `Tag of string * hash\n        | `Tree of string * hash\n        | `Tree_root of hash ]\n    val pred : store -\u003e ?full:bool -\u003e hash -\u003e pred list Lwt.t\n    type path =\n        [ `Commit of path | `Path of string list | `Tag of string * path ]\n    val mem : store -\u003e hash -\u003e path -\u003e bool Lwt.t\n    val find : store -\u003e hash -\u003e path -\u003e hash option Lwt.t\n  end\n\n# ;; we want to read the contents of a blob under name [filename]\n# let read filename =\n  let open Lwt_result.Syntax in\n  (* get store located in current root's .git folder *)\n  let* store = Store.v (Fpath.v (Sys.getcwd ())) in\n  (* find obj-id pointed at by main branch (reference) *)\n  let* commit_id = Store.Ref.resolve store Git.Reference.main in\n  let open Lwt.Syntax in\n  (* find obj-id of of [filename] as a git blob *)\n  let* blob_id = Search.find store commit_id (`Commit (`Path [ filename ])) in\n  match blob_id with\n  | None -\u003e Lwt.return (Error (`Not_found commit_id))\n  | Some hash -\u003e\n      (* read contents of the blob *)\n      Store.read store hash\n  ;;\nval read : string -\u003e (Store.Value.t, Store.error) Lwt_result.t = \u003cfun\u003e\n\n# let pp =\n  let ok ppf = function\n    | Git.Value.Blob b -\u003e Fmt.string ppf (Git.Blob.to_string b)\n    | _ -\u003e Fmt.string ppf \"#git-object\"\n  in\n  Fmt.result ~ok ~error:Store.pp_error;;\nval pp : ('_weak1 Git.Value.t, Store.error) result Fmt.t = \u003cfun\u003e\n\n# Lwt_main.run Lwt.Infix.(read \"README.md\" \u003e|= pp Fmt.stdout) ;;\n\nocaml-git -- Git format and protocol in pure OCaml\n\nSupport for on-disk and in-memory Git stores. Can read and write all\nthe Git objects: the usual blobs, trees, commits and tags but also\nthe pack files, pack indexes and the index file (where the staging area\nlives).\n\n[...]\n```\n\n()\n\n### License\n\nMIT, see [LICENSE.md][LICENSE.md] file for its text.\n\n[documentation]: http://mirage.github.io/ocaml-git/\n[irmin]: https://github.com/mirage/irmin\n[patience-diff]: https://git-scm.com/docs/git-diff\n[digestif]: https://github.com/mirage/digestif\n[checkseum]: https://github.com/mirage/checkseum\n[virtual-library]: https://dune.readthedocs.io/en/stable/variants.html\n[blob]: http://mirage.github.io/ocaml-git/git/Git/Blob/module-type-S/index.html\n[tree]: http://mirage.github.io/ocaml-git/git/Git/Tree/module-type-S/index.html\n[commit]: http://mirage.github.io/ocaml-git/git/Git/Commit/module-type-S/index.html\n[tag]: http://mirage.github.io/ocaml-git/git/Git/Tag/module-type-S/index.html\n[reference]: http://mirage.github.io/ocaml-git/git/Git/Reference/module-type-S/index.html\n[pack-file]: http://mirage.github.io/ocaml-git/git/Git/Pack/index.html\n[pack-index]: http://mirage.github.io/ocaml-git/git/Git/Index_pack/index.html\n[index]: http://mirage.github.io/ocaml-git/git-unix/Git_unix/Index/index.html\n[git-sync]: http://mirage.github.io/ocaml-git/git/Git/Sync/module-type-S/index.html\n[git-store]: http://mirage.github.io/ocaml-git/git/Git/Store/index.html\n[git-store-memory]: http://mirage.github.io/ocaml-git/git/Git/Mem/index.html\n[git-store-unix]: http://mirage.github.io/ocaml-git/git-unix/Git_unix/Store/index.html\n[LICENSE.md]: ./LICENSE.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirage%2Focaml-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmirage%2Focaml-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirage%2Focaml-git/lists"}