// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie // SPDX-License-Identifier: MIT //! zig-git: reading git repositories from Zig without running `git`. //! //! What there is so far is the bottom of the core layer: object formats //! and object IDs, the four kinds of object and their headers, views of a //! commit's, a tree's and a tag's contents that read them as forgivingly //! as git does, and the object database on disk — loose objects, packs, //! multi-pack-indexes and alternates — behind one object database //! interface; configuration from every source git reads, includes and //! all; wildmatch, git's glob dialect; refs; the index; the commit-graph //! and its changed-path Bloom filters; and finding and opening a //! repository as git does, `Repository` being the way in. Of the revision //! layer there are revisions, read by `revision` and resolved by //! `Resolver`, with the refspecs and upstream and push branches //! (`refspec`, `tracking`) they need; walking commits (`RevWalk`, over the //! commits `Commits` reads); merge bases (`merge_base`); and describing //! commits as `git log --pretty` does (`pretty`), with their trailers //! (`trailers`), the mailmap (`Mailmap`), searches by message and //! identity (`grep`) and decorations (`Decorations`); replace refs //! (`Replacements`), grafts and the shallow boundary (`Grafts`); and //! naming commits by tags as `git describe` does (`describe`). const std = @import("std"); const builtin = @import("builtin"); const object = @import("object.zig"); /// The hash algorithm a repository names its objects with. pub const ObjectFormat = object.Format; /// An object ID, with the format it was computed in. pub const ObjectId = object.Id; /// The kind of an object: commit, tree, blob or tag. pub const ObjectKind = object.Kind; /// An object header: kind and size. pub const ObjectHeader = object.Header; /// Computes an object ID a piece at a time. pub const ObjectHasher = object.Hasher; /// The most bytes an object ID has in any object format. pub const object_max_byte_length = object.max_byte_length; /// The most hexadecimal digits an object ID has in any object format. pub const object_max_hex_length = object.max_hex_length; /// The object ID of an object of a kind holding some contents. pub const hashObject = object.hash; /// What a failed read was about. pub const Diagnostics = @import("Diagnostics.zig"); /// An author, committer or tagger line. pub const Identity = @import("Identity.zig"); /// Dates as git shows and reads them: `--date=` modes, `TZ` and git's /// date parsers. pub const date = @import("date.zig"); /// A commit's contents. pub const Commit = @import("commit.zig").Commit; /// One header of a commit or a tag, and a way to step through them. pub const HeaderField = @import("commit.zig").Field; /// An annotated tag's contents. pub const Tag = @import("tag.zig").Tag; /// A tree's contents, an entry at a time. pub const tree = @import("tree.zig"); /// Paths as git quotes them in its output. pub const quote = @import("quote.zig"); /// Where a repository's objects are found by object ID. pub const ObjectDatabase = @import("ObjectDatabase.zig"); /// Loose objects: one compressed file per object. pub const loose = @import("loose.zig"); /// Packs: many objects in one file, most stored as deltas. pub const pack = @import("pack.zig"); /// A pack index: the `.idx` beside a pack. pub const PackIndex = @import("PackIndex.zig"); /// A multi-pack-index: one table finding the objects of many packs. pub const MultiPackIndex = @import("MultiPackIndex.zig"); /// Deltas: objects stored as instructions for rebuilding them. pub const delta = @import("delta.zig"); /// How a repository names its alternates. pub const alternates = @import("alternates.zig"); /// A repository's object database on disk, alternates and all. pub const DiskDatabase = @import("DiskDatabase.zig"); /// Replace refs: objects read as other objects. pub const Replacements = @import("Replacements.zig"); /// Grafts and the shallow boundary: commits read with other parents. pub const Grafts = @import("Grafts.zig"); /// Decorations: the refs, `HEAD` and the rest shown beside commits. pub const Decorations = @import("Decorations.zig"); /// Naming commits by the nearest tag they descend from, as `git describe` /// does. pub const describe = @import("describe.zig"); /// Abbreviated object IDs: expanding a prefix to its objects, and /// shortening an object ID to a prefix only it has. pub const abbrev = @import("abbrev.zig"); /// The commit-graph: commits' parents, trees, dates and generation /// numbers, without reading the commits. pub const CommitGraph = @import("CommitGraph.zig"); /// Changed-path Bloom filters, as the commit-graph keeps them. pub const bloom = @import("bloom.zig"); /// A repository's configuration, from every source git reads. pub const Config = @import("Config.zig"); /// Finding a repository as git finds one. pub const discover = @import("discover.zig"); /// A repository's format version and extensions. pub const RepositoryFormat = @import("RepositoryFormat.zig"); /// A repository, opened: its locations, configuration and objects. pub const Repository = @import("Repository.zig"); /// Where a repository's refs are found by name, whatever the storage. pub const RefStore = @import("RefStore.zig"); /// Ref names: which are well formed, root refs, per-worktree refs, and /// the patterns commands list refs with. pub const refname = @import("refs/name.zig"); /// The contents of a loose ref. pub const loose_ref = @import("refs/loose.zig"); /// The `packed-refs` file. pub const packed_refs = @import("refs/packed.zig"); /// Reftables: refs and reflogs in git's binary format. pub const reftable = @import("refs/reftable.zig"); /// Reflog entries, and the files backend's reflog lines. pub const reflog = @import("refs/reflog.zig"); /// The index: what the next commit's tree will hold, its extensions, /// split and sparse indexes. pub const Index = @import("Index.zig"); /// git's glob patterns, as ignore files, attributes, pathspecs, ref /// patterns and `includeIf` use them. pub const wildmatch = @import("wildmatch.zig"); /// POSIX extended regular expressions, as `git config --get-regexp` and /// commit message searches use them. pub const regex = @import("regex.zig"); /// Pathspecs: the patterns that limit a command to some paths. pub const Pathspec = @import("Pathspec.zig"); /// Attributes: the gitattributes files, their patterns and macros, and /// the state of each attribute for a path. pub const Attributes = @import("Attributes.zig"); /// Two trees compared, limited by a pathspec: the entries that differ. pub const TreeDiff = @import("TreeDiff.zig"); /// The index compared with a tree and with the working tree, from its /// stat data, as `git diff-index` and `git diff-files` compare them. pub const IndexDiff = @import("IndexDiff.zig"); /// Two texts compared line by line, and patches written, as `git diff` /// does. pub const diff = @import("diff.zig"); /// Refspecs: how a remote's refs map to this repository's and back. pub const refspec = @import("refspec.zig"); /// A branch's upstream and push branches, from the configuration. pub const tracking = @import("tracking.zig"); /// Revisions as gitrevisions(7) spells them, read into a structured form. pub const revision = @import("revision.zig"); /// Resolving a revision against a repository. pub const Resolver = @import("Resolver.zig"); /// The commits a walk reads: parents, dates and generation numbers, from /// the commit-graph or the objects. pub const Commits = @import("Commits.zig"); /// Walking commits as `git rev-list` does. pub const RevWalk = @import("RevWalk.zig"); /// Merge bases, and the questions answered as they are found. pub const merge_base = @import("merge_base.zig"); /// Mailmaps: the names and email addresses people are shown under. pub const Mailmap = @import("Mailmap.zig"); /// Trailers: the `Key: value` lines at the end of a commit message. pub const trailers = @import("trailers.zig"); /// Describing commits: the built-in formats and format strings of `git /// log --pretty`. pub const pretty = @import("pretty.zig"); /// How many columns of a terminal text takes, as git counts them. pub const width = @import("width.zig"); /// Choosing commits by their messages and identities: `--grep`, /// `--author` and `--committer`. pub const grep = @import("grep.zig"); /// A commit's or a tag's message taken apart as `for-each-ref`'s /// `%(contents...)` atoms take it: the signature, and the subject. pub const contents = @import("contents.zig"); /// Commits re-encoded for output: UTF-8 and ISO-8859-1. pub const encoding = @import("encoding.zig"); /// Contents converted on their way in from the working tree, as git /// converts them: line endings, `$Id$` and `working-tree-encoding`. pub const convert = @import("convert.zig"); /// Repositories made with git for tests, including those of programs /// built on this module. pub const test_fixture = if (builtin.is_test) @import("testing/fixture.zig") else struct {}; /// Packs and pack indexes written byte by byte, for tests. pub const test_packs = if (builtin.is_test) @import("testing/packs.zig") else struct {}; /// Repositories whose object IDs collide on their first digits, for tests. pub const test_collide = if (builtin.is_test) @import("testing/collide.zig") else struct {}; test { std.testing.refAllDecls(@This()); _ = object; _ = @import("zlib.zig"); _ = @import("testing/packs.zig"); }