# grit-lib: the library guide

> Everything an agent needs to write Git-compatible Rust programs with `grit-lib`: the quick start, every library guide with its compiled example, and the generated API map. On-disk formats and the wire protocol match Git, so repositories you write work with `git` and any Git host. Full API reference: https://docs.rs/grit-lib

Each section below is one docs page; its heading is the page's URL.

# https://grit-scm.com/docs/library-quickstart/index.md

# Library quick start

> Add grit-lib to a Rust project, open a repository, and read the current commit from HEAD.

This page walks through a minimal program that discovers a Git repository in the current directory (or a parent), resolves `HEAD`, and prints the commit id and subject line. The source below is the real example binary in the Grit repository; it is included automatically so the docs cannot drift from compiled code.

## Add the dependency

In your crate:

```bash
cargo add grit-lib
```

Or add to `Cargo.toml`:

```toml
[dependencies]
grit-lib = "0.5.0"
```

Use the [latest version on crates.io](https://crates.io/crates/grit-lib) if the number above is stale.

`grit-lib` requires **Rust 1.95** or newer (`rust-version` in the crate manifest).
That applies when you add the dependency from crates.io or a path outside the Grit
workspace. Building inside the Grit repository uses the contributor toolchain pin
in [`rust-toolchain.toml`](https://github.com/gitbutlerapp/grit/blob/main/rust-toolchain.toml)
(currently **1.99.0**), which does not propagate to downstream crates.

## Example program

Save as `src/main.rs` (or copy from `grit-examples` in the Grit repo):

```rust
//! Minimal grit-lib program: discover a repository and print HEAD's commit id.
//!
//! Source for the library quick start in the docs; kept in sync via an include directive.

use grit_lib::config::environment::RepositoryOptions;
use grit_lib::refs::store::RefName;
use grit_lib::repo::Repository;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let repo = Repository::discover(None, &RepositoryOptions::from_process())?;
    let head_name = RefName::try_from("HEAD")?;
    let head = repo.references().resolve(&head_name)?;
    let commit = repo.objects().read_commit(&head)?;
    println!("{head}");
    let subject = commit.message.lines().next().unwrap_or("");
    if !subject.is_empty() {
        println!("{subject}");
    }
    Ok(())
}
```

## Run it

From the root of any Git repository with at least one commit:

```bash
cargo run
```

Example output (your commit id will differ):

```text
217c6f9a1b2c3d4e5f6789012345678901234567
Start the project
```

The first line is the full object id of `HEAD`; the second is the first line of the commit message.

## The environment

The program opens the repository with [`RepositoryOptions::from_process`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.from_process), which snapshots the process environment (`HOME`, `GIT_*`, Windows `ProgramFiles`) so system and global config apply exactly as they do for `git` and `grit`: `core.autocrlf`, `user.name` and `user.email`, `safe.directory`, `core.excludesFile` and credential helpers. The library itself never reads the process environment. [`RepositoryOptions::empty`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.empty) is the hermetic alternative for tests: no home directory and no global config. See [Embedding grit-lib](https://grit-scm.com/docs/library/embedding/index.md#matching-git-and-grit-on-user-repositories).

## Next steps

- [Library guide overview](https://grit-scm.com/docs/library/index.md) — longer-form guides for objects, refs, diff, and network code.
- [grit-lib on docs.rs](https://docs.rs/grit-lib) — API reference for `Repository` and the rest of the public surface.
- [Tutorial](https://grit-scm.com/docs/tutorial/index.md) — the same repository operations from the `grit` CLI.

# https://grit-scm.com/docs/library/index.md

# Library guide

> Use grit-lib from Rust — the same engine that powers the grit CLI.

These pages walk through every stable domain in `grit-lib`: repository discovery, typed handles on `Repository`, and network or maintenance workflows. Each guide includes a compiled example from `grit-examples` that tests against the system `git` binary.

| Page | Topic |
| --- | --- |
| [Repository](https://grit-scm.com/docs/library/repository/index.md) | Discover, open, init, typed handles overview |
| [Embedding](https://grit-scm.com/docs/library/embedding/index.md) | Environment, sinks, subprocess injection, concurrency |
| [Config](https://grit-scm.com/docs/library/config/index.md) | `Repository::config()` / `Config` get/set |
| [Objects](https://grit-scm.com/docs/library/objects/index.md) | `Objects` read/write |
| [Refs](https://grit-scm.com/docs/library/refs/index.md) | `References`, reflog, backends |
| [Storage backends](https://grit-scm.com/docs/library/storage-backends.md/index.md) | Custom object and ref stores, conformance suites |
| [Index](https://grit-scm.com/docs/library/staging/index.md) | `IndexFile`, stage, write tree |
| [Worktree](https://grit-scm.com/docs/library/worktree/index.md) | Linked worktrees, ignore, attributes |
| [Diff](https://grit-scm.com/docs/library/diff/index.md) | `Diff` tree/index/worktree |
| [Revwalk](https://grit-scm.com/docs/library/revwalk/index.md) | `RevWalk`, merge base |
| [Merge](https://grit-scm.com/docs/library/merge/index.md) | Three-way tree merge, porcelain merge helpers |
| [Network](https://grit-scm.com/docs/library/network/index.md) | `Remotes` |
| [Stash](https://grit-scm.com/docs/library/stash/index.md) | `RepositoryStash` |
| [Notes](https://grit-scm.com/docs/library/notes/index.md) | `RepositoryNotes` |
| [Bundle](https://grit-scm.com/docs/library/bundle/index.md) | `Bundles` |
| [Maintenance](https://grit-scm.com/docs/library/maintenance/index.md) | Fsck object rules, hooks |
| [API layout](https://grit-scm.com/docs/library/api-layout/index.md) | Flat → canonical module map |
| [API map](https://grit-scm.com/docs/library/api-map/index.md) | Generated module and type index |

For exhaustive API detail see [grit-lib on docs.rs](https://docs.rs/grit-lib).

# https://grit-scm.com/docs/library/api-layout/index.md

# api-layout

# grit-lib API layout

Grit’s stable surface is the **canonical domain tree** (≤25 root modules plus [`prelude`](https://docs.rs/grit-lib/latest/grit_lib/prelude/index.html)). Flat implementation modules such as `odb` or `fetch` at the crate root are **private**; use `grit_lib::objects::odb` and `grit_lib::remote::transfer` instead. The map in [`grit-lib/canonical-modules.toml`](https://github.com/gitbutlerapp/grit/blob/main/grit-lib/canonical-modules.toml) lists every previously flat path and its canonical replacement.

For naming rules, semver policy on the path to **0.6.0**, and how to add a public item, see [`grit-lib/API.md`](https://github.com/gitbutlerapp/grit/blob/main/grit-lib/API.md). If you embed against **0.5.x**, see [Migrating to 0.6](https://grit-scm.com/docs/library/api-layout/migrating-to-0.6.md/index.md).

## Domain roots

| Domain | Role |
| --- | --- |
| [`objects`](https://docs.rs/grit-lib/latest/grit_lib/objects/index.html) | Object ids/kinds, ODB, packs, MIDX, hashing, deltas, bitmaps |
| [`refs`](https://docs.rs/grit-lib/latest/grit_lib/refs/index.html) | Ref backends, reflog, refspecs, reftable, name validation |
| [`index`](https://docs.rs/grit-lib/latest/grit_lib/index/index.html) | Index file, sparse checkout, split index, untracked cache |
| [`revwalk`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/index.html) | `rev-parse`, `rev-list`, merge-base, commit-graph |
| [`diff`](https://docs.rs/grit-lib/latest/grit_lib/diff/index.html) | Tree/content diff, patch-ids helpers |
| [`merge`](https://docs.rs/grit-lib/latest/grit_lib/merge/index.html) | Branch merge, pick/revert/replay, rerere, tree merge |
| [`config`](https://docs.rs/grit-lib/latest/grit_lib/config/index.html) | Config cascade, identity, init/bootstrap |
| [`remote`](https://docs.rs/grit-lib/latest/grit_lib/remote/index.html) | Remotes, fetch/push, transport, credentials |
| [`worktree`](https://docs.rs/grit-lib/latest/grit_lib/worktree/index.html) | Working tree, ignore, attributes, pathspec |
| [`stash`](https://docs.rs/grit-lib/latest/grit_lib/stash/index.html) | Stash stack (porcelain types) |
| [`notes`](https://docs.rs/grit-lib/latest/grit_lib/notes/index.html) | Git notes |
| [`bundle`](https://docs.rs/grit-lib/latest/grit_lib/bundle/index.html) | Bundle files and bundle-over-remote |
| [`parallel`](https://docs.rs/grit-lib/latest/grit_lib/parallel/index.html) | Thread policy and parallel helpers (root) |

Cross-cutting entry points (`repo`, `error`, `porcelain`, `progress`, …) remain at the crate root.

## `Repository` handles

Each [`Repository`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) accessor returns a handle **named like the method** (mirrors [`objects`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Objects.html) / [`references`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html)):

| Accessor | Handle type |
| --- | --- |
| [`index`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.index) | [`IndexFile`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexFile.html) |
| [`revwalk`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.revwalk) | [`RevWalk`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html) |
| [`remotes`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.remotes) | [`Remotes`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/type.Remotes.html) |
| [`worktrees`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.worktrees) | [`Worktrees`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/type.Worktrees.html) |
| [`bundles`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.bundles) | [`Bundles`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/type.Bundles.html) |
| `snapshot_checkouts` (`unstable-hosting` feature only, outside semver) | `SnapshotCheckouts` |

Use [`references`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.references) for resolve/list/update; the raw backend is [`references().store()`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.store) (same trait object as [`ref_store`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.ref_store)).

Which area belongs on which accessor, including the accessors the API 0.6 work still has to add, is in the [handle map](https://github.com/gitbutlerapp/grit/blob/main/grit-lib/API.md#handle-map) in `grit-lib/API.md`. The same section covers the other canonical forms: options structs, trailing progress and cancel parameters, and when a free function is allowed.

## Flat → canonical map

The authoritative map lives in [`grit-lib/canonical-modules.toml`](https://github.com/gitbutlerapp/grit/blob/main/grit-lib/canonical-modules.toml). CI checks that every `grit_lib::…` import in `grit-cli`, `grit-protocol`, `grit-examples`, `grit-utils`, `grit-test-support`, and `grit-lib/tests` appears in that file (`scripts/check_canonical_layout.py`, wired from `canonical_paths` integration test). Imports must use the **canonical domain path** (for example `grit_lib::objects::odb`, not the private flat `odb` module); `scripts/check_noncanonical_grit_lib_imports.py` enforces that (`no_noncanonical_grit_lib_imports` in the same integration test, and `scripts/tests/test_canonical_layout.py` in the docs CI job).

Examples:

| Private flat module | Canonical path |
| --- | --- |
| `odb` | `grit_lib::objects::odb` |
| `pack_bitmap` | `grit_lib::objects::bitmap` |
| `bitmap_walk` | `grit_lib::objects::bitmap` |
| `rev_list` | `grit_lib::revwalk::rev_list` |
| `fetch` | internal (fetch runs through `grit_lib::remote::Remote::fetch`; progress types are in `grit_lib::progress`) |
| `ignore` | `grit_lib::worktree::ignore` |
| `pathspec` | `grit_lib::worktree::pathspec` |
| `ident` (not under `config::ident`) | `grit_lib::ident` |
| `sparse_checkout` | `grit_lib::index::sparse_checkout` |
| `reflog` | `grit_lib::refs::reflog` |
| `serve` | `grit_lib::remote::serve` |
| `transfer` | `grit_lib::remote::transfer` |
| `test_support::fixtures` (bench repos; enable `test-support`, outside semver) | *(not in default rustdoc)* |
| `object_inspect` | `grit_lib::revwalk::object_inspect` |
| `quote_path` | `grit_lib::porcelain::quote_path` |
| `pack_reuse` | `grit_lib::objects::pack` |
| `pack_write` | crate-internal (`index_pack` install helpers; no public `objects::pack_write` path) |
| `fsmonitor` | `grit_lib::worktree::fsmonitor` |
| `HookName`, `PostOperationHooks` | `grit_lib::command_runner::hooks` |
| `RefStorageFormat` | `grit_lib::refs::ref_storage` |
| `OidAbbrevBatch` | `grit_lib::revwalk::object_inspect` |
| `PARALLEL_STAT_MIN_ENTRIES` | `grit_lib::worktree` |

Removed **view modules** (use domains above instead): `object_store`, `references`, `worktree_index`, `revision`, `diffing`, `merging`, `configuration`, and the empty `plumbing` scaffold.

Removed **test-only functions** that reproduced Git `test-tool` dumps or printed Git's CLI warnings, with no caller outside `grit-lib`'s own tests:

| Removed | Use instead |
| --- | --- |
| `objects::midx::format_midx_dump`, `format_midx_dump_layer`, `format_midx_show_objects`, `format_midx_show_objects_layer`, `format_midx_bitmapped_packs` | [`read_midx_objects`](https://docs.rs/grit-lib/latest/grit_lib/objects/midx/fn.read_midx_objects.html), [`read_midx_btmp_ranges`](https://docs.rs/grit-lib/latest/grit_lib/objects/midx/fn.read_midx_btmp_ranges.html) |
| `index::index_name_hash_lazy::dump_lazy_init_name_hash`, `test_lazy_init_name_hash`, `memihash_cont` | [`memihash`](https://docs.rs/grit-lib/latest/grit_lib/index/index_name_hash_lazy/fn.memihash.html) |
| `config::gitmodules::write_gitmodules_cli_option_warnings` | [`looks_like_command_line_option`](https://docs.rs/grit-lib/latest/grit_lib/config/gitmodules/fn.looks_like_command_line_option.html) |
| `config::gitmodules::gitdir::die_path_inside_submodule_when_disabled` | [`path_inside_registered_submodule`](https://docs.rs/grit-lib/latest/grit_lib/config/gitmodules/gitdir/fn.path_inside_registered_submodule.html), [`path_inside_indexed_submodule`](https://docs.rs/grit-lib/latest/grit_lib/config/gitmodules/gitdir/fn.path_inside_indexed_submodule.html) |

## Nested implementation modules

Some canonical paths re-export **submodules** of the flat implementation (for example `grit_lib::objects::odb::store` is the public path for the object-store backend). Prefer the canonical prefix in all new code.

# https://grit-scm.com/docs/library/api-map/index.md

# grit-lib API map

> Generated index of public grit-lib modules and key types with docs.rs links.

This page is regenerated from the local `grit-lib` rustdoc build (`cargo doc -p grit-lib --no-deps`) whenever you run `make docs`. Each row links to [docs.rs](https://docs.rs/grit-lib/latest/grit_lib/) for the matching item.

| Item | Kind | Summary | docs.rs |
| --- | --- | --- | --- |
| `grit_lib::apply` | module | Unified/git-diff patch parsing and blob-level hunk application. | [API](https://docs.rs/grit-lib/latest/grit_lib/apply/index.html) |
| `grit_lib::apply::ApplyOptions` | struct | Options controlling blob-level hunk application. | [API](https://docs.rs/grit-lib/latest/grit_lib/apply/struct.ApplyOptions.html) |
| `grit_lib::apply::BinaryPatchPayload` | struct | Binary patch payload as compressed base85 chunks for forward/reverse apply. | [API](https://docs.rs/grit-lib/latest/grit_lib/apply/struct.BinaryPatchPayload.html) |
| `grit_lib::apply::BinaryPatchSection` | struct | One forward or reverse chunk in a GIT binary patch. | [API](https://docs.rs/grit-lib/latest/grit_lib/apply/struct.BinaryPatchSection.html) |
| `grit_lib::apply::BinaryPatchSectionKind` | enum | Whether a GIT binary patch section holds a full literal or a delta against the other side. | [API](https://docs.rs/grit-lib/latest/grit_lib/apply/enum.BinaryPatchSectionKind.html) |
| `grit_lib::apply::FilePatch` | struct | Represents one file in a unified diff. | [API](https://docs.rs/grit-lib/latest/grit_lib/apply/struct.FilePatch.html) |
| `grit_lib::apply::Hunk` | struct | A single hunk in a unified diff. | [API](https://docs.rs/grit-lib/latest/grit_lib/apply/struct.Hunk.html) |
| `grit_lib::apply::HunkLine` | enum | One line in a unified-diff hunk body. | [API](https://docs.rs/grit-lib/latest/grit_lib/apply/enum.HunkLine.html) |
| `grit_lib::apply::IndexApplyOptions` | struct | Options for apply_patch_to_index. | [API](https://docs.rs/grit-lib/latest/grit_lib/apply/struct.IndexApplyOptions.html) |
| `grit_lib::apply::IndexApplyOutcome` | struct | Result of applying patches to the index. | [API](https://docs.rs/grit-lib/latest/grit_lib/apply/struct.IndexApplyOutcome.html) |
| `grit_lib::blame` | module | Blame line-mapping algorithm. | [API](https://docs.rs/grit-lib/latest/grit_lib/blame/index.html) |
| `grit_lib::blame::BlameAttributedLine` | struct | One blamed line returned by [blame_file]. | [API](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameAttributedLine.html) |
| `grit_lib::blame::BlameCommitInfo` | struct | Metadata for a commit referenced by BlameResult::lines. | [API](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameCommitInfo.html) |
| `grit_lib::blame::BlameDiffAlgorithm` | enum | Diff algorithm used when mapping lines between blob revisions during blame. | [API](https://docs.rs/grit-lib/latest/grit_lib/blame/enum.BlameDiffAlgorithm.html) |
| `grit_lib::blame::BlameFinalSource` | enum | Which version of the blamed file [blame_file] attributes, line by line. | [API](https://docs.rs/grit-lib/latest/grit_lib/blame/enum.BlameFinalSource.html) |
| `grit_lib::blame::BlameHunk` | struct | A contiguous run of blamed lines sharing commit, path, and original line sequence. | [API](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameHunk.html) |
| `grit_lib::blame::BlameLine` | struct | A single line attribution produced by compute_blame. | [API](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameLine.html) |
| `grit_lib::blame::BlameOptions` | struct | Options for [blame_file]. | [API](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameOptions.html) |
| `grit_lib::blame::BlameResult` | struct | Full blame result for one file at one revision. | [API](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameResult.html) |
| `grit_lib::blame::BlameTextconvContext` | struct | Cached config and attributes for optional textconv during blame. | [API](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameTextconvContext.html) |
| `grit_lib::blame::CopyDetection` | enum | Copy detection depth for blame, matching Git’s repeated -C flag. | [API](https://docs.rs/grit-lib/latest/grit_lib/blame/enum.CopyDetection.html) |
| `grit_lib::blame::IgnoreRevs` | struct | Commits skipped during blame (Git --ignore-rev / --ignore-revs-file). | [API](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.IgnoreRevs.html) |
| `grit_lib::blame::IgnoreRevsSources` | struct | Where to load ignored revisions from (config, CLI files, CLI rev specs). | [API](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.IgnoreRevsSources.html) |
| `grit_lib::bundle` | module | Bundle files and bundle-over-remote transport. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/index.html) |
| `grit_lib::bundle::Bundle` | struct | An opened bundle file on disk. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.Bundle.html) |
| `grit_lib::bundle::BundleCreatePlan` | struct | Planned bundle contents without writing a file. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.BundleCreatePlan.html) |
| `grit_lib::bundle::BundleError` | enum | Bundle read/write/verify failures. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/enum.BundleError.html) |
| `grit_lib::bundle::BundleHeader` | struct | Parsed bundle header (everything before the PACK stream). | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.BundleHeader.html) |
| `grit_lib::bundle::BundlePrerequisite` | struct | One prerequisite commit line (-oid) for an incremental bundle. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.BundlePrerequisite.html) |
| `grit_lib::bundle::BundleRefEntry` | struct | One ref tip that would appear in a bundle header. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.BundleRefEntry.html) |
| `grit_lib::bundle::BundleRefUpdatePlan` | struct | One ref movement that would occur when applying bundle header tips locally. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.BundleRefUpdatePlan.html) |
| `grit_lib::bundle::BundleSpec` | struct | Input for [write_bundle]. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.BundleSpec.html) |
| `grit_lib::bundle::BundleUnbundlePlan` | struct | Planned unbundle work: verification outcome and ref updates without ingesting the pack. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.BundleUnbundlePlan.html) |
| `grit_lib::bundle::BundleVerifyReport` | struct | Outcome of Bundle::verify. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.BundleVerifyReport.html) |
| `grit_lib::bundle::BundleVersion` | enum | Supported on-disk bundle header versions. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/enum.BundleVersion.html) |
| `grit_lib::bundle::FilterSpec` | struct | Wire filter specification carried in v3 @filter= capabilities. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.FilterSpec.html) |
| `grit_lib::bundle::UnbundleOutcome` | struct | Result of ingesting a bundle’s embedded pack into a repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.UnbundleOutcome.html) |
| `grit_lib::bundle::UnbundledRef` | struct | A single ref entry returned from Bundle::unbundle. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.UnbundledRef.html) |
| `grit_lib::bundle::bundle_remote` | module | Revision options for writing bundles from grit bundle create-style arguments. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/bundle_remote/index.html) |
| `grit_lib::bundle::bundle_remote::BundleCreateOptions` | struct | Ref tips and revision tokens for RepositoryBundles::write_from_revs. | [API](https://docs.rs/grit-lib/latest/grit_lib/bundle/bundle_remote/struct.BundleCreateOptions.html) |
| `grit_lib::change_id` | module | Change identifiers stored in commit headers. | [API](https://docs.rs/grit-lib/latest/grit_lib/change_id/index.html) |
| `grit_lib::change_id::ChangeId` | struct | A change identifier as stored in a commit header (reverse-hex or opaque text). | [API](https://docs.rs/grit-lib/latest/grit_lib/change_id/struct.ChangeId.html) |
| `grit_lib::change_id::ChangeIdError` | enum | Failure modes for change-id parsing and generation. | [API](https://docs.rs/grit-lib/latest/grit_lib/change_id/enum.ChangeIdError.html) |
| `grit_lib::change_id::ChangeIdGenerator` | trait | Injectable source of random change-id bytes. | [API](https://docs.rs/grit-lib/latest/grit_lib/change_id/trait.ChangeIdGenerator.html) |
| `grit_lib::change_id::ChangeIdMatch` | struct | A commit whose resolved change id matched a prefix lookup. | [API](https://docs.rs/grit-lib/latest/grit_lib/change_id/struct.ChangeIdMatch.html) |
| `grit_lib::change_id::ChangeIdPolicy` | struct | Repository and testing knobs for assigning change ids to new commits. | [API](https://docs.rs/grit-lib/latest/grit_lib/change_id/struct.ChangeIdPolicy.html) |
| `grit_lib::change_id::ResolvedChangeId` | struct | Resolved change id plus whether it came from a stored header. | [API](https://docs.rs/grit-lib/latest/grit_lib/change_id/struct.ResolvedChangeId.html) |
| `grit_lib::command_runner` | module | Injectable subprocess execution for hooks, filters, credentials, and helpers. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/index.html) |
| `grit_lib::command_runner::CommandEnvironment` | struct | How a child process should inherit or receive environment variables. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.CommandEnvironment.html) |
| `grit_lib::command_runner::CommandExit` | struct | Exit status of a completed child. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.CommandExit.html) |
| `grit_lib::command_runner::CommandHandleError` | struct | Error when an operation requires a live OS child but the handle is synthetic. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.CommandHandleError.html) |
| `grit_lib::command_runner::CommandOutput` | struct | Output from RunningCommand::wait_with_output. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.CommandOutput.html) |
| `grit_lib::command_runner::CommandRunner` | trait | Spawns subprocesses; the only production implementation uses std::process::Command. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/trait.CommandRunner.html) |
| `grit_lib::command_runner::CommandRunner` | trait | Discovery and config variables that affect repository open/discover and ConfigSet loading. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/trait.CommandRunner.html) |
| `grit_lib::command_runner::CommandSpec` | struct | Typed description of a subprocess to spawn. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.CommandSpec.html) |
| `grit_lib::command_runner::CommandStdin` | enum | Stdin source for the child. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/enum.CommandStdin.html) |
| `grit_lib::command_runner::CommandStdio` | enum | Stdio disposition for a child stream. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/enum.CommandStdio.html) |
| `grit_lib::command_runner::RecordedResponse` | enum | Scripted responses for RecordingRunner. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/enum.RecordedResponse.html) |
| `grit_lib::command_runner::RecordingRunner` | struct | Records CommandSpec invocations and returns configurable exit statuses. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.RecordingRunner.html) |
| `grit_lib::command_runner::RunningCommand` | struct | Live child process with optional piped stdio. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.RunningCommand.html) |
| `grit_lib::command_runner::ShellInvocation` | enum | Shell invocation mode (Git sh -c hooks and filters). | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/enum.ShellInvocation.html) |
| `grit_lib::command_runner::SystemCommandRunner` | struct | Runs commands with the real OS process API. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.SystemCommandRunner.html) |
| `grit_lib::command_runner::hooks` | module | Git hook execution helpers (legacy free functions; prefer crate::repo_handles::RepositoryHooks). | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/index.html) |
| `grit_lib::command_runner::hooks::CommitHookEnv` | struct | Environment for commit-style hooks (GIT_INDEX_FILE, GIT_EDITOR, GIT_PREFIX, and extra pairs). | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/struct.CommitHookEnv.html) |
| `grit_lib::command_runner::hooks::HookError` | enum | Hook subprocess failure (non-zero exit or spawn error). | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.HookError.html) |
| `grit_lib::command_runner::hooks::HookName` | enum | Well-known lifecycle hooks that porcelain operations run and report in their outcomes (for example crate::porcelain::commit::CommitOutcome::hooks_run). | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.HookName.html) |
| `grit_lib::command_runner::hooks::HookOutput` | struct | Bytes the hooks of one event wrote while HookStdio::Capture was in effect. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/struct.HookOutput.html) |
| `grit_lib::command_runner::hooks::HookResult` | enum | Result of running the hooks for one event. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.HookResult.html) |
| `grit_lib::command_runner::hooks::HookStdio` | enum | Where hook subprocesses send their stdout and stderr. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.HookStdio.html) |
| `grit_lib::command_runner::hooks::PostOperationHooks` | enum | Whether an operation runs the hooks Git runs once it has completed (post-checkout, post-merge, post-rewrite). | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.PostOperationHooks.html) |
| `grit_lib::command_runner::hooks::PrePushRef` | struct | One ref update a push is about to make, as reported to the pre-push hook. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/struct.PrePushRef.html) |
| `grit_lib::command_runner::hooks::RewriteKind` | enum | What kind of rewrite a post-rewrite hook is told about (its first argument). | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.RewriteKind.html) |
| `grit_lib::command_runner::hooks::RunHookOptions` | struct | Options for [run_hook_opts]. | [API](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/struct.RunHookOptions.html) |
| `grit_lib::commit` | module | Commit-metadata helpers shared by the porcelain commands. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/index.html) |
| `grit_lib::commit::TrailerArgParseError` | struct | Error when a --trailer argument is not key=value or key: value. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/struct.TrailerArgParseError.html) |
| `grit_lib::commit::encoding` | module | Commit encoding helpers for non-UTF-8 commit messages. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/encoding/index.html) |
| `grit_lib::commit::signing` | module | OpenPGP / SSH signature verification. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/signing/index.html) |
| `grit_lib::commit::signing::GpgConfig` | struct | Resolved signing/verification configuration. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/signing/struct.GpgConfig.html) |
| `grit_lib::commit::signing::GpgFormat` | enum | The signature format selected via gpg.format. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/signing/enum.GpgFormat.html) |
| `grit_lib::commit::signing::SignatureCheck` | struct | A parsed signature check result. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/signing/struct.SignatureCheck.html) |
| `grit_lib::commit::signing::TrustLevel` | enum | Signature trust level, as reported for a verified signature. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/signing/enum.TrustLevel.html) |
| `grit_lib::commit::trailers` | module | Commit trailers and interpretation helpers. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/trailers/index.html) |
| `grit_lib::commit::trailers::CherryPickMessageOptions` | struct | -x / -s options when finalizing a cherry-pick commit message. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/trailers/struct.CherryPickMessageOptions.html) |
| `grit_lib::commit::trailers::interpret` | module | Parse and apply trailer commands. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/trailers/interpret/index.html) |
| `grit_lib::commit::trailers::interpret::NewTrailerArg` | struct | One trailer to add (a --trailer argument) and how to place it. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/trailers/interpret/struct.NewTrailerArg.html) |
| `grit_lib::commit::trailers::interpret::ProcessTrailerOptions` | struct | ProcessTrailerOptions struct. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/trailers/interpret/struct.ProcessTrailerOptions.html) |
| `grit_lib::commit::trailers::interpret::TrailerIfExists` | enum | TrailerIfExists enum. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/trailers/interpret/enum.TrailerIfExists.html) |
| `grit_lib::commit::trailers::interpret::TrailerIfMissing` | enum | TrailerIfMissing enum. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/trailers/interpret/enum.TrailerIfMissing.html) |
| `grit_lib::commit::trailers::interpret::TrailerWhere` | enum | Placement of a new trailer relative to an anchor trailer. | [API](https://docs.rs/grit-lib/latest/grit_lib/commit/trailers/interpret/enum.TrailerWhere.html) |
| `grit_lib::commits` | module | Create and plan commits on a repository (Commits from Repository::commits). | [API](https://docs.rs/grit-lib/latest/grit_lib/commits/index.html) |
| `grit_lib::commits::Commits` | struct | Record and preview commits for one open repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/commits/struct.Commits.html) |
| `grit_lib::config` | module | Configuration cascade, identity, and repository bootstrap helpers. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/index.html) |
| `grit_lib::config::Config` | struct | Read merged config and update the repository-local config file. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html) |
| `grit_lib::config::ConfigEditor` | struct | Edit a config file outside an open Repository (global, system, or -f path). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigEditor.html) |
| `grit_lib::config::ConfigEntry` | struct | A single configuration entry with its origin metadata. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigEntry.html) |
| `grit_lib::config::ConfigFile` | struct | A parsed configuration file that preserves the raw text for round-trip editing (set/unset/rename-section/remove-section). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigFile.html) |
| `grit_lib::config::ConfigIncludeOrigin` | enum | Where a ConfigFile was loaded from for Git include semantics. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/enum.ConfigIncludeOrigin.html) |
| `grit_lib::config::ConfigLocation` | enum | Which config file(s) to read or write. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/enum.ConfigLocation.html) |
| `grit_lib::config::ConfigScope` | enum | The scope (origin) of a configuration value. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/enum.ConfigScope.html) |
| `grit_lib::config::ConfigSet` | struct | A merged view across all configuration scopes. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html) |
| `grit_lib::config::ConfigValueOrigin` | struct | Origin metadata for the winning config value of a key. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigValueOrigin.html) |
| `grit_lib::config::ConfigValueType` | enum | Value type for typed config operations (Git --type subset). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/enum.ConfigValueType.html) |
| `grit_lib::config::ConfigWriteOptions` | struct | Options for a config file write (dry-run, typed canonicalization, unset patterns). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigWriteOptions.html) |
| `grit_lib::config::ConfigWritePreview` | struct | Human-readable summary of a config write that --dry-run would perform. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigWritePreview.html) |
| `grit_lib::config::GitConfigIntStrictError` | enum | Why parse_git_config_int_strict failed (mirrors Git errno after git_parse_signed). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/enum.GitConfigIntStrictError.html) |
| `grit_lib::config::IncludeContext` | struct | Context for evaluating [includeIf] conditions (gitdir:, onbranch:, hasconfig:). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/struct.IncludeContext.html) |
| `grit_lib::config::IncludeMode` | enum | Whether ConfigSet::merge_file expands [include] / [includeIf] directives. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/enum.IncludeMode.html) |
| `grit_lib::config::IncludeOptions` | struct | Options for ConfigSet::merge_file. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/struct.IncludeOptions.html) |
| `grit_lib::config::LoadConfigOptions` | struct | Options controlling how ConfigSet::load merges files and includes. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/struct.LoadConfigOptions.html) |
| `grit_lib::config::TypedConfigValue` | enum | A config value after typed parsing. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/enum.TypedConfigValue.html) |
| `grit_lib::config::dotfile` | module | dotfile API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/dotfile/index.html) |
| `grit_lib::config::environment` | module | environment API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/environment/index.html) |
| `grit_lib::config::environment::ConfigOverride` | struct | One command-line configuration override, the key[=value] argument of git -c. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.ConfigOverride.html) |
| `grit_lib::config::environment::Environment` | struct | Discovery and config variables that affect repository open/discover and ConfigSet loading. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html) |
| `grit_lib::config::environment::RepositoryOptions` | struct | Options passed to crate::repo::Repository::open, crate::repo::Repository::discover, and related entry points. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html) |
| `grit_lib::config::git_date` | module | git_date API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/git_date/index.html) |
| `grit_lib::config::git_date::DateMode` | struct | How show_date formats a timestamp (Git’s --date=<format>). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/git_date/struct.DateMode.html) |
| `grit_lib::config::git_date::DateModeType` | enum | DateModeType enum. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/git_date/enum.DateModeType.html) |
| `grit_lib::config::git_date::DateSpecError` | enum | Failure to interpret a Git-style date cutoff string (for example --since / --until). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/git_date/enum.DateSpecError.html) |
| `grit_lib::config::git_date::approx` | module | Git-compatible approxidate parsing. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/git_date/approx/index.html) |
| `grit_lib::config::git_path` | module | git_path API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/git_path/index.html) |
| `grit_lib::config::git_path::GitPathError` | enum | Errors returned by Git-compatible path helper routines. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/git_path/enum.GitPathError.html) |
| `grit_lib::config::gitmodules` | module | gitmodules API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/gitmodules/index.html) |
| `grit_lib::config::gitmodules::DotFsckIssue` | enum | Problems reported while walking trees / blobs for .gitmodules / .gitattributes fsck. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/gitmodules/enum.DotFsckIssue.html) |
| `grit_lib::config::gitmodules::gitdir` | module | Submodule .git file resolution. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/gitmodules/gitdir/index.html) |
| `grit_lib::config::ident_resolve` | module | ident_resolve API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/ident_resolve/index.html) |
| `grit_lib::config::ident_resolve::IdentRole` | enum | Author vs committer for GIT_* / author.* / committer.* lookup. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/ident_resolve/enum.IdentRole.html) |
| `grit_lib::config::ident_resolve::IdentityEnv` | trait | Environment access used for identity resolution. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/ident_resolve/trait.IdentityEnv.html) |
| `grit_lib::config::ident_resolve::IdentityError` | enum | Errors returned by strict identity resolution. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/ident_resolve/enum.IdentityError.html) |
| `grit_lib::config::init_filesystem` | module | init_filesystem API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/init_filesystem/index.html) |
| `grit_lib::config::init_filesystem::FilesystemCapabilities` | struct | Platform limits Git records as core.* during init. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/init_filesystem/struct.FilesystemCapabilities.html) |
| `grit_lib::config::init_filesystem::FilesystemCapabilitiesError` | enum | Failure while detecting filesystem capabilities under a git directory. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/init_filesystem/enum.FilesystemCapabilitiesError.html) |
| `grit_lib::config::init_filesystem::InitFilesystemConfigOptions` | struct | Controls when init-time filesystem capability detection may write local config. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/init_filesystem/struct.InitFilesystemConfigOptions.html) |
| `grit_lib::config::init_filesystem::PrecomposeDetection` | enum | When init may run the NFD→NFC precompose capability check. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/init_filesystem/enum.PrecomposeDetection.html) |
| `grit_lib::config::mailmap` | module | mailmap API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/mailmap/index.html) |
| `grit_lib::config::mailmap::MailmapEntry` | struct | Legacy line-shaped entry kept for API compatibility; prefer MailmapTable. | [API](https://docs.rs/grit-lib/latest/grit_lib/config/mailmap/struct.MailmapEntry.html) |
| `grit_lib::config::mailmap::MailmapTable` | struct | Parsed mailmap as a lookup table (Git string_list + nested namemap). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/mailmap/struct.MailmapTable.html) |
| `grit_lib::config::precompose_config` | module | precompose_config API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/config/precompose_config/index.html) |
| `grit_lib::diagnostics` | module | Git-style diagnostic prefixes and typed warning sinks for embedders and the CLI. | [API](https://docs.rs/grit-lib/latest/grit_lib/diagnostics/index.html) |
| `grit_lib::diagnostics::CollectingDiagnostics` | struct | Collects warnings (and traces) for tests and the CLI. | [API](https://docs.rs/grit-lib/latest/grit_lib/diagnostics/struct.CollectingDiagnostics.html) |
| `grit_lib::diagnostics::DiagnosticSink` | trait | Receives warnings and optional trace lines from grit-lib. | [API](https://docs.rs/grit-lib/latest/grit_lib/diagnostics/trait.DiagnosticSink.html) |
| `grit_lib::diagnostics::NullDiagnostics` | struct | Discards all diagnostics (default for crate::repo::Repository). | [API](https://docs.rs/grit-lib/latest/grit_lib/diagnostics/struct.NullDiagnostics.html) |
| `grit_lib::diagnostics::Trace` | enum | Optional trace events (network debugging, etc.), separate from Warning. | [API](https://docs.rs/grit-lib/latest/grit_lib/diagnostics/enum.Trace.html) |
| `grit_lib::diagnostics::Warning` | enum | A non-fatal condition worth surfacing to the user or an embedder. | [API](https://docs.rs/grit-lib/latest/grit_lib/diagnostics/enum.Warning.html) |
| `grit_lib::diff` | module | Tree and content diffs, rename detection, merge diffs, and related helpers. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/index.html) |
| `grit_lib::diff::AnnotatedStructuredHunk` | struct | One structured hunk optionally decorated with a stable HunkId. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.AnnotatedStructuredHunk.html) |
| `grit_lib::diff::BreakRewrites` | enum | Break-rewrite policy (Git -B): split a heavily rewritten modification into a deletion and an addition so rename and copy detection can pair its halves. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.BreakRewrites.html) |
| `grit_lib::diff::CommitFilesManyInput` | struct | One commit’s identity for Diff::commit_files_many_work, avoiding a second ODB read. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.CommitFilesManyInput.html) |
| `grit_lib::diff::CommitFilesManyOptions` | struct | Options for Diff::commit_files_many. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.CommitFilesManyOptions.html) |
| `grit_lib::diff::CommitFilesResult` | struct | One commit’s diff output in Diff::commit_files_many (same order as input oids). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.CommitFilesResult.html) |
| `grit_lib::diff::CopyDetection` | enum | Copy detection policy for tree, index and work-tree diffs (Git -C). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.CopyDetection.html) |
| `grit_lib::diff::Diff` | struct | Compare trees, the index, and the working tree for one repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html) |
| `grit_lib::diff::DiffAlgorithm` | enum | Line diff algorithm names matching Git’s diff.algorithm and --diff-algorithm. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.DiffAlgorithm.html) |
| `grit_lib::diff::DiffArguments` | struct | Resolved diff mode and normalized pathspecs. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffArguments.html) |
| `grit_lib::diff::DiffDetail` | enum | How much content to compute for each changed file. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.DiffDetail.html) |
| `grit_lib::diff::DiffEntriesResult` | struct | Changed paths from a Diff metadata diff, after any rename, copy or break pairing, with what the diff noticed along the way. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffEntriesResult.html) |
| `grit_lib::diff::DiffEntry` | struct | A single diff entry representing one changed path. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffEntry.html) |
| `grit_lib::diff::DiffFilesOutput` | struct | Output of Diff::files_for_entries. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffFilesOutput.html) |
| `grit_lib::diff::DiffFilter` | struct | Typed include/exclude set for DiffStatus using Git’s letter syntax. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffFilter.html) |
| `grit_lib::diff::DiffLabel` | enum | One side’s --- / +++ header label in UnifiedDiffOptions. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.DiffLabel.html) |
| `grit_lib::diff::DiffMerges` | enum | How to diff a merge commit’s tree against its parents. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.DiffMerges.html) |
| `grit_lib::diff::DiffOptions` | struct | Line-diff options shared by structured output, log patches, and benchmarks. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffOptions.html) |
| `grit_lib::diff::DiffRequest` | struct | Unparsed grit diff flags and operands, as the user typed them. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffRequest.html) |
| `grit_lib::diff::DiffSide` | enum | Which tree/index/worktree sides a hunk was produced from. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.DiffSide.html) |
| `grit_lib::diff::DiffStat` | struct | Per-file line counts plus totals for a whole diff. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffStat.html) |
| `grit_lib::diff::DiffStatus` | enum | The kind of change between two sides of a diff. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.DiffStatus.html) |
| `grit_lib::diff::DiffTarget` | enum | What to compare when producing a structured file diff list. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.DiffTarget.html) |
| `grit_lib::diff::DiffTotals` | struct | Summary across all files in a stat-style diff. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffTotals.html) |
| `grit_lib::diff::FileChange` | struct | One changed path with both sides’ bytes loaded for diffing. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.FileChange.html) |
| `grit_lib::diff::FileDiff` | struct | One changed file with structured hunks and metadata (returned by Diff::files). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.FileDiff.html) |
| `grit_lib::diff::FileStat` | struct | One file’s row in a DiffStat. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.FileStat.html) |
| `grit_lib::diff::HunkDiffBundle` | struct | Staged and unstaged file diffs for hunk id assignment (one staged scan per call). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.HunkDiffBundle.html) |
| `grit_lib::diff::HunkExtent` | enum | How far each hunk reaches beyond its changed lines. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.HunkExtent.html) |
| `grit_lib::diff::HunkId` | struct | Twelve lowercase hex characters identifying one structured hunk within a side and path. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.HunkId.html) |
| `grit_lib::diff::HunkIdError` | enum | Parse or format failure for HunkId. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.HunkIdError.html) |
| `grit_lib::diff::IndentHeuristic` | enum | Git’s indent heuristic for placing a change whose boundaries are ambiguous. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.IndentHeuristic.html) |
| `grit_lib::diff::IndentHeuristicOverride` | enum | CLI override for diff.indentHeuristic when building DiffOptions. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.IndentHeuristicOverride.html) |
| `grit_lib::diff::InexactRenameDetectionSkipped` | struct | Emitted when unmatched rename candidates exceed diff.renameLimit after exact and basename pairing. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.InexactRenameDetectionSkipped.html) |
| `grit_lib::diff::InvalidDiffFilter` | enum | Unknown or unsupported --diff-filter letter. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.InvalidDiffFilter.html) |
| `grit_lib::diff::LineStat` | struct | Line insertion/deletion counts for one file (--numstat). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.LineStat.html) |
| `grit_lib::diff::ListedFileDiff` | struct | One changed file with optional patch body or line counts (returned by Diff::files_for_entries). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.ListedFileDiff.html) |
| `grit_lib::diff::LogPatchBinaryFormat` | enum | Binary file encoding inside a log/show patch (git log -p vs git diff --binary). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.LogPatchBinaryFormat.html) |
| `grit_lib::diff::LogPatchCommitHeader` | enum | How much commit metadata precedes each patch in write_commit_log_patch. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.LogPatchCommitHeader.html) |
| `grit_lib::diff::LogPatchOptions` | struct | Options for write_commit_log_patch. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.LogPatchOptions.html) |
| `grit_lib::diff::NoIndexError` | enum | Failure modes specific to diff_paths. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.NoIndexError.html) |
| `grit_lib::diff::NoNewlineMarker` | enum | Whether patches carry Git’s \ No newline at end of file marker lines. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.NoNewlineMarker.html) |
| `grit_lib::diff::PatchResolvedSide` | struct | One file for write_patch_resolved: diff metadata plus where each side’s content is. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.PatchResolvedSide.html) |
| `grit_lib::diff::PatchSide` | enum | Where write_patch_resolved takes the content of one side of a file. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.PatchSide.html) |
| `grit_lib::diff::PatchTextOptions` | struct | Options for write_patch (git diff --binary-compatible output for git apply). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.PatchTextOptions.html) |
| `grit_lib::diff::PathQuoting` | enum | How DiffLabel::Path labels quote unusual path bytes (Git’s core.quotePath). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.PathQuoting.html) |
| `grit_lib::diff::Pickaxe` | struct | Compiled pickaxe filter for [crate::rev_list::rev_list]. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Pickaxe.html) |
| `grit_lib::diff::Pickaxe` | struct | Commit message and identity filters for revision walks (--author, --grep, …). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Pickaxe.html) |
| `grit_lib::diff::PickaxeError` | enum | Invalid pickaxe pattern. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.PickaxeError.html) |
| `grit_lib::diff::PickaxeKind` | enum | Which pickaxe mode is active (-S or -G). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.PickaxeKind.html) |
| `grit_lib::diff::RenameDetection` | enum | Rename detection policy for tree diffs. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.RenameDetection.html) |
| `grit_lib::diff::ResolveDiffArgumentsError` | enum | Invalid grit diff argument combinations or revision parsing failures. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.ResolveDiffArgumentsError.html) |
| `grit_lib::diff::StatBar` | struct | Column counts for one diffstat row’s change bar (see LineStat::bar). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.StatBar.html) |
| `grit_lib::diff::SubmoduleIgnoreMode` | enum | Submodule ignore mode for worktree gitlink comparisons (Git --ignore-submodules, diff.ignoreSubmodules, submodule.<name>.ignore). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.SubmoduleIgnoreMode.html) |
| `grit_lib::diff::TreeDiffOptions` | struct | Options shared by the metadata diffs on Diff: Diff::tree_to_tree, Diff::commits, Diff::index_to_tree, Diff::index_to_worktree, Diff::tree_to_worktree and Diff::detect_renames. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html) |
| `grit_lib::diff::TreeDiffStructured` | struct | Tree diff entry with structured line hunks ready for CLI rendering. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffStructured.html) |
| `grit_lib::diff::UncommittedDiff` | struct | Staged, unstaged, and working-tree diffs over one loaded index. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UncommittedDiff.html) |
| `grit_lib::diff::UnifiedDiffOptions` | struct | Everything that shapes a unified diff of two text sides. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html) |
| `grit_lib::diff::UnknownDiffAlgorithm` | struct | Unknown value for DiffAlgorithm’s FromStr implementation. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnknownDiffAlgorithm.html) |
| `grit_lib::diff::WhitespaceMode` | struct | Whitespace handling for line diffs (super::DiffOptions::whitespace). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.WhitespaceMode.html) |
| `grit_lib::diff::combined_diff_patch` | module | combined_diff_patch API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_diff_patch/index.html) |
| `grit_lib::diff::combined_diff_patch::CombinedDiffWsOptions` | struct | Whitespace handling for combined diffs (Git xdl_opts subset). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_diff_patch/struct.CombinedDiffWsOptions.html) |
| `grit_lib::diff::combined_diff_patch::CombinedStructuredHunk` | struct | A combined hunk (@@@ header and body lines). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_diff_patch/struct.CombinedStructuredHunk.html) |
| `grit_lib::diff::combined_diff_patch::CombinedStructuredLine` | struct | One line in a combined (--cc) hunk: parent-column markers plus text. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_diff_patch/struct.CombinedStructuredLine.html) |
| `grit_lib::diff::combined_diff_patch::CombinedStructuredLineKind` | enum | Line role in a combined (--cc) hunk (derived from parent-column markers). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_diff_patch/enum.CombinedStructuredLineKind.html) |
| `grit_lib::diff::combined_diff_patch::CombinedStructuredTextDiff` | struct | Structured combined diff body (no diff --cc file header). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_diff_patch/struct.CombinedStructuredTextDiff.html) |
| `grit_lib::diff::combined_tree_diff` | module | Combined tree diff helpers for merge commits. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_tree_diff/index.html) |
| `grit_lib::diff::combined_tree_diff::CombinedDiffPath` | struct | One path in a combined diff: merge result tree vs each parent tree. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_tree_diff/struct.CombinedDiffPath.html) |
| `grit_lib::diff::combined_tree_diff::CombinedParentSide` | struct | One parent’s contribution at a combined-diff path. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_tree_diff/struct.CombinedParentSide.html) |
| `grit_lib::diff::combined_tree_diff::CombinedParentStatus` | enum | Per-parent coarse status in a combined diff (A / M / D). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_tree_diff/enum.CombinedParentStatus.html) |
| `grit_lib::diff::combined_tree_diff::CombinedRawLineFormatOptions` | struct | Formatting switches for format_combined_raw_line_all_paths_with_options. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_tree_diff/struct.CombinedRawLineFormatOptions.html) |
| `grit_lib::diff::combined_tree_diff::CombinedTreeDiffOptions` | struct | Options for the multitree walk. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_tree_diff/struct.CombinedTreeDiffOptions.html) |
| `grit_lib::diff::fmt_merge_msg` | module | Merge commit message formatting from FETCH_HEAD-style input. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/fmt_merge_msg/index.html) |
| `grit_lib::diff::fmt_merge_msg::FmtMergeMsgOptions` | struct | Options for fmt_merge_msg. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/fmt_merge_msg/struct.FmtMergeMsgOptions.html) |
| `grit_lib::diff::merge_diff` | module | Combined diff content for octopus merges. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/merge_diff/index.html) |
| `grit_lib::diff::merge_file` | module | merge_file API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/merge_file/index.html) |
| `grit_lib::diff::merge_file::ConflictStyle` | enum | Conflict-marker output style. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/merge_file/enum.ConflictStyle.html) |
| `grit_lib::diff::merge_file::MergeFavor` | enum | How conflict regions should be resolved. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/merge_file/enum.MergeFavor.html) |
| `grit_lib::diff::merge_file::MergeInput` | struct | Input and options for a three-way merge. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/merge_file/struct.MergeInput.html) |
| `grit_lib::diff::merge_file::MergeOutput` | struct | Result of a three-way merge. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/merge_file/struct.MergeOutput.html) |
| `grit_lib::diff::merge_trees` | module | Tree-level three-way merge engine. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/merge_trees/index.html) |
| `grit_lib::diff::patch_ids` | module | patch_ids API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/patch_ids/index.html) |
| `grit_lib::diff::patch_ids::PatchIdMode` | enum | How to compute a patch-ID from unified diff text. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/patch_ids/enum.PatchIdMode.html) |
| `grit_lib::diff::rerere` | module | Recorded conflict resolution (rerere). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/rerere/index.html) |
| `grit_lib::diff::rerere::RerereAutoupdate` | enum | Effective rerere.autoupdate setting for a repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/rerere/enum.RerereAutoupdate.html) |
| `grit_lib::diff::rerere::RerereEvent` | struct | One rerere status event for a path. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/rerere/struct.RerereEvent.html) |
| `grit_lib::diff::rerere::RerereEventKind` | enum | Outcome of rerere handling one path (replaces stderr status lines). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/rerere/enum.RerereEventKind.html) |
| `grit_lib::diff::structured` | module | Structured line diffs for CLI and embedders (grit diff, grit show). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/structured/index.html) |
| `grit_lib::diff::structured::SideBytes` | struct | Bytes of one file side prepared for diffing. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/structured/struct.SideBytes.html) |
| `grit_lib::diff::structured::StructuredFileDiff` | struct | File metadata plus a structured line diff. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/structured/struct.StructuredFileDiff.html) |
| `grit_lib::diff::structured::StructuredHunk` | struct | A contiguous run of changes plus surrounding context. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/structured/struct.StructuredHunk.html) |
| `grit_lib::diff::structured::StructuredLine` | struct | One rendered line in a structured hunk. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/structured/struct.StructuredLine.html) |
| `grit_lib::diff::structured::StructuredLineKind` | enum | Kind of line in a structured hunk. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/structured/enum.StructuredLineKind.html) |
| `grit_lib::diff::structured::StructuredSegment` | struct | One run of text within a line, with optional intra-line emphasis. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/structured/struct.StructuredSegment.html) |
| `grit_lib::diff::structured::StructuredTextDiff` | struct | Line-level diff of two text sides (no file metadata). | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/structured/struct.StructuredTextDiff.html) |
| `grit_lib::diff::userdiff` | module | Per-path diff driver (funcname) matching. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/userdiff/index.html) |
| `grit_lib::diff::userdiff::FuncnameMatcher` | struct | Compiled function-name matcher used for diff hunk headers. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/userdiff/struct.FuncnameMatcher.html) |
| `grit_lib::diff::userdiff::FuncnamePatternError` | enum | Why a diff.<driver>.funcname / diff.<driver>.xfuncname pattern was rejected. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/userdiff/enum.FuncnamePatternError.html) |
| `grit_lib::diff::ws` | module | ASCII whitespace helpers used by the diff engine. | [API](https://docs.rs/grit-lib/latest/grit_lib/diff/ws/index.html) |
| `grit_lib::divergence` | module | What happened when two heads of one shared branch diverged. | [API](https://docs.rs/grit-lib/latest/grit_lib/divergence/index.html) |
| `grit_lib::divergence::Change` | struct | One commit, as both sides have it. | [API](https://docs.rs/grit-lib/latest/grit_lib/divergence/struct.Change.html) |
| `grit_lib::divergence::Choice` | enum | A way of putting two diverged heads back together. | [API](https://docs.rs/grit-lib/latest/grit_lib/divergence/enum.Choice.html) |
| `grit_lib::divergence::Combined` | struct | What putting two heads together made. | [API](https://docs.rs/grit-lib/latest/grit_lib/divergence/struct.Combined.html) |
| `grit_lib::divergence::Did` | enum | What one side did to one commit since the base. | [API](https://docs.rs/grit-lib/latest/grit_lib/divergence/enum.Did.html) |
| `grit_lib::divergence::Divergence` | struct | Two diverged heads, explained. | [API](https://docs.rs/grit-lib/latest/grit_lib/divergence/struct.Divergence.html) |
| `grit_lib::divergence::Keyed` | struct | One commit of a head, by the key it’s matched on. | [API](https://docs.rs/grit-lib/latest/grit_lib/divergence/struct.Keyed.html) |
| `grit_lib::divergence::ReplayOntoOutcome` | enum | Outcome of RevWalk::replay_onto: either a new tip commit or a conflict list with repository paths. | [API](https://docs.rs/grit-lib/latest/grit_lib/divergence/enum.ReplayOntoOutcome.html) |
| `grit_lib::divergence::ResolveOption` | struct | One way out of a divergence, as offered for its scenario. | [API](https://docs.rs/grit-lib/latest/grit_lib/divergence/struct.ResolveOption.html) |
| `grit_lib::divergence::Scenario` | enum | What two diverged heads add up to. | [API](https://docs.rs/grit-lib/latest/grit_lib/divergence/enum.Scenario.html) |
| `grit_lib::error` | module | Shared error types for grit-lib. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/index.html) |
| `grit_lib::error::ApplyError` | enum | Unified diff / patch application errors. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ApplyError.html) |
| `grit_lib::error::AttrPathspecError` | enum | Why a :(attr:...) pathspec clause was rejected. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.AttrPathspecError.html) |
| `grit_lib::error::AuthFailure` | enum | Why an HTTP remote refused access (RemoteError::Auth). | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.AuthFailure.html) |
| `grit_lib::error::BadNumericSource` | enum | Why a Git config numeric value was rejected (git config int strict parsing). | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.BadNumericSource.html) |
| `grit_lib::error::BinaryPatchError` | enum | Why a GIT binary patch section could not be read or applied (ApplyError::BinaryPatch). | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.BinaryPatchError.html) |
| `grit_lib::error::ConfigError` | enum | Configuration parse and validation failures. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ConfigError.html) |
| `grit_lib::error::ConfigValueError` | enum | Why a raw config value could not be read as a boolean, integer or color. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ConfigValueError.html) |
| `grit_lib::error::DiffError` | enum | Diff-area failure: applying patches, selecting hunks by id, and blame inputs. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.DiffError.html) |
| `grit_lib::error::Error` | enum | The top-level error type for all grit-lib operations. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html) |
| `grit_lib::error::ErrorSummary` | struct | Classification and text of a failure recorded inside another error. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/struct.ErrorSummary.html) |
| `grit_lib::error::FilterError` | enum | Clean/smudge filter and EOL conversion failures. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.FilterError.html) |
| `grit_lib::error::FilterPhase` | enum | Which filter hook failed. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.FilterPhase.html) |
| `grit_lib::error::GitDirPathOperation` | enum | Git-directory filesystem operation that failed on a single path. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.GitDirPathOperation.html) |
| `grit_lib::error::InvalidKeyReason` | enum | Which part of a config key ConfigError::InvalidKey rejected. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.InvalidKeyReason.html) |
| `grit_lib::error::LockHeldError` | struct | Lock file could not be created because another process holds it (or left a stale lock). | [API](https://docs.rs/grit-lib/latest/grit_lib/error/struct.LockHeldError.html) |
| `grit_lib::error::MidxError` | enum | A fatal multi-pack-index condition (Git die() after error: lines). | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.MidxError.html) |
| `grit_lib::error::NotARepositoryReason` | enum | Why a path could not be opened as a Git repository; carried by RepositoryError::NotARepository. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.NotARepositoryReason.html) |
| `grit_lib::error::NotesError` | enum | Notes failure: notes refs, the notes tree layout, rewrite configuration, and notes merges. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.NotesError.html) |
| `grit_lib::error::ObjectError` | enum | Object database failure: loose objects, packs, indexes, commit-graph, multi-pack-index, and promisor (partial clone) objects. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html) |
| `grit_lib::error::ObjectReadFailure` | enum | Failure decoding object bytes from loose storage or a pack entry. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectReadFailure.html) |
| `grit_lib::error::OverwriteReason` | enum | Why a tree transition would overwrite existing worktree content. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.OverwriteReason.html) |
| `grit_lib::error::PatchSide` | enum | Side of a patch a header path belongs to (ApplyError::MalformedHeaderPath). | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.PatchSide.html) |
| `grit_lib::error::PathIoError` | struct | Structured path I/O failure shared by worktree and git-directory operations. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/struct.PathIoError.html) |
| `grit_lib::error::PathIoOperation` | enum | Which filesystem area a PathIoError refers to. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.PathIoOperation.html) |
| `grit_lib::error::PathOutsideRepoError` | enum | Path outside the repository during pathspec or transport resolution. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.PathOutsideRepoError.html) |
| `grit_lib::error::PathspecFromFileParseError` | enum | --pathspec-from-file / --pathspec-file-nul parse failure. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.PathspecFromFileParseError.html) |
| `grit_lib::error::PathspecFromFileParseError` | enum | Parsed and optionally work-tree–resolved pathspec list for matching and display. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.PathspecFromFileParseError.html) |
| `grit_lib::error::PathspecResolveError` | enum | Failure while resolving argv and --pathspec-from-file pathspecs against a work tree. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.PathspecResolveError.html) |
| `grit_lib::error::PromisorFetchFailure` | struct | One promisor remote’s failure inside ObjectError::PromisorFetchFailed. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/struct.PromisorFetchFailure.html) |
| `grit_lib::error::RefError` | enum | Reference failure: ref names and values, packed-refs, ref locks, ref stores (files and reftable), reflog selectors, and the state of HEAD. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.RefError.html) |
| `grit_lib::error::RefLockError` | enum | Reference lock failures while creating or updating a ref. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.RefLockError.html) |
| `grit_lib::error::RemoteUnreadableReason` | enum | Why a remote could not be read or written (RemoteError::Unreadable). | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.RemoteUnreadableReason.html) |
| `grit_lib::error::RevisionError` | enum | Revision failure: a name that resolves to nothing, a revision expression that does not parse, or a revision walk whose options are invalid. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.RevisionError.html) |
| `grit_lib::error::SubmoduleError` | enum | Submodule layout and state failures: where a submodule’s git directory lives and whether its checkout can be inspected. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.SubmoduleError.html) |
| `grit_lib::error::WorktreeOperation` | enum | The command a dirty worktree blocked (WorktreeError::DirtyWorktree). | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.WorktreeOperation.html) |
| `grit_lib::error::WorktreePathOperation` | enum | Worktree filesystem operation that failed on a single path. | [API](https://docs.rs/grit-lib/latest/grit_lib/error/enum.WorktreePathOperation.html) |
| `grit_lib::gitbutler` | module | Recognize a GitButler workspace. | [API](https://docs.rs/grit-lib/latest/grit_lib/gitbutler/index.html) |
| `grit_lib::gitbutler::GitButlerWorkspace` | struct | A checked-out GitButler workspace: HEAD is on WORKSPACE_BRANCH and its tip is the workspace commit (WORKSPACE_COMMIT_MARKER in its message). | [API](https://docs.rs/grit-lib/latest/grit_lib/gitbutler/struct.GitButlerWorkspace.html) |
| `grit_lib::gitbutler::WorkspaceHead` | struct | One head merged into a GitButlerWorkspace. | [API](https://docs.rs/grit-lib/latest/grit_lib/gitbutler/struct.WorkspaceHead.html) |
| `grit_lib::gitbutler::WorkspaceStanding` | struct | A GitButlerWorkspace’s standing against the target branch, from GitButlerWorkspace::standing. | [API](https://docs.rs/grit-lib/latest/grit_lib/gitbutler/struct.WorkspaceStanding.html) |
| `grit_lib::ident` | module | Git author/committer identity lines (ident in Git’s fsck.c / commit.c). | [API](https://docs.rs/grit-lib/latest/grit_lib/ident/index.html) |
| `grit_lib::ident::AuthorArgError` | enum | Failure to parse parse_author_arg. | [API](https://docs.rs/grit-lib/latest/grit_lib/ident/enum.AuthorArgError.html) |
| `grit_lib::ident::AuthorContact` | struct | Name and email from a git commit --author-style argument (Name <email> or bare email). | [API](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.AuthorContact.html) |
| `grit_lib::ident::CommitIdentityError` | enum | Failure to normalize a commit author or committer string. | [API](https://docs.rs/grit-lib/latest/grit_lib/ident/enum.CommitIdentityError.html) |
| `grit_lib::ident::Signature` | struct | Parsed author or committer identity from a full header or reflog identity line. | [API](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.Signature.html) |
| `grit_lib::ident::SignatureError` | enum | Why a Signature cannot be written into an object (see Signature::validate). | [API](https://docs.rs/grit-lib/latest/grit_lib/ident/enum.SignatureError.html) |
| `grit_lib::ident::SignatureField` | enum | Which part of a Signature a SignatureError refers to. | [API](https://docs.rs/grit-lib/latest/grit_lib/ident/enum.SignatureField.html) |
| `grit_lib::ident::SignatureTimestamp` | enum | Parsed timestamp from a signature line for display and filtering. | [API](https://docs.rs/grit-lib/latest/grit_lib/ident/enum.SignatureTimestamp.html) |
| `grit_lib::index` | module | Git index (staging area) read/write and related cache extensions. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/index.html) |
| `grit_lib::index::CacheTreeNode` | struct | One node from Git’s TREE index extension. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/struct.CacheTreeNode.html) |
| `grit_lib::index::Index` | struct | The in-memory representation of the Git index file (staging area). | [API](https://docs.rs/grit-lib/latest/grit_lib/index/struct.Index.html) |
| `grit_lib::index::IndexEntry` | struct | A single entry in the Git index. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexEntry.html) |
| `grit_lib::index::IndexFile` | struct | Load and persist the Git index for one repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexFile.html) |
| `grit_lib::index::IndexLoadOptions` | struct | Options for IndexFile::load. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexLoadOptions.html) |
| `grit_lib::index::IndexLock` | struct | Exclusive .git/index.lock held for a mutating porcelain operation. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexLock.html) |
| `grit_lib::index::IndexParseContext` | struct | Context for index parse/load threading and config. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexParseContext.html) |
| `grit_lib::index::IndexParseOptions` | struct | Options for Index::parse. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexParseOptions.html) |
| `grit_lib::index::IndexWriteOptions` | struct | Options for IndexFile::write. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexWriteOptions.html) |
| `grit_lib::index::SparseIndexLoad` | enum | How IndexFile::load treats sparse-directory placeholders. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/enum.SparseIndexLoad.html) |
| `grit_lib::index::StatMatchPolicy` | struct | Git match_stat_data policy (core.trustctime, core.checkstat, core.usenanosec). | [API](https://docs.rs/grit-lib/latest/grit_lib/index/struct.StatMatchPolicy.html) |
| `grit_lib::index::WorktreeModePolicy` | struct | What the worktree filesystem can express about a tracked path’s mode. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/struct.WorktreeModePolicy.html) |
| `grit_lib::index::error` | module | Typed failures for index read, write, extensions, and write-tree. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/error/index.html) |
| `grit_lib::index::error::IndexChmodReason` | enum | Why IndexError::Chmod rejected a mode change. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/error/enum.IndexChmodReason.html) |
| `grit_lib::index::error::IndexChmodReason` | enum | Typed failures for index read, write, extensions, and write-tree. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/error/enum.IndexChmodReason.html) |
| `grit_lib::index::error::IndexCorrupt` | struct | Index file or extension corruption at an optional byte offset. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/error/struct.IndexCorrupt.html) |
| `grit_lib::index::error::IndexCorruptReason` | enum | Why index bytes or an extension payload could not be parsed. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/error/enum.IndexCorruptReason.html) |
| `grit_lib::index::error::IndexError` | enum | Failures while reading, writing, or deriving trees from the Git index. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/error/enum.IndexError.html) |
| `grit_lib::index::index_name_hash_lazy` | module | index_name_hash_lazy API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/index/index_name_hash_lazy/index.html) |
| `grit_lib::index::resolve_undo` | module | resolve_undo API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/index/resolve_undo/index.html) |
| `grit_lib::index::resolve_undo::ResolveUndoRecord` | struct | Per-path undo data: up to three conflict stages (index 0 = stage 1). | [API](https://docs.rs/grit-lib/latest/grit_lib/index/resolve_undo/struct.ResolveUndoRecord.html) |
| `grit_lib::index::sparse_checkout` | module | sparse_checkout API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/index/sparse_checkout/index.html) |
| `grit_lib::index::sparse_checkout::SparseCheckout` | struct | The active sparse-checkout definition of a repository, compiled once for path checks. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/sparse_checkout/struct.SparseCheckout.html) |
| `grit_lib::index::split_index` | module | split_index API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/index/split_index/index.html) |
| `grit_lib::index::split_index::WriteSplitIndexRequest` | struct | Request from update-index for the next index write. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/split_index/struct.WriteSplitIndexRequest.html) |
| `grit_lib::index::untracked_cache` | module | untracked_cache API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/index/untracked_cache/index.html) |
| `grit_lib::index::untracked_cache::OidStat` | struct | OidStat struct. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/untracked_cache/struct.OidStat.html) |
| `grit_lib::index::untracked_cache::StatDataDisk` | struct | Git struct stat_data on disk (36 bytes). | [API](https://docs.rs/grit-lib/latest/grit_lib/index/untracked_cache/struct.StatDataDisk.html) |
| `grit_lib::index::untracked_cache::UntrackedCache` | struct | UntrackedCache struct. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/untracked_cache/struct.UntrackedCache.html) |
| `grit_lib::index::untracked_cache::UntrackedCacheDir` | struct | UntrackedCacheDir struct. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/untracked_cache/struct.UntrackedCacheDir.html) |
| `grit_lib::index::untracked_cache::UntrackedIgnoredMode` | enum | UntrackedIgnoredMode enum. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/untracked_cache/enum.UntrackedIgnoredMode.html) |
| `grit_lib::index::write_tree` | module | write_tree API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/index/write_tree/index.html) |
| `grit_lib::index::write_tree::WriteTreeFlags` | struct | Options for cache_tree_update and write_tree_update_index. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/write_tree/struct.WriteTreeFlags.html) |
| `grit_lib::index::write_tree::WriteTreePersistence` | enum | How cache_tree_update persists rebuilt tree objects. | [API](https://docs.rs/grit-lib/latest/grit_lib/index/write_tree/enum.WriteTreePersistence.html) |
| `grit_lib::line_range` | module | Resolve Git-style -L line ranges for blame (and future log -L). | [API](https://docs.rs/grit-lib/latest/grit_lib/line_range/index.html) |
| `grit_lib::line_range::LineRangeError` | enum | Failure while parsing or resolving a -L line range specification. | [API](https://docs.rs/grit-lib/latest/grit_lib/line_range/enum.LineRangeError.html) |
| `grit_lib::list_limit` | module | Bounded list results shared by notes, hooks, bundle heads, and CLI list commands. | [API](https://docs.rs/grit-lib/latest/grit_lib/list_limit/index.html) |
| `grit_lib::list_limit::Limited` | struct | A list capped by an optional limit, with truncation when more items existed. | [API](https://docs.rs/grit-lib/latest/grit_lib/list_limit/struct.Limited.html) |
| `grit_lib::lockfile` | module | Exclusive lock files with optional Git-style acquisition backoff. | [API](https://docs.rs/grit-lib/latest/grit_lib/lockfile/index.html) |
| `grit_lib::lockfile::LockClock` | trait | Injectable clock and sleep for deterministic lock backoff tests. | [API](https://docs.rs/grit-lib/latest/grit_lib/lockfile/trait.LockClock.html) |
| `grit_lib::lockfile::LockError` | enum | Failure to create or commit a lock file. | [API](https://docs.rs/grit-lib/latest/grit_lib/lockfile/enum.LockError.html) |
| `grit_lib::lockfile::LockFile` | struct | Exclusive lock file created by this process. | [API](https://docs.rs/grit-lib/latest/grit_lib/lockfile/struct.LockFile.html) |
| `grit_lib::lockfile::LockHolder` | struct | Process recorded as the owner of a lock file. | [API](https://docs.rs/grit-lib/latest/grit_lib/lockfile/struct.LockHolder.html) |
| `grit_lib::lockfile::LockJitter` | trait | Injectable jitter so concurrent processes do not sleep in lockstep. | [API](https://docs.rs/grit-lib/latest/grit_lib/lockfile/trait.LockJitter.html) |
| `grit_lib::lockfile::LockWait` | enum | Whether to wait for an existing lock, and for how long. | [API](https://docs.rs/grit-lib/latest/grit_lib/lockfile/enum.LockWait.html) |
| `grit_lib::lockfile::SystemLockJitter` | struct | OS random bytes for cross-process jitter (Git-style lock backoff). | [API](https://docs.rs/grit-lib/latest/grit_lib/lockfile/struct.SystemLockJitter.html) |
| `grit_lib::maintenance` | module | Repository maintenance: repack, fsck, and garbage collection orchestration. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/index.html) |
| `grit_lib::maintenance::AutoGcOutcome` | enum | Result of Maintenance::gc_auto. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.AutoGcOutcome.html) |
| `grit_lib::maintenance::AutoGcReason` | enum | Why automatic maintenance is due, as decided by Maintenance::auto_gc_needed. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.AutoGcReason.html) |
| `grit_lib::maintenance::BuiltCommitGraph` | struct | A commit-graph file built in memory by Maintenance::build_commit_graph. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.BuiltCommitGraph.html) |
| `grit_lib::maintenance::CommitGraphBuild` | enum | Outcome of Maintenance::build_commit_graph. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.CommitGraphBuild.html) |
| `grit_lib::maintenance::CommitGraphOptions` | struct | Options for Maintenance::write_commit_graph. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.CommitGraphOptions.html) |
| `grit_lib::maintenance::CommitGraphSkipReason` | enum | Why Maintenance::write_commit_graph wrote no graph. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.CommitGraphSkipReason.html) |
| `grit_lib::maintenance::CommitGraphWriteReport` | struct | Result of writing objects/info/commit-graph. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.CommitGraphWriteReport.html) |
| `grit_lib::maintenance::DropExpiry` | enum | How long recently needed blobs are kept: the value of maintenance.drop-large-blobs.expire, or of a command line’s --older-than. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.DropExpiry.html) |
| `grit_lib::maintenance::DropPromisedBlobsOptions` | struct | Options for Maintenance::drop_promised_blobs. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.DropPromisedBlobsOptions.html) |
| `grit_lib::maintenance::DropPromisedBlobsReport` | struct | What Maintenance::drop_promised_blobs did, or with DropPromisedBlobsOptions::dry_run would do. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.DropPromisedBlobsReport.html) |
| `grit_lib::maintenance::DropPromisedBlobsSkip` | enum | Why gc did not run its drop phase (DropPromisedBlobsReport::skipped). | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.DropPromisedBlobsSkip.html) |
| `grit_lib::maintenance::DroppedBlob` | struct | One blob Maintenance::drop_promised_blobs dropped (or, on a dry run, would drop). | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.DroppedBlob.html) |
| `grit_lib::maintenance::GcLock` | struct | Repository-wide maintenance lock, compatible with Git’s gc.pid. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.GcLock.html) |
| `grit_lib::maintenance::GcLockAttempt` | enum | Outcome of Maintenance::try_lock. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.GcLockAttempt.html) |
| `grit_lib::maintenance::GcLockHolder` | struct | Process recorded in gc.pid by a maintenance run that is still in progress. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.GcLockHolder.html) |
| `grit_lib::maintenance::GcOptions` | struct | Options for Maintenance::gc. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.GcOptions.html) |
| `grit_lib::maintenance::GcPhaseReport` | enum | One maintenance phase from a full Maintenance::gc run. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.GcPhaseReport.html) |
| `grit_lib::maintenance::GcPhaseTimings` | struct | Wall-clock milliseconds for each phase of Maintenance::gc. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.GcPhaseTimings.html) |
| `grit_lib::maintenance::GcStats` | struct | Result of Maintenance::gc. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.GcStats.html) |
| `grit_lib::maintenance::KeptBlobCounts` | struct | Why candidate blobs stayed. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.KeptBlobCounts.html) |
| `grit_lib::maintenance::LopReadiness` | struct | Whether a LOP can answer the lazy fetches of Git clients. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.LopReadiness.html) |
| `grit_lib::maintenance::Maintenance` | struct | Garbage collection, repacking, commit-graph and MIDX writes, fsck and the gc.pid lock for one repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html) |
| `grit_lib::maintenance::MidxOptions` | struct | Options for Maintenance::write_midx. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.MidxOptions.html) |
| `grit_lib::maintenance::MidxWriteReport` | struct | Result of writing objects/pack/multi-pack-index. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.MidxWriteReport.html) |
| `grit_lib::maintenance::OffloadConfigChange` | struct | One config value Maintenance::offload_blobs set. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.OffloadConfigChange.html) |
| `grit_lib::maintenance::OffloadError` | enum | Why Maintenance::offload_blobs refused to run. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.OffloadError.html) |
| `grit_lib::maintenance::OffloadOptions` | struct | Options for Maintenance::offload_blobs. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.OffloadOptions.html) |
| `grit_lib::maintenance::OffloadPack` | struct | A pack Maintenance::offload_blobs wrote. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.OffloadPack.html) |
| `grit_lib::maintenance::OffloadPackRole` | enum | Which of the packs Maintenance::offload_blobs writes an OffloadPack is. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.OffloadPackRole.html) |
| `grit_lib::maintenance::OffloadRepo` | enum | Which repository a OffloadConfigChange was made in. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.OffloadRepo.html) |
| `grit_lib::maintenance::OffloadReport` | struct | What Maintenance::offload_blobs did (or, with OffloadOptions::dry_run, would do). | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.OffloadReport.html) |
| `grit_lib::maintenance::PackRefsOptions` | struct | Options for References::pack. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.PackRefsOptions.html) |
| `grit_lib::maintenance::PackRefsReport` | struct | Result of packing refs (files packed-refs or reftable compaction). | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.PackRefsReport.html) |
| `grit_lib::maintenance::PruneOptions` | struct | Options for Maintenance::prune_loose_objects. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.PruneOptions.html) |
| `grit_lib::maintenance::RepackOptions` | struct | Options for Maintenance::repack_all. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.RepackOptions.html) |
| `grit_lib::maintenance::RepackReport` | struct | Counters produced by Maintenance::repack. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.RepackReport.html) |
| `grit_lib::maintenance::RepackStats` | struct | Extended counters and paths produced by Maintenance::repack_all. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.RepackStats.html) |
| `grit_lib::maintenance::fsck` | module | Standalone object fsck helpers (single-object checks). | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/index.html) |
| `grit_lib::maintenance::fsck::FsckError` | struct | Git-compatible fsck failure for loose object validation. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/struct.FsckError.html) |
| `grit_lib::maintenance::fsck::FsckMsgLevel` | enum | How one fsck message is treated during a transfer. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/enum.FsckMsgLevel.html) |
| `grit_lib::maintenance::fsck::FsckObjectOptions` | struct | Repository hash width for object-id fields in commit, tag, and tree headers. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/struct.FsckObjectOptions.html) |
| `grit_lib::maintenance::fsck::ObjectFsckChecker` | struct | An ObjectFsckPolicy with its skip list loaded, ready to check objects. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/struct.ObjectFsckChecker.html) |
| `grit_lib::maintenance::fsck::ObjectFsckPolicy` | struct | Which object problems refuse a transfer. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/struct.ObjectFsckPolicy.html) |
| `grit_lib::maintenance::fsck::SkipListError` | enum | Why a skip list could not be loaded. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/enum.SkipListError.html) |
| `grit_lib::maintenance::repository_fsck` | module | Repository-wide fsck (object store, connectivity, refs). | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/index.html) |
| `grit_lib::maintenance::repository_fsck::FsckDiagnostic` | struct | A repository finding with its severity and listing visibility resolved. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/struct.FsckDiagnostic.html) |
| `grit_lib::maintenance::repository_fsck::FsckIssue` | enum | One repository fsck finding with a stable, typed shape. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/enum.FsckIssue.html) |
| `grit_lib::maintenance::repository_fsck::FsckOptions` | struct | Controls which fsck phases run and how strictly diagnostics are treated. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/struct.FsckOptions.html) |
| `grit_lib::maintenance::repository_fsck::FsckReport` | struct | Aggregate fsck outcome. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/struct.FsckReport.html) |
| `grit_lib::maintenance::repository_fsck::FsckSeverity` | enum | Severity for reporting and exit status. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/enum.FsckSeverity.html) |
| `grit_lib::maintenance::repository_fsck::FsckSummary` | struct | Classified findings and aggregate integrity status. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/struct.FsckSummary.html) |
| `grit_lib::maintenance::repository_fsck::MissingObjectReferrer` | enum | Where a missing-object diagnostic was discovered. | [API](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/enum.MissingObjectReferrer.html) |
| `grit_lib::merge` | module | Merge, pick, revert, replay and rerere for one Repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/index.html) |
| `grit_lib::merge::BranchIntegrateRequest` | struct | Integrate into an explicit branch tip (for example during pull). | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.BranchIntegrateRequest.html) |
| `grit_lib::merge::Merge` | struct | Merge, pick, revert, replay and merge --continue / --abort for one repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html) |
| `grit_lib::merge::MergeError` | enum | Merge, replay, and in-progress operation failures. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/enum.MergeError.html) |
| `grit_lib::merge::MergeRerere` | struct | Recorded conflict resolution (rerere) for one repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.MergeRerere.html) |
| `grit_lib::merge::RerereAutoupdate` | enum | Effective rerere.autoupdate setting for a repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/enum.RerereAutoupdate.html) |
| `grit_lib::merge::RerereEvent` | struct | One rerere status event for a path. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.RerereEvent.html) |
| `grit_lib::merge::RerereEventKind` | enum | Outcome of rerere handling one path (replaces stderr status lines). | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/enum.RerereEventKind.html) |
| `grit_lib::merge::merge_diff` | module | Combined diff content for merge commits. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_diff/index.html) |
| `grit_lib::merge::merge_diff::CombinedDiffFormat` | enum | Header word of a combined diff: diff --combined (-c) or diff --cc. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_diff/enum.CombinedDiffFormat.html) |
| `grit_lib::merge::merge_diff::CombinedPatchOptions` | struct | How format_combined_textconv_patch renders one merge path. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_diff/struct.CombinedPatchOptions.html) |
| `grit_lib::merge::merge_diff::CombinedPathLabels` | enum | Which paths the --- lines of a combined patch name. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_diff/enum.CombinedPathLabels.html) |
| `grit_lib::merge::merge_diff::ConflictStages` | struct | Index stages of one conflicted path: base (stage 1), ours (stage 2) and theirs (stage 3). | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_diff/struct.ConflictStages.html) |
| `grit_lib::merge::merge_diff::Textconv` | enum | Whether a path’s diff.<driver>.textconv filter runs before its contents are diffed. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_diff/enum.Textconv.html) |
| `grit_lib::merge::merge_file` | module | Single-file three-way merge. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_file/index.html) |
| `grit_lib::merge::merge_file::ConflictStyle` | enum | Conflict-marker output style. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_file/enum.ConflictStyle.html) |
| `grit_lib::merge::merge_file::MergeFavor` | enum | How conflict regions should be resolved. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_file/enum.MergeFavor.html) |
| `grit_lib::merge::merge_file::MergeInput` | struct | Input and options for a three-way merge. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_file/struct.MergeInput.html) |
| `grit_lib::merge::merge_file::MergeOutput` | struct | Result of a three-way merge. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_file/struct.MergeOutput.html) |
| `grit_lib::merge::merge_trees` | module | Tree-level three-way merge engine. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/index.html) |
| `grit_lib::merge::merge_trees::DirectoryRenameConflict` | enum | A directory rename that a merge could not settle on its own. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/enum.DirectoryRenameConflict.html) |
| `grit_lib::merge::merge_trees::DirectoryRenameMode` | enum | How a three-way merge treats files one side adds inside a directory the other side renamed. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/enum.DirectoryRenameMode.html) |
| `grit_lib::merge::merge_trees::MergeSide` | enum | One side of a three-way merge. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/enum.MergeSide.html) |
| `grit_lib::merge::merge_trees::RenameRenameConflict` | struct | One base path that each side of a merge renamed to a different destination. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/struct.RenameRenameConflict.html) |
| `grit_lib::merge::merge_trees::TheirsConflictLabel` | enum | How to label the “theirs” side in textual conflict markers. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/enum.TheirsConflictLabel.html) |
| `grit_lib::merge::merge_trees::TreeMergeConflictPresentation` | struct | Labels and marker style for conflict output during tree merges. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/struct.TreeMergeConflictPresentation.html) |
| `grit_lib::merge::merge_trees::TreeMergeOutput` | struct | Result of merging three trees with optional conflict-marker blobs for checkout. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/struct.TreeMergeOutput.html) |
| `grit_lib::merge::merge_trees::WhitespaceMergeOptions` | struct | WhitespaceMergeOptions struct. | [API](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/struct.WhitespaceMergeOptions.html) |
| `grit_lib::notes` | module | Git notes refs and note commit helpers. | [API](https://docs.rs/grit-lib/latest/grit_lib/notes/index.html) |
| `grit_lib::notes::NotesMergeStrategy` | enum | How to combine conflicting note blobs during a notes merge. | [API](https://docs.rs/grit-lib/latest/grit_lib/notes/enum.NotesMergeStrategy.html) |
| `grit_lib::notes::NotesRef` | struct | Full ref name for a Git notes namespace (refs/notes/…). | [API](https://docs.rs/grit-lib/latest/grit_lib/notes/struct.NotesRef.html) |
| `grit_lib::notes::NotesRewriteCommand` | enum | History command that may copy notes onto rewritten commits. | [API](https://docs.rs/grit-lib/latest/grit_lib/notes/enum.NotesRewriteCommand.html) |
| `grit_lib::notes::NotesRewriteMode` | enum | How to combine note blobs when several rewritten commits map onto one target. | [API](https://docs.rs/grit-lib/latest/grit_lib/notes/enum.NotesRewriteMode.html) |
| `grit_lib::notes::NotesRewritePlan` | struct | Resolved settings for a notes copy during a rewrite (refs, mode, commit message). | [API](https://docs.rs/grit-lib/latest/grit_lib/notes/struct.NotesRewritePlan.html) |
| `grit_lib::notes::NotesTreeEntry` | struct | One leaf entry in a notes fanout tree (blob pointing at a note object). | [API](https://docs.rs/grit-lib/latest/grit_lib/notes/struct.NotesTreeEntry.html) |
| `grit_lib::objects` | module | Git objects: ids, kinds, in-memory representations, and the object database stack. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/index.html) |
| `grit_lib::objects::CommitData` | struct | Parsed representation of a commit object. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.CommitData.html) |
| `grit_lib::objects::CommitRef` | struct | Parsed commit headers and message body borrowing from the object bytes. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.CommitRef.html) |
| `grit_lib::objects::FileMode` | struct | A Git file mode (100644, 100755, 120000, 160000, 040000), or FileMode::ABSENT for the missing side of an add or delete. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.FileMode.html) |
| `grit_lib::objects::HashAlgo` | enum | A Git hash algorithm. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/enum.HashAlgo.html) |
| `grit_lib::objects::HashVersionError` | struct | Error when converting an on-disk hash-version byte to HashAlgo. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.HashVersionError.html) |
| `grit_lib::objects::NewCommit` | struct | A commit to create with Objects::write_commit. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.NewCommit.html) |
| `grit_lib::objects::Object` | struct | A decompressed, header-stripped Git object. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Object.html) |
| `grit_lib::objects::ObjectId` | struct | A Git object identifier: a SHA-1 (20-byte) or SHA-256 (32-byte) digest. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectId.html) |
| `grit_lib::objects::ObjectIdPrefix` | struct | A parsed abbreviated object id: the leading hex digits (“nibbles”) of a digest. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectIdPrefix.html) |
| `grit_lib::objects::ObjectInfo` | struct | Kind and uncompressed size of a Git object without loading its payload. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectInfo.html) |
| `grit_lib::objects::ObjectKind` | enum | The four Git object types. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/enum.ObjectKind.html) |
| `grit_lib::objects::ObjectRef` | struct | Borrowed view of an object’s kind and uncompressed payload. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectRef.html) |
| `grit_lib::objects::Objects` | struct | Read and write Git objects through a Repository handle. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Objects.html) |
| `grit_lib::objects::OidBuildHasher` | struct | Build hasher for OidHashMap and OidHashSet. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.OidBuildHasher.html) |
| `grit_lib::objects::OidHasher` | struct | Hasher state for OID-keyed maps. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.OidHasher.html) |
| `grit_lib::objects::TagData` | struct | Parsed representation of an annotated tag object. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TagData.html) |
| `grit_lib::objects::TreeEntry` | struct | A single entry in a Git tree object. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeEntry.html) |
| `grit_lib::objects::TreeEntryError` | enum | Why Objects::write_tree refused an entry. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/enum.TreeEntryError.html) |
| `grit_lib::objects::TreeEntryRef` | struct | A single tree entry borrowing name bytes from the tree object payload. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeEntryRef.html) |
| `grit_lib::objects::TreeRefIter` | struct | Iterator over tree entries borrowing from the tree object’s raw payload. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeRefIter.html) |
| `grit_lib::objects::WriteTreeOptions` | struct | Options for Objects::write_tree_with. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.WriteTreeOptions.html) |
| `grit_lib::objects::bitmap` | module | Pack and commit reachability bitmaps. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/index.html) |
| `grit_lib::objects::bitmap::BitmapError` | enum | Failure mode when a .bitmap sidecar cannot be used. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/enum.BitmapError.html) |
| `grit_lib::objects::bitmap::BitmapIndex` | struct | Memory-mapped pack or MIDX reachability bitmap (Git BITM v1). | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html) |
| `grit_lib::objects::bitmap::BitmapWalkError` | enum | Bitmap-specific failures during a reachability walk; object and ref failures are reported in their own areas. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/enum.BitmapWalkError.html) |
| `grit_lib::objects::bitmap::BitmapWalkUnsupported` | struct | Bitmap walk could not run (unsupported filter or shallow repo); use a non-bitmap walk instead. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapWalkUnsupported.html) |
| `grit_lib::objects::bitmap::CommitReachabilityBitmap` | struct | Decoded reachability set for one commit (bits index pack/MIDX object positions). | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.CommitReachabilityBitmap.html) |
| `grit_lib::objects::bitmap::PackBitmapWriteError` | enum | Failure while writing a pack reachability bitmap. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/enum.PackBitmapWriteError.html) |
| `grit_lib::objects::bitmap::PackBitmapWriteOptions` | struct | Options controlling pack bitmap generation (caller-supplied; not read from the environment). | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.PackBitmapWriteOptions.html) |
| `grit_lib::objects::bitmap::PackBitmapWriter` | struct | Writes .bitmap sidecars for pack indexes produced by all-into-one repacks. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.PackBitmapWriter.html) |
| `grit_lib::objects::bitmap::ReachabilityQuery` | struct | Query parameters for a bitmap reachability walk. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.ReachabilityQuery.html) |
| `grit_lib::objects::bitmap::ReachableSet` | struct | Reachable objects from a ReachabilityQuery: in-index bits plus out-of-namespace oids. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.ReachableSet.html) |
| `grit_lib::objects::bitmap::TypeBitmap` | struct | Borrowed type filter bitmap (commits, trees, blobs, or tags). | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.TypeBitmap.html) |
| `grit_lib::objects::commit_graph` | module | Commit-graph files for reachability and generation numbers. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/commit_graph/index.html) |
| `grit_lib::objects::delta_encode` | module | Delta compression encoding for pack streams. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/delta_encode/index.html) |
| `grit_lib::objects::delta_encode::DeltaIndex` | struct | Rolling-hash index over a base buffer for reuse when encoding many targets. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/delta_encode/struct.DeltaIndex.html) |
| `grit_lib::objects::hash` | module | Object-id hashing, file checksums, and hash algorithm selection. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/hash/index.html) |
| `grit_lib::objects::hash::Backend` | enum | Which implementation the sha1 / sha2 dependency selects for algo on this CPU. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/hash/enum.Backend.html) |
| `grit_lib::objects::hash::HashingWriter` | struct | A writer that forwards bytes to an inner sink while accumulating a checksum. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/hash/struct.HashingWriter.html) |
| `grit_lib::objects::hash::ObjectHasher` | struct | Incremental hasher for Git’s supported object-id algorithms. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/hash/struct.ObjectHasher.html) |
| `grit_lib::objects::index_pack` | module | Index-pack and thin-pack handling. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/index.html) |
| `grit_lib::objects::index_pack::IngestPackOptions` | struct | Options controlling how a received pack is ingested. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/struct.IngestPackOptions.html) |
| `grit_lib::objects::index_pack::IngestedPack` | struct | Result of ingesting a received pack into an object database. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/struct.IngestedPack.html) |
| `grit_lib::objects::index_pack::ObjectKindCounts` | struct | Per-type object counts for a pack, tallied while it is indexed. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/struct.ObjectKindCounts.html) |
| `grit_lib::objects::midx` | module | Multi-pack-index (MIDX) read and write. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/midx/index.html) |
| `grit_lib::objects::midx::MidxBitmapWriteOutcome` | enum | Outcome of an optional MIDX reachability bitmap write. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/midx/enum.MidxBitmapWriteOutcome.html) |
| `grit_lib::objects::midx::WriteMultiPackIndexOptions` | struct | Options for writing a multi-pack index (extension of the simple writer). | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/midx/struct.WriteMultiPackIndexOptions.html) |
| `grit_lib::objects::odb` | module | Object database backends and loose/packed storage. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/index.html) |
| `grit_lib::objects::odb::ObjectStore` | trait | Read-only object storage: lookup, metadata, streaming, and enumeration. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/trait.ObjectStore.html) |
| `grit_lib::objects::odb::ObjectStream` | struct | Streaming handle for a single object’s uncompressed payload. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.ObjectStream.html) |
| `grit_lib::objects::odb::Odb` | struct | A loose-object database rooted at a given objects/ directory. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) |
| `grit_lib::objects::odb::OdbBuilder` | struct | Read layers, an attached commit-graph and the alternates switch for a repository’s object database. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.OdbBuilder.html) |
| `grit_lib::objects::odb::WritableObjectStore` | trait | Object storage that supports inserting new objects. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/trait.WritableObjectStore.html) |
| `grit_lib::objects::odb::WriteOptions` | struct | Options for Odb::write_with and WritableObjectStore::write. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.WriteOptions.html) |
| `grit_lib::objects::odb::store` | module | Pluggable object storage backends and the ObjectStore trait surface. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/index.html) |
| `grit_lib::objects::odb::store::CompositeStore` | struct | Read-only store that consults an ordered list of backends. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/struct.CompositeStore.html) |
| `grit_lib::objects::odb::store::FilesSource` | struct | Read/write object storage backed by one objects/ directory tree. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/struct.FilesSource.html) |
| `grit_lib::objects::odb::store::FilesSourceOpenOptions` | struct | MIDX-related switches when opening a FilesSource. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/struct.FilesSourceOpenOptions.html) |
| `grit_lib::objects::odb::store::LooseStore` | struct | On-disk loose object store for one objects/ directory. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/struct.LooseStore.html) |
| `grit_lib::objects::odb::store::MemoryStore` | struct | In-memory object map keyed by ObjectId. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/struct.MemoryStore.html) |
| `grit_lib::objects::odb::store::MidxObjects` | struct | MIDX-backed read-only ObjectStore for one objects/ directory. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/struct.MidxObjects.html) |
| `grit_lib::objects::odb::store::MidxObjectsStatus` | enum | Whether MidxObjects can serve reads for this repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/enum.MidxObjectsStatus.html) |
| `grit_lib::objects::odb::store::ObjectStore` | trait | Read-only object storage: lookup, metadata, streaming, and enumeration. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.ObjectStore.html) |
| `grit_lib::objects::odb::store::ObjectStream` | struct | Streaming handle for a single object’s uncompressed payload. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/struct.ObjectStream.html) |
| `grit_lib::objects::odb::store::PackFilter` | struct | Which local pack indexes participate in filtered membership checks. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/struct.PackFilter.html) |
| `grit_lib::objects::odb::store::PackedObjects` | struct | Pack-index-backed read-only ObjectStore for one objects/ directory. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/struct.PackedObjects.html) |
| `grit_lib::objects::odb::store::PrunableObjectStore` | trait | Object storage that can delete objects, so garbage collection can reclaim them. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.PrunableObjectStore.html) |
| `grit_lib::objects::odb::store::WritableObjectStore` | trait | Object storage that supports inserting new objects. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.WritableObjectStore.html) |
| `grit_lib::objects::pack` | module | Pack files, indexes, and packfile I/O. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack/index.html) |
| `grit_lib::objects::pack::PackIndex` | struct | Parsed pack index with fanout-accelerated OID lookup and in-place table reads. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack/struct.PackIndex.html) |
| `grit_lib::objects::pack::PackIndexEntryRef` | struct | Borrowed view of one row in a pack index. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack/struct.PackIndexEntryRef.html) |
| `grit_lib::objects::pack::SingleLocalPackReader` | struct | Sorted cat-file --batch reader for repos with exactly one local pack (hot-path benchmarks). | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack/struct.SingleLocalPackReader.html) |
| `grit_lib::objects::pack_object_select` | module | Object selection heuristics for packing. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_object_select/index.html) |
| `grit_lib::objects::pack_object_select::HaveBoundary` | enum | How client haves bound the want-side object walk. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_object_select/enum.HaveBoundary.html) |
| `grit_lib::objects::pack_object_select::PackEnumerateOptions` | struct | Parameters for enumerate_pack_objects. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_object_select/struct.PackEnumerateOptions.html) |
| `grit_lib::objects::pack_objects` | module | Pack-objects negotiation and encoding. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_objects/index.html) |
| `grit_lib::objects::pack_objects::PackBuildOptions` | struct | Options controlling pack-objects output (also used by build_pack). | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_objects/struct.PackBuildOptions.html) |
| `grit_lib::objects::pack_objects::PackObjects` | struct | Streaming pack-objects builder over an Odb. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_objects/struct.PackObjects.html) |
| `grit_lib::objects::pack_objects::PackObjectsOptions` | struct | Extended options for PackObjects. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_objects/struct.PackObjectsOptions.html) |
| `grit_lib::objects::pack_objects::PackStats` | struct | Counters reported after a successful pack write. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_objects/struct.PackStats.html) |
| `grit_lib::objects::pack_objects::UploadPackStream` | struct | The pack one upload-pack response streams: the client’s wants and haves, the shallow boundaries on either side, and an optional partial-clone filter. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_objects/struct.UploadPackStream.html) |
| `grit_lib::objects::pack_store` | module | Pack-backed object store implementation. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_store/index.html) |
| `grit_lib::objects::pack_store::PackStore` | struct | Per-objects/ cache of pack indexes, bytes, MIDX views, and delta-base LRU state. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_store/struct.PackStore.html) |
| `grit_lib::objects::promisor` | module | promisor API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor/index.html) |
| `grit_lib::objects::promisor::DefaultPromisorFetcher` | struct | Default PromisorFetcher using Remote::fetch and the process HTTP client factory. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor/struct.DefaultPromisorFetcher.html) |
| `grit_lib::objects::promisor::PromisorFetcher` | trait | Fetches missing objects from the configured promisor remote without updating refs. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor/trait.PromisorFetcher.html) |
| `grit_lib::objects::promisor_remote` | module | Promisor remote configuration for partial clones. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/index.html) |
| `grit_lib::objects::promisor_remote::PromisorAcceptPolicy` | struct | The client’s rules for accepting advertised promisor remotes. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/struct.PromisorAcceptPolicy.html) |
| `grit_lib::objects::promisor_remote::PromisorAdvertisement` | struct | The promisor remotes a server advertises with the promisor-remote capability. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/struct.PromisorAdvertisement.html) |
| `grit_lib::objects::promisor_remote::PromisorConfigWarning` | enum | A promisor-related config value the library ignored. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/enum.PromisorConfigWarning.html) |
| `grit_lib::objects::promisor_remote::PromisorDecision` | struct | The client’s verdict on every advertised promisor remote. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/struct.PromisorDecision.html) |
| `grit_lib::objects::promisor_remote::PromisorField` | enum | An optional per-remote field the promisor-remote capability can carry besides name and url. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/enum.PromisorField.html) |
| `grit_lib::objects::promisor_remote::PromisorHandshake` | struct | What the promisor-remote exchange decided for one fetch. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/struct.PromisorHandshake.html) |
| `grit_lib::objects::promisor_remote::PromisorHandshakeOptions` | struct | Options for PromisorHandshake::evaluate. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/struct.PromisorHandshakeOptions.html) |
| `grit_lib::objects::promisor_remote::PromisorRejection` | enum | Why an advertised promisor remote was not accepted. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/enum.PromisorRejection.html) |
| `grit_lib::objects::unpack_objects` | module | Unpack loose objects from pack streams. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/unpack_objects/index.html) |
| `grit_lib::objects::unpack_objects::UnpackOptions` | struct | Options controlling unpack-objects behaviour. | [API](https://docs.rs/grit-lib/latest/grit_lib/objects/unpack_objects/struct.UnpackOptions.html) |
| `grit_lib::operation` | module | Shared conflict classification and in-progress operation vocabulary. | [API](https://docs.rs/grit-lib/latest/grit_lib/operation/index.html) |
| `grit_lib::operation::BlockedMove` | struct | The files a ConflictKind::DirectoryRenameBlocked directory rename did not move. | [API](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.BlockedMove.html) |
| `grit_lib::operation::Conflict` | struct | One conflicted path, as reported by status and by every operation that can stop on conflicts. | [API](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.Conflict.html) |
| `grit_lib::operation::ConflictKind` | enum | How the two sides of a merge collided on one path. | [API](https://docs.rs/grit-lib/latest/grit_lib/operation/enum.ConflictKind.html) |
| `grit_lib::operation::ConflictKindPhrase` | enum | Conflict category for grouped status output; the CLI maps each variant to its words. | [API](https://docs.rs/grit-lib/latest/grit_lib/operation/enum.ConflictKindPhrase.html) |
| `grit_lib::operation::MovedPath` | struct | Where a ConflictKind::DirectoryRenameMoved file came from. | [API](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.MovedPath.html) |
| `grit_lib::operation::OperationState` | struct | What paused operations left in the git directory, from Operations::state. | [API](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.OperationState.html) |
| `grit_lib::operation::Operations` | struct | Paused merge, rebase, pick, revert and bisect state for one open repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.Operations.html) |
| `grit_lib::operation::RenamedPaths` | struct | The three names in a ConflictKind::RenameRename conflict. | [API](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.RenamedPaths.html) |
| `grit_lib::ownership_check` | module | Injectable ownership checks for repository discovery (safe.directory). | [API](https://docs.rs/grit-lib/latest/grit_lib/ownership_check/index.html) |
| `grit_lib::ownership_check::OwnershipCheck` | trait | Answers whether the current user owns a repository path. | [API](https://docs.rs/grit-lib/latest/grit_lib/ownership_check/trait.OwnershipCheck.html) |
| `grit_lib::ownership_check::OwnershipContext` | struct | Context passed to OwnershipCheck::status. | [API](https://docs.rs/grit-lib/latest/grit_lib/ownership_check/struct.OwnershipContext.html) |
| `grit_lib::ownership_check::OwnershipError` | enum | Failure modes for ownership inspection. | [API](https://docs.rs/grit-lib/latest/grit_lib/ownership_check/enum.OwnershipError.html) |
| `grit_lib::ownership_check::OwnershipStatus` | enum | Whether a path on disk is owned by the effective user. | [API](https://docs.rs/grit-lib/latest/grit_lib/ownership_check/enum.OwnershipStatus.html) |
| `grit_lib::ownership_check::SystemOwnershipCheck` | struct | Default ownership check using the effective Unix uid and SUDO_UID. | [API](https://docs.rs/grit-lib/latest/grit_lib/ownership_check/struct.SystemOwnershipCheck.html) |
| `grit_lib::parallel` | module | Ordered scoped-thread parallelism and Git config-driven thread policy. | [API](https://docs.rs/grit-lib/latest/grit_lib/parallel/index.html) |
| `grit_lib::parallel::ParallelHashError` | enum | Incremental hasher for Git file checksums (pack/index/MIDX/commit-graph trailers). | [API](https://docs.rs/grit-lib/latest/grit_lib/parallel/enum.ParallelHashError.html) |
| `grit_lib::parallel::ParallelHashError` | enum | Failure from fallible parallel helpers when a closure returns an error. | [API](https://docs.rs/grit-lib/latest/grit_lib/parallel/enum.ParallelHashError.html) |
| `grit_lib::parallel::ParallelOp` | enum | Git operation that selects which config keys apply to parallelism. | [API](https://docs.rs/grit-lib/latest/grit_lib/parallel/enum.ParallelOp.html) |
| `grit_lib::parallel::ParallelOptions` | struct | Resolved worker count and serial-fallback thresholds for one parallel map call. | [API](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ParallelOptions.html) |
| `grit_lib::parallel::Parallelism` | struct | Resolved worker thread count for parallel helpers. | [API](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.Parallelism.html) |
| `grit_lib::parallel::ThreadPolicy` | struct | Explicit CLI or embedder overrides layered on top of config resolution. | [API](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ThreadPolicy.html) |
| `grit_lib::path_validate` | module | Git-compatible path component validation (verify_path / tree fsck rules). | [API](https://docs.rs/grit-lib/latest/grit_lib/path_validate/index.html) |
| `grit_lib::path_validate::EntryMode` | struct | Git tree/index file mode for validation (symlink vs blob affects dot-file rules). | [API](https://docs.rs/grit-lib/latest/grit_lib/path_validate/struct.EntryMode.html) |
| `grit_lib::path_validate::PathComponentError` | enum | Why a single path component fails validation. | [API](https://docs.rs/grit-lib/latest/grit_lib/path_validate/enum.PathComponentError.html) |
| `grit_lib::path_validate::PathValidationKind` | enum | Which Git path rules to apply (validate_component / validate_path). | [API](https://docs.rs/grit-lib/latest/grit_lib/path_validate/enum.PathValidationKind.html) |
| `grit_lib::path_validate::ProtectOptions` | struct | Whether NTFS and HFS+ spelling protections apply (from core.protectNTFS / core.protectHFS). | [API](https://docs.rs/grit-lib/latest/grit_lib/path_validate/struct.ProtectOptions.html) |
| `grit_lib::path_validate::TreeEntryNameAudit` | struct | Semantic problems detected on a tree entry name (fsck aggregates several at once). | [API](https://docs.rs/grit-lib/latest/grit_lib/path_validate/struct.TreeEntryNameAudit.html) |
| `grit_lib::porcelain` | module | Porcelain operations — user-facing workflows that assemble structured result models from domain modules (e.g. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/index.html) |
| `grit_lib::porcelain::CommitError` | enum | Commit, identity, signing, and patch-scoped commit failures. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.CommitError.html) |
| `grit_lib::porcelain::MergeError` | enum | Merge, replay, and in-progress operation failures. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html) |
| `grit_lib::porcelain::add` | module | Stage working-tree changes into the index (git add). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/add/index.html) |
| `grit_lib::porcelain::add::StageMode` | enum | What paths [stage] should update (git add vs git add -u). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/add/enum.StageMode.html) |
| `grit_lib::porcelain::add::StageOptions` | struct | Inputs for [stage]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/add/struct.StageOptions.html) |
| `grit_lib::porcelain::add::StageOutcome` | struct | Paths returned by [stage] (repository-relative, / separators). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/add/struct.StageOutcome.html) |
| `grit_lib::porcelain::branch` | module | Local branches: create one without switching HEAD, list them, delete one, rename one, and configure upstream. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/index.html) |
| `grit_lib::porcelain::branch::BranchCreateOptions` | struct | Inputs for Branches::create. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.BranchCreateOptions.html) |
| `grit_lib::porcelain::branch::BranchDeleteMode` | enum | Safe delete requires the tip to be merged; force skips the check. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/enum.BranchDeleteMode.html) |
| `grit_lib::porcelain::branch::BranchDeleteOptions` | struct | Options for Branches::delete. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.BranchDeleteOptions.html) |
| `grit_lib::porcelain::branch::BranchError` | enum | Branch create, delete, and upstream failures. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/enum.BranchError.html) |
| `grit_lib::porcelain::branch::BranchList` | struct | Result of [list_branches]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.BranchList.html) |
| `grit_lib::porcelain::branch::BranchRenameOptions` | struct | Options for Branches::rename. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.BranchRenameOptions.html) |
| `grit_lib::porcelain::branch::CreateBranchOutcome` | struct | Outcome of [create_branch]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.CreateBranchOutcome.html) |
| `grit_lib::porcelain::branch::DeletedBranch` | struct | Result of Branches::delete. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.DeletedBranch.html) |
| `grit_lib::porcelain::branch::LocalBranch` | struct | One local branch in a BranchList. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.LocalBranch.html) |
| `grit_lib::porcelain::branch::RenameBranchOutcome` | struct | Outcome of [rename_branch]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.RenameBranchOutcome.html) |
| `grit_lib::porcelain::branch::StartPoint` | struct | Start commit and reflog label for crate::porcelain::branch::BranchCreateOptions::start. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.StartPoint.html) |
| `grit_lib::porcelain::branch::TrackMode` | enum | Whether creating a branch should configure branch.<name>.remote / .merge. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/enum.TrackMode.html) |
| `grit_lib::porcelain::checkout` | module | git checkout worktree-apply primitives. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/checkout/index.html) |
| `grit_lib::porcelain::checkout::CheckoutOutcome` | struct | Populated-tree checkout metadata (case-insensitive path collisions). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/checkout/struct.CheckoutOutcome.html) |
| `grit_lib::porcelain::checkout_reflog` | module | Reflog entries for branch checkout and branch creation (Git-compatible messages). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/checkout_reflog/index.html) |
| `grit_lib::porcelain::cherry_pick` | module | Merge-strategy helpers shared by pick/revert replay and other tree merges. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/cherry_pick/index.html) |
| `grit_lib::porcelain::clean` | module | Remove untracked (and optionally ignored) paths from the work tree. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/clean/index.html) |
| `grit_lib::porcelain::clean::CleanOptions` | struct | Inputs for Checkout::clean. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/clean/struct.CleanOptions.html) |
| `grit_lib::porcelain::clean::CleanOutcome` | struct | Result of Checkout::clean. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/clean/struct.CleanOutcome.html) |
| `grit_lib::porcelain::clean::CleanScope` | enum | Which untracked/ignored paths Checkout::clean may remove. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/clean/enum.CleanScope.html) |
| `grit_lib::porcelain::commit` | module | Create a commit from the current index and move the checked-out branch. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/index.html) |
| `grit_lib::porcelain::commit::CommitAuthorInfo` | struct | Request plus scope for Commits::create and Commits::plan. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitAuthorInfo.html) |
| `grit_lib::porcelain::commit::CommitAuthorInfo` | struct | Author name, email, and date suffix from a written commit header line. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitAuthorInfo.html) |
| `grit_lib::porcelain::commit::CommitFile` | struct | One path-level change that would be recorded in a commit. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitFile.html) |
| `grit_lib::porcelain::commit::CommitOutcome` | struct | Result of [create_commit]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitOutcome.html) |
| `grit_lib::porcelain::commit::CommitPatchInput` | enum | Hunk ids or parsed patches for CommitScope::Patch. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/enum.CommitPatchInput.html) |
| `grit_lib::porcelain::commit::CommitPlan` | struct | Planned commit contents and metadata (see [plan_commit]). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitPlan.html) |
| `grit_lib::porcelain::commit::CommitRequest` | struct | Inputs for [create_commit]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitRequest.html) |
| `grit_lib::porcelain::commit::CommitScope` | enum | Which paths are included when recording a commit ([commit_with_scope]). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/enum.CommitScope.html) |
| `grit_lib::porcelain::commit::HookPolicy` | enum | Whether the verifying hooks run before a commit object is written. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/enum.HookPolicy.html) |
| `grit_lib::porcelain::hunk_select` | module | Select structured diff hunks by stable id and apply them to the index. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/hunk_select/index.html) |
| `grit_lib::porcelain::hunk_select::HunkSelectError` | enum | Failure while resolving or staging hunk ids. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/hunk_select/enum.HunkSelectError.html) |
| `grit_lib::porcelain::hunk_select::HunkSelection` | struct | Selected hunks by stable id and/or new-side line ranges. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/hunk_select/struct.HunkSelection.html) |
| `grit_lib::porcelain::hunk_select::LineRange` | struct | New-side line range for partial hunk staging (1-based, inclusive). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/hunk_select/struct.LineRange.html) |
| `grit_lib::porcelain::hunk_select::RestoreHunksOutcome` | struct | Outcome of [restore_hunks]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/hunk_select/struct.RestoreHunksOutcome.html) |
| `grit_lib::porcelain::hunk_select::StageHunksOutcome` | struct | Result of [stage_hunks]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/hunk_select/struct.StageHunksOutcome.html) |
| `grit_lib::porcelain::index_mode` | module | Explicit index file modes for paths where the worktree does not report executable bits. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/index_mode/index.html) |
| `grit_lib::porcelain::index_mode::StageExecutableHint` | enum | Whether staging should force the executable bit for matched regular files. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/index_mode/enum.StageExecutableHint.html) |
| `grit_lib::porcelain::log` | module | git log ref decoration as structured data. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/log/index.html) |
| `grit_lib::porcelain::log::CommitRefDecoration` | struct | One ref label attached to a commit for structured log/show JSON. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/log/struct.CommitRefDecoration.html) |
| `grit_lib::porcelain::log::CommitReuse` | trait | Commits a caller already holds, handed out once each so loaders skip the object read. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/log/trait.CommitReuse.html) |
| `grit_lib::porcelain::log::DecorationFilter` | struct | The --decorate-refs / --decorate-refs-exclude / log.excludeDecoration ref filter. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/log/struct.DecorationFilter.html) |
| `grit_lib::porcelain::log::DecorationItem` | struct | One ref (or synthetic label) attached to a commit for --decorate / %d. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/log/struct.DecorationItem.html) |
| `grit_lib::porcelain::log::DecorationKind` | enum | Decoration category for git log --decorate colouring (color.decorate.*). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/log/enum.DecorationKind.html) |
| `grit_lib::porcelain::log::DecorationOptions` | struct | Which refs RevWalk::decorations collects and how it names them. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/log/struct.DecorationOptions.html) |
| `grit_lib::porcelain::log::LoadedCommit` | struct | Commit metadata loaded once per oid for porcelain JSON (log, show, revs, …). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/log/struct.LoadedCommit.html) |
| `grit_lib::porcelain::merge` | module | git merge index/head algorithm core. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/index.html) |
| `grit_lib::porcelain::merge::ContinueOptions` | struct | Combined diff content for merge commits. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.ContinueOptions.html) |
| `grit_lib::porcelain::merge::ContinueOptions` | struct | Options for [continue_merge]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.ContinueOptions.html) |
| `grit_lib::porcelain::merge::ContinueOutcome` | struct | Result of [continue_merge]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.ContinueOutcome.html) |
| `grit_lib::porcelain::merge::FastForwardPolicy` | enum | Fast-forward policy for branch integration. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/enum.FastForwardPolicy.html) |
| `grit_lib::porcelain::merge::IntegrateBranchOptions` | struct | Fast-forward toggle for pull-style integration via Merge::integrate_into_branch (convert with From<IntegrateBranchOptions> into MergeOptions). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.IntegrateBranchOptions.html) |
| `grit_lib::porcelain::merge::IntegrateBranchOutcome` | enum | Result of integrating another branch into the current one ([integrate_branch]). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/enum.IntegrateBranchOutcome.html) |
| `grit_lib::porcelain::merge::MergeCommitMode` | enum | Whether integration stops before creating a commit. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/enum.MergeCommitMode.html) |
| `grit_lib::porcelain::merge::MergeDryRunPlan` | enum | Planned merge of other_oid into into_oid without touching refs, the index, merge state, or the working tree (same in-memory three-way merge as [predict_merge]). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/enum.MergeDryRunPlan.html) |
| `grit_lib::porcelain::merge::MergeOptions` | struct | Options for [integrate_branch_with]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergeOptions.html) |
| `grit_lib::porcelain::merge::MergePrediction` | enum | In-memory prediction of merging other_oid into the commit into_oid. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/enum.MergePrediction.html) |
| `grit_lib::porcelain::merge::MergePredictionOptions` | struct | Options for [predict_merge] and [write_merge_tree]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergePredictionOptions.html) |
| `grit_lib::porcelain::merge::MergeSource` | struct | The commit a merge brings in, and how its name was resolved ([resolve_merge_source]). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergeSource.html) |
| `grit_lib::porcelain::merge::MergeSourceKind` | enum | What kind of name a merge source was given by ([resolve_merge_source]). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/enum.MergeSourceKind.html) |
| `grit_lib::porcelain::merge::MergeTreeStage` | struct | One unmerged index entry of a WrittenMergeTree: the <mode> <oid> <stage> <path> rows git merge-tree --write-tree prints after the tree id. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergeTreeStage.html) |
| `grit_lib::porcelain::merge::WrittenMergeTree` | struct | A three-way merge result stored in the object database ([write_merge_tree]). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.WrittenMergeTree.html) |
| `grit_lib::porcelain::paths` | module | Remove and rename paths in the working tree and index (git rm / git mv semantics). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/paths/index.html) |
| `grit_lib::porcelain::paths::BlockedRemoval` | struct | A path [remove_paths] refused to remove, carried by crate::worktree::WorktreeError::RemoveBlocked. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/paths/struct.BlockedRemoval.html) |
| `grit_lib::porcelain::paths::MoveOptions` | struct | Options for [move_paths]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/paths/struct.MoveOptions.html) |
| `grit_lib::porcelain::paths::MoveOutcome` | struct | Result of [move_paths] and [move_path]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/paths/struct.MoveOutcome.html) |
| `grit_lib::porcelain::paths::PathMove` | struct | One tracked path rename performed by [move_paths]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/paths/struct.PathMove.html) |
| `grit_lib::porcelain::paths::RemoveBlockReason` | enum | Why [remove_paths] refused to remove a path without RemoveOptions::force. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/paths/enum.RemoveBlockReason.html) |
| `grit_lib::porcelain::paths::RemoveOptions` | struct | Options for [remove_paths]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/paths/struct.RemoveOptions.html) |
| `grit_lib::porcelain::paths::RemoveOutcome` | struct | Result of [remove_paths]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/paths/struct.RemoveOutcome.html) |
| `grit_lib::porcelain::pathspec_match` | module | Shared pathspec matching against index, HEAD tree, and worktree paths. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pathspec_match/index.html) |
| `grit_lib::porcelain::pull` | module | Fetch from a remote and integrate the configured upstream into the current branch. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/index.html) |
| `grit_lib::porcelain::pull::FetchedUpstream` | struct | An upstream commit pull integrates without fetching (PullOptions::upstream). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/struct.FetchedUpstream.html) |
| `grit_lib::porcelain::pull::PullCheck` | struct | Dry-run result for PullOptions::check. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/struct.PullCheck.html) |
| `grit_lib::porcelain::pull::PullError` | enum | Pull-specific failures from pull; fetch, merge, rebase, and repository failures are reported in their own areas. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/enum.PullError.html) |
| `grit_lib::porcelain::pull::PullMode` | enum | How pull integrates upstream commits when a fast-forward is not possible. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/enum.PullMode.html) |
| `grit_lib::porcelain::pull::PullOptions` | struct | Options for pull. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/struct.PullOptions.html) |
| `grit_lib::porcelain::pull::PullOutcome` | struct | Structured outcome of pull. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/struct.PullOutcome.html) |
| `grit_lib::porcelain::pull::PullResult` | enum | High-level result of a successful pull. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/enum.PullResult.html) |
| `grit_lib::porcelain::quote_path` | module | Shell-style path quoting for display. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/quote_path/index.html) |
| `grit_lib::porcelain::replay` | module | Single-commit replay (cherry-pick and revert) onto the current branch. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay/index.html) |
| `grit_lib::porcelain::replay::ReplayDirection` | enum | Whether [replay_commit] applies a commit’s patch or its inverse. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay/enum.ReplayDirection.html) |
| `grit_lib::porcelain::replay::ReplayOutcome` | enum | Result of [replay_commit]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay/enum.ReplayOutcome.html) |
| `grit_lib::porcelain::replay::ReplayRequest` | struct | Inputs for [replay_commit]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay/struct.ReplayRequest.html) |
| `grit_lib::porcelain::replay_sequence` | module | Multi-commit cherry-pick and revert sequences with Git-compatible on-disk state. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/index.html) |
| `grit_lib::porcelain::replay_sequence::ReplayAbortOutcome` | enum | Whether [abort_replay_sequence] rewound the branch or only cleared replay metadata. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/enum.ReplayAbortOutcome.html) |
| `grit_lib::porcelain::replay_sequence::ReplayCreated` | struct | One commit produced by a replay step, paired with its source. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/struct.ReplayCreated.html) |
| `grit_lib::porcelain::replay_sequence::ReplayEmptyPolicy` | enum | How to handle a replay step whose merged tree matches HEAD (empty patch). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/enum.ReplayEmptyPolicy.html) |
| `grit_lib::porcelain::replay_sequence::ReplayOptions` | struct | Per-sequence merge and message options (stored under .git/sequencer/opts for grit starts). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/struct.ReplayOptions.html) |
| `grit_lib::porcelain::replay_sequence::ReplaySequenceRequest` | struct | Inputs for [start_replay_sequence]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/struct.ReplaySequenceRequest.html) |
| `grit_lib::porcelain::replay_sequence::SequenceOutcome` | enum | Result of starting or advancing a replay sequence. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/enum.SequenceOutcome.html) |
| `grit_lib::porcelain::replay_sequence::SequencePrediction` | enum | In-memory prediction of [start_replay_sequence] (no refs, index, worktree, or on-disk object writes). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/enum.SequencePrediction.html) |
| `grit_lib::porcelain::reset` | module | Move HEAD and optionally the index and working tree to a target commit. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/reset/index.html) |
| `grit_lib::porcelain::reset::OrphanedCommitSummary` | struct | One commit that becomes unreachable when HEAD moves away from it. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/reset/struct.OrphanedCommitSummary.html) |
| `grit_lib::porcelain::reset::ResetMode` | enum | Which parts of the repository [reset_to_commit] updates. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/reset/enum.ResetMode.html) |
| `grit_lib::porcelain::reset::ResetOptions` | struct | Inputs for [reset_to_commit] and [preview_reset]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/reset/struct.ResetOptions.html) |
| `grit_lib::porcelain::reset::ResetOutcome` | struct | Result of [reset_to_commit]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/reset/struct.ResetOutcome.html) |
| `grit_lib::porcelain::reset::ResetPreview` | struct | Non-mutating preview of [reset_to_commit]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/reset/struct.ResetPreview.html) |
| `grit_lib::porcelain::restore` | module | Restore working tree and/or index paths from the index, HEAD, or another tree (git restore semantics). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/restore/index.html) |
| `grit_lib::porcelain::restore::ConflictSide` | enum | Unmerged index side to check out into the worktree (git restore --ours\|--theirs). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/restore/enum.ConflictSide.html) |
| `grit_lib::porcelain::restore::RestoreOptions` | struct | Options for [restore_paths], translated from the grit restore CLI. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/restore/struct.RestoreOptions.html) |
| `grit_lib::porcelain::restore::RestoreOutcome` | struct | Outcome of a restore operation: paths written and paths removed in each target. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/restore/struct.RestoreOutcome.html) |
| `grit_lib::porcelain::restore::RestoreSource` | enum | Where explicit --source content comes from; default targets use the index or HEAD. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/restore/enum.RestoreSource.html) |
| `grit_lib::porcelain::revert` | module | Revert-specific helpers (revision ordering and commit messages). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/revert/index.html) |
| `grit_lib::porcelain::stage_tracked` | module | Stage modifications and deletions of already-tracked paths (git commit -a / -a staging). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/stage_tracked/index.html) |
| `grit_lib::porcelain::stage_tracked::IndexStagingThresholds` | struct | Entry-count thresholds for bulk tracked restage behavior. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/stage_tracked/struct.IndexStagingThresholds.html) |
| `grit_lib::porcelain::stage_tracked::StageTrackedSummary` | struct | Summary of paths updated while staging tracked modifications/deletions. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/stage_tracked/struct.StageTrackedSummary.html) |
| `grit_lib::porcelain::staging` | module | Stage worktree changes into the index (grit add / commit -a engine). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/staging/index.html) |
| `grit_lib::porcelain::staging::StageWorktreeChangesOutcome` | struct | Result of [stage_worktree_changes]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/staging/struct.StageWorktreeChangesOutcome.html) |
| `grit_lib::porcelain::status` | module | git status as a structured operation. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/index.html) |
| `grit_lib::porcelain::status::ConflictGroup` | struct | Unmerged paths that share one ConflictKind, from StatusModel::conflict_groups. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.ConflictGroup.html) |
| `grit_lib::porcelain::status::ConflictGroup` | struct | Tracked paths that collide on a case-insensitive volume and share one on-disk file. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.ConflictGroup.html) |
| `grit_lib::porcelain::status::IgnoredMode` | enum | How ignored files are reported (git status --ignored[=<mode>]). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/enum.IgnoredMode.html) |
| `grit_lib::porcelain::status::InterruptedRewrite` | enum | How [status] dealt with an interrupted rewrite apply, from [crate::history::recover_interrupted_rewrite_apply]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/enum.InterruptedRewrite.html) |
| `grit_lib::porcelain::status::RenameDetection` | struct | Rename/copy detection settings for the status diffs (status.renames / --find-renames, status.renameLimit, copy detection). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.RenameDetection.html) |
| `grit_lib::porcelain::status::StatusAction` | enum | An everyday follow-up suggested by StatusGuidance::Actions. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/enum.StatusAction.html) |
| `grit_lib::porcelain::status::StatusGuidance` | enum | What to do next with the repository, from StatusModel::guidance. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/enum.StatusGuidance.html) |
| `grit_lib::porcelain::status::StatusModel` | struct | The computed result of git status: everything the renderers need, with no presentation applied. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.StatusModel.html) |
| `grit_lib::porcelain::status::StatusOptions` | struct | Inputs that drive what status computes. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.StatusOptions.html) |
| `grit_lib::porcelain::status::StatusShortLine` | enum | One line of compact status output before terminal path quoting. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/enum.StatusShortLine.html) |
| `grit_lib::porcelain::status::StatusShortPath` | enum | Path half of a StatusShortLine (single path or rename/copy endpoints). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/enum.StatusShortPath.html) |
| `grit_lib::porcelain::status::UntrackedCollectMeta` | struct | Side effects from an untracked/ignored walk beyond the path lists. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.UntrackedCollectMeta.html) |
| `grit_lib::porcelain::status::UntrackedMode` | enum | How untracked files are reported (git status --untracked-files=<mode>). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/enum.UntrackedMode.html) |
| `grit_lib::porcelain::switch` | module | Switch branches or detach HEAD at a commit, updating the working tree when needed. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/switch/index.html) |
| `grit_lib::porcelain::switch::SwitchMode` | enum | Resolved switch target after DWIM and revision parsing. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/switch/enum.SwitchMode.html) |
| `grit_lib::porcelain::switch::SwitchOptions` | struct | Inputs for [switch_repository]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/switch/struct.SwitchOptions.html) |
| `grit_lib::porcelain::switch::SwitchOutcome` | struct | Result of [switch_repository]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/switch/struct.SwitchOutcome.html) |
| `grit_lib::porcelain::tag` | module | Tag creation, listing, deletion, verification and the list filter/sort helpers. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/index.html) |
| `grit_lib::porcelain::tag::CreateTagOutcome` | struct | Result of [create_tag]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/struct.CreateTagOutcome.html) |
| `grit_lib::porcelain::tag::CreateTagRequest` | struct | Inputs for [create_tag]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/struct.CreateTagRequest.html) |
| `grit_lib::porcelain::tag::Ident` | struct | Parsed name and email from a Git identity line (without timestamp). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/struct.Ident.html) |
| `grit_lib::porcelain::tag::TagAnnotation` | struct | Annotated tag message and tagger metadata for list output. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/struct.TagAnnotation.html) |
| `grit_lib::porcelain::tag::TagDetail` | enum | Amount of tag metadata requested from [list_tags]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/enum.TagDetail.html) |
| `grit_lib::porcelain::tag::TagError` | enum | Tag create, delete, and verification failures. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/enum.TagError.html) |
| `grit_lib::porcelain::tag::TagKind` | enum | Whether a refs/tags/* ref is lightweight or an annotated tag object. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/enum.TagKind.html) |
| `grit_lib::porcelain::tag::TagList` | enum | Result rows returned by [list_tags] for the requested TagDetail. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/enum.TagList.html) |
| `grit_lib::porcelain::tag::TagSummary` | struct | One tag in the result of [list_tags]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/struct.TagSummary.html) |
| `grit_lib::porcelain::tag::VerifiedTag` | struct | Result of [verify_tag_by_name]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/struct.VerifiedTag.html) |
| `grit_lib::porcelain::terminal` | module | Terminal capability probes for porcelain output. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/terminal/index.html) |
| `grit_lib::porcelain::workspace_snapshot` | module | Capture and restore repository workspace state for undo logs (index with conflict stages, worktree bytes including conflict markers, HEAD, named refs, and in-progress operation sentinels). | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/workspace_snapshot/index.html) |
| `grit_lib::porcelain::workspace_snapshot::WorkspaceCaptureOptions` | struct | Options for [capture_workspace_snapshot]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/workspace_snapshot/struct.WorkspaceCaptureOptions.html) |
| `grit_lib::porcelain::workspace_snapshot::WorkspaceRestoreOptions` | struct | Options for [restore_workspace_snapshot]. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/workspace_snapshot/struct.WorkspaceRestoreOptions.html) |
| `grit_lib::porcelain::workspace_snapshot::WorkspaceSnapshot` | struct | A point-in-time workspace snapshot suitable for undo/redo in front ends. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/workspace_snapshot/struct.WorkspaceSnapshot.html) |
| `grit_lib::porcelain::worktree_guard` | module | Lightweight worktree cleanliness checks without a full status pass. | [API](https://docs.rs/grit-lib/latest/grit_lib/porcelain/worktree_guard/index.html) |
| `grit_lib::prelude` | module | The types most callers need, re-exported for use grit_lib::prelude::*;. | [API](https://docs.rs/grit-lib/latest/grit_lib/prelude/index.html) |
| `grit_lib::prelude::RepositoryOptions` | struct | Options passed to crate::repo::Repository::open, crate::repo::Repository::discover, and related entry points. | [API](https://docs.rs/grit-lib/latest/grit_lib/prelude/struct.RepositoryOptions.html) |
| `grit_lib::progress` | module | Progress reporting and cancellation across the library/CLI boundary. | [API](https://docs.rs/grit-lib/latest/grit_lib/progress/index.html) |
| `grit_lib::progress::CancelToken` | struct | Cooperative cancellation handle shared across threads (Clone shares the same flag). | [API](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html) |
| `grit_lib::progress::FetchMilestone` | enum | A point reached in a wire fetch, reported through ProgressSink::milestone. | [API](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.FetchMilestone.html) |
| `grit_lib::progress::NullProgress` | struct | A ProgressSink that discards every update. | [API](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.NullProgress.html) |
| `grit_lib::progress::OverallEstimate` | struct | A snapshot of overall progress. | [API](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.OverallEstimate.html) |
| `grit_lib::progress::OverallEstimator` | struct | Combines per-phase progress into one overall estimate. | [API](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.OverallEstimator.html) |
| `grit_lib::progress::PhaseRates` | struct | Typical throughput used to size phases that have not started yet. | [API](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.PhaseRates.html) |
| `grit_lib::progress::ProgressPhase` | enum | A coarse phase of a long-running Git operation. | [API](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html) |
| `grit_lib::progress::ProgressSink` | trait | A sink for progress updates emitted by a library operation. | [API](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html) |
| `grit_lib::progress::ProgressUnit` | enum | Unit for ProgressSink::inc / ProgressSink::set during a phase. | [API](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressUnit.html) |
| `grit_lib::progress::ReceivedObjects` | struct | How far a pack transfer has got, counted in objects rather than bytes. | [API](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.ReceivedObjects.html) |
| `grit_lib::refs` | module | Reference storage — files backend + reftable backend. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/index.html) |
| `grit_lib::refs::BranchCommitRefUpdate` | struct | Move a checked-out branch to new_oid and append matching branch and HEAD reflogs. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.BranchCommitRefUpdate.html) |
| `grit_lib::refs::DwimMatch` | struct | The ref a short name such as main or v1.0 stands for, from References::dwim. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.DwimMatch.html) |
| `grit_lib::refs::LogRefsConfig` | enum | Core logAllRefUpdates modes (after config lookup), matching Git’s log_refs_config. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/enum.LogRefsConfig.html) |
| `grit_lib::refs::PackedRefRecord` | struct | One reference line (and optional peel) for [write_packed_refs_file]. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.PackedRefRecord.html) |
| `grit_lib::refs::PackedRefs` | struct | A one-time, in-memory snapshot of a ref store’s packed-refs file. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.PackedRefs.html) |
| `grit_lib::refs::RawRefLookup` | enum | Outcome of a single storage-level ref lookup (Git refs_read_raw_ref style). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/enum.RawRefLookup.html) |
| `grit_lib::refs::Ref` | enum | A symbolic or direct reference. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/enum.Ref.html) |
| `grit_lib::refs::RefBatchItem` | struct | One ref create/update/delete in a batch transaction (see crate::gc::update_refs). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.RefBatchItem.html) |
| `grit_lib::refs::RefUpdateCommitOutcome` | struct | Per-ref result from commit_ref_updates_non_atomic_on_store. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.RefUpdateCommitOutcome.html) |
| `grit_lib::refs::References` | struct | Resolve, list, and update refs for one open repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html) |
| `grit_lib::refs::RefnameUnavailable` | enum | Why a reference name cannot be created (Git refs_verify_refname_available style). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/enum.RefnameUnavailable.html) |
| `grit_lib::refs::branch_tracking` | module | branch_tracking API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/index.html) |
| `grit_lib::refs::branch_tracking::BaseSource` | enum | Where a ComparisonBase came from. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/enum.BaseSource.html) |
| `grit_lib::refs::branch_tracking::BoundedCommitSide` | struct | One side of a TargetComparison with total count, a bounded oid list, and truncation. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.BoundedCommitSide.html) |
| `grit_lib::refs::branch_tracking::BranchDetail` | enum | How much object data [list_branches] loads per branch. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/enum.BranchDetail.html) |
| `grit_lib::refs::branch_tracking::BranchListQuery` | struct | Query for [list_branches]: scope plus shared ref patterns, sort, and limit. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.BranchListQuery.html) |
| `grit_lib::refs::branch_tracking::BranchScope` | enum | Which branches to include in [list_branches]. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/enum.BranchScope.html) |
| `grit_lib::refs::branch_tracking::BranchStanding` | struct | Target and upstream standing for the current HEAD (status header / JSON). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.BranchStanding.html) |
| `grit_lib::refs::branch_tracking::BranchSummary` | struct | One row from [list_branches]. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.BranchSummary.html) |
| `grit_lib::refs::branch_tracking::ComparisonBase` | struct | A resolved branch that another branch is measured against. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.ComparisonBase.html) |
| `grit_lib::refs::branch_tracking::Standing` | enum | How a branch tip relates to its base, from symmetric ahead/behind counts. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/enum.Standing.html) |
| `grit_lib::refs::branch_tracking::StandingHeader` | enum | How the status header summarizes branch vs target/upstream (before merge/rebase overrides). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/enum.StandingHeader.html) |
| `grit_lib::refs::branch_tracking::StandingOptions` | struct | Options for BranchStanding::compute. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.StandingOptions.html) |
| `grit_lib::refs::branch_tracking::StatusHeader` | enum | Status header after branch standing and in-progress operation overrides. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/enum.StatusHeader.html) |
| `grit_lib::refs::branch_tracking::StatusIntegrationAction` | enum | Whether status should suggest grit pull or grit merge to catch up. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/enum.StatusIntegrationAction.html) |
| `grit_lib::refs::branch_tracking::StatusIntegrationHint` | struct | Footer hint for integrating commits the branch is behind. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.StatusIntegrationHint.html) |
| `grit_lib::refs::branch_tracking::TargetComparison` | struct | Ahead-of-target view of the current branch (grit shortlog / grit ahead). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.TargetComparison.html) |
| `grit_lib::refs::branch_tracking::TargetComparisonOptions` | struct | Options for compare_with_target. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.TargetComparisonOptions.html) |
| `grit_lib::refs::branch_tracking::TargetSpec` | struct | User-provided ref or revision to compare the current branch against. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.TargetSpec.html) |
| `grit_lib::refs::branch_tracking::TipComparison` | struct | Symmetric comparison of a branch tip with a base commit. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.TipComparison.html) |
| `grit_lib::refs::branch_tracking::TrackedComparison` | struct | Symmetric comparison of the current branch tip against one tracked ref (target or upstream). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.TrackedComparison.html) |
| `grit_lib::refs::branch_tracking::UpstreamStatus` | struct | Upstream of a local branch when branch.<name>.merge / .remote is set. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.UpstreamStatus.html) |
| `grit_lib::refs::check_ref_format` | module | check_ref_format API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/index.html) |
| `grit_lib::refs::check_ref_format::RefName` | struct | Validated full ref name (for example refs/heads/main). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefName.html) |
| `grit_lib::refs::check_ref_format::RefNameError` | enum | Errors returned by ref-name validation and RefName::parse. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/enum.RefNameError.html) |
| `grit_lib::refs::check_ref_format::RefNamePolicy` | struct | Options controlling how a ref name is validated when parsed. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefNamePolicy.html) |
| `grit_lib::refs::check_ref_format::RefNameRef` | struct | Borrowed validated ref name (like std::path::Path to std::path::PathBuf). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefNameRef.html) |
| `grit_lib::refs::gc` | module | In-process ref-transaction and loose-object prune helpers. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/gc/index.html) |
| `grit_lib::refs::gc::PruneStats` | struct | Result of a loose-object prune. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/gc/struct.PruneStats.html) |
| `grit_lib::refs::gc::RefTransactionItem` | struct | A single ref change in an update_refs batch transaction. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/gc/struct.RefTransactionItem.html) |
| `grit_lib::refs::hide_refs` | module | hide_refs API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/hide_refs/index.html) |
| `grit_lib::refs::listing` | module | Shared ref listing: namespace selection, glob patterns, sort keys, and limits. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/listing/index.html) |
| `grit_lib::refs::listing::RefKind` | enum | Class of ref for display and JSON (head, remote, tag, …). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/listing/enum.RefKind.html) |
| `grit_lib::refs::listing::RefListing` | struct | One ref returned from References::query or query_listings_from_pairs. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/listing/struct.RefListing.html) |
| `grit_lib::refs::listing::RefNamespace` | enum | Which ref namespace to include in a RefQuery. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/listing/enum.RefNamespace.html) |
| `grit_lib::refs::listing::RefQuery` | struct | Filters and ordering for a ref listing query. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/listing/struct.RefQuery.html) |
| `grit_lib::refs::listing::RefQueryOptions` | struct | Extra inputs for pattern matching and version sort (explicit config, no env reads). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/listing/struct.RefQueryOptions.html) |
| `grit_lib::refs::listing::RefSort` | struct | Sort direction and key for ref listing. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/listing/struct.RefSort.html) |
| `grit_lib::refs::listing::SortKey` | enum | Primary sort key for RefQuery. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/listing/enum.SortKey.html) |
| `grit_lib::refs::query_reachability` | module | Reachability filters for super::listing::RefQuery (--contains, --merged, …). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/query_reachability/index.html) |
| `grit_lib::refs::ref_namespace` | module | ref_namespace API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/ref_namespace/index.html) |
| `grit_lib::refs::ref_storage` | module | ref_storage API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/ref_storage/index.html) |
| `grit_lib::refs::ref_storage::RefStorageFormat` | enum | On-disk ref storage backend named by extensions.refStorage. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/ref_storage/enum.RefStorageFormat.html) |
| `grit_lib::refs::reflog` | module | reflog API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reflog/index.html) |
| `grit_lib::refs::reflog::MessageMatcher` | struct | Case-sensitive substring filter for reflog message text (--grep). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reflog/struct.MessageMatcher.html) |
| `grit_lib::refs::reflog::ReflogEntry` | struct | A single reflog entry. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reflog/struct.ReflogEntry.html) |
| `grit_lib::refs::reflog::ReflogExpireActionKind` | enum | What happened to one reflog entry during expire_reflog_git. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reflog/enum.ReflogExpireActionKind.html) |
| `grit_lib::refs::reflog::ReflogSelector` | struct | One entry in a reference log, indexed from its newest entry. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reflog/struct.ReflogSelector.html) |
| `grit_lib::refs::refs_fsck` | module | refs_fsck API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/refs_fsck/index.html) |
| `grit_lib::refs::refs_fsck::RefsFsckIssue` | struct | One diagnostic (use format_refs_fsck_line for Git-compatible output). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/refs_fsck/struct.RefsFsckIssue.html) |
| `grit_lib::refs::refs_fsck::RefsFsckSeverity` | enum | Severity of a refs-fsck diagnostic. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/refs_fsck/enum.RefsFsckSeverity.html) |
| `grit_lib::refs::refspec` | module | refspec API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/refspec/index.html) |
| `grit_lib::refs::refspec::RefspecError` | enum | Error returned when a refspec cannot be parsed. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/refspec/enum.RefspecError.html) |
| `grit_lib::refs::refspec::RefspecItem` | struct | A parsed refspec item. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/refspec/struct.RefspecItem.html) |
| `grit_lib::refs::reftable` | module | reftable API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/index.html) |
| `grit_lib::refs::reftable::LogRecord` | struct | A decoded log record. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/struct.LogRecord.html) |
| `grit_lib::refs::reftable::RefRecord` | struct | A decoded ref record. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/struct.RefRecord.html) |
| `grit_lib::refs::reftable::RefValue` | enum | A single reference record as stored in a reftable. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/enum.RefValue.html) |
| `grit_lib::refs::reftable::ReftableError` | enum | A reftable failure: malformed table bytes, a locked stack, or a rejected update. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/enum.ReftableError.html) |
| `grit_lib::refs::reftable::ReftableField` | enum | A field of a reftable file, named by ReftableError variants. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/enum.ReftableField.html) |
| `grit_lib::refs::reftable::ReftableReader` | struct | Reads a single reftable file from a byte buffer. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/struct.ReftableReader.html) |
| `grit_lib::refs::reftable::ReftableStack` | struct | Manages the $GIT_DIR/reftable/ directory and tables.list stack. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/struct.ReftableStack.html) |
| `grit_lib::refs::reftable::ReftableTransactionUpdate` | struct | A ref update that should be written to a reftable transaction. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/struct.ReftableTransactionUpdate.html) |
| `grit_lib::refs::reftable::ReftableWriteOptions` | struct | Repository-level overrides for reftable stack writes. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/struct.ReftableWriteOptions.html) |
| `grit_lib::refs::reftable::ReftableWriter` | struct | Writes a single reftable file. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/struct.ReftableWriter.html) |
| `grit_lib::refs::reftable::WriteOptions` | struct | Write options for reftable creation. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/struct.WriteOptions.html) |
| `grit_lib::refs::store` | module | Pluggable reference storage: typed transactions and backends. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/index.html) |
| `grit_lib::refs::store::BackendError` | struct | A custom ref backend’s storage error, carried by RefStoreError::Backend. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.BackendError.html) |
| `grit_lib::refs::store::Expected` | enum | Compare-and-swap expectation for a single ref update. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.Expected.html) |
| `grit_lib::refs::store::FilesRefStore` | struct | Loose + packed ref storage on disk. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.FilesRefStore.html) |
| `grit_lib::refs::store::FilesRefStoreConfig` | struct | Explicit context for a files ref store (no environment reads for namespace). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.FilesRefStoreConfig.html) |
| `grit_lib::refs::store::MemoryRefStore` | struct | Fully in-memory ref database with transactional updates. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.MemoryRefStore.html) |
| `grit_lib::refs::store::PreparedRefTransaction` | trait | Committable ref update batch returned from RefStore::prepare. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/trait.PreparedRefTransaction.html) |
| `grit_lib::refs::store::RawRef` | enum | Storage-level ref value without DWIM or resolution. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.RawRef.html) |
| `grit_lib::refs::store::RefCaseOnlyRename` | struct | Rename a loose ref when only letter case changes (case-insensitive filesystems). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefCaseOnlyRename.html) |
| `grit_lib::refs::store::RefEntry` | struct | One ref returned from iteration, optionally with a peeled object id. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefEntry.html) |
| `grit_lib::refs::store::RefName` | struct | Validated full ref name (for example refs/heads/main). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefName.html) |
| `grit_lib::refs::store::RefNameRef` | struct | Borrowed validated ref name (like std::path::Path to std::path::PathBuf). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefNameRef.html) |
| `grit_lib::refs::store::RefReflogRename` | struct | Move a branch reflog to a new ref name and append one entry (branch rename). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefReflogRename.html) |
| `grit_lib::refs::store::RefStorageFormat` | enum | Which physical backend backs a super::RefStore. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.RefStorageFormat.html) |
| `grit_lib::refs::store::RefStore` | trait | Reference storage backend (loose/packed files, reftable, or in-memory). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/trait.RefStore.html) |
| `grit_lib::refs::store::RefStoreError` | enum | Failure modes for reference store reads and transactions. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.RefStoreError.html) |
| `grit_lib::refs::store::RefTransaction` | struct | Batch of ref updates prepared for super::RefStore::prepare. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefTransaction.html) |
| `grit_lib::refs::store::RefUpdate` | struct | One ref create, update, delete, or reflog-only touch in a transaction. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefUpdate.html) |
| `grit_lib::refs::store::RefUpdateFlags` | struct | Per-update flags (Git REF_NO_DEREF / REF_LOG_ONLY / REF_SKIP_OID_VERIFICATION semantics). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefUpdateFlags.html) |
| `grit_lib::refs::store::ReflogUpdate` | struct | Metadata appended to a ref update for the reflog. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.ReflogUpdate.html) |
| `grit_lib::refs::store::ReftableRefStore` | struct | On-disk ref storage using the reftable backend (extensions.refStorage = reftable). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.ReftableRefStore.html) |
| `grit_lib::refs::store::SingleWriterGate` | struct | Fair FIFO gate for a single in-process writer slot. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.SingleWriterGate.html) |
| `grit_lib::refs::store::SingleWriterTicket` | struct | Holds the writer slot until dropped (commit, abort, or a failed prepare after acquire). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.SingleWriterTicket.html) |
| `grit_lib::refs::store::backend` | module | Building blocks for custom RefStore backends. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/backend/index.html) |
| `grit_lib::refs::store::backend::RefBatchState` | struct | Mutable ref + reflog state used to simulate or apply a transaction batch. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/backend/struct.RefBatchState.html) |
| `grit_lib::refs::store::paths` | module | Git ref-related paths under a repository directory (common dir or git dir). | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/store/paths/index.html) |
| `grit_lib::refs::version_sort` | module | Ref-name version ordering for version:refname sort. | [API](https://docs.rs/grit-lib/latest/grit_lib/refs/version_sort/index.html) |
| `grit_lib::remote` | module | Remotes, fetch/push, transport, and credential helpers. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/index.html) |
| `grit_lib::remote::HttpClientFactory` | trait | Builds HTTP clients for smart-HTTP remotes. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/trait.HttpClientFactory.html) |
| `grit_lib::remote::InspectOptions` | struct | Options for Remotes::inspect. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.InspectOptions.html) |
| `grit_lib::remote::ListRefsOptions` | struct | Options controlling Remote::list_refs output, aligned with git ls-remote. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.ListRefsOptions.html) |
| `grit_lib::remote::PeeledRemoteRef` | struct | One advertised ref with its peeled ^{} line folded in (see fold_peeled_refs). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.PeeledRemoteRef.html) |
| `grit_lib::remote::Remote` | struct | A resolved remote: name (if from config), URL(s), and fetch refspecs. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.Remote.html) |
| `grit_lib::remote::RemoteBranchState` | struct | One remote branch and how it relates to local tracking refs. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.RemoteBranchState.html) |
| `grit_lib::remote::RemoteBranchStateKind` | enum | Whether a remote branch is tracked locally, new on the remote, or stale locally. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/enum.RemoteBranchStateKind.html) |
| `grit_lib::remote::RemoteError` | enum | Errors for remote URL resolution, transport, fetch, push, and clone. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/enum.RemoteError.html) |
| `grit_lib::remote::RemotePullBranch` | struct | A local branch configured to pull from a remote via branch.* config. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.RemotePullBranch.html) |
| `grit_lib::remote::RemoteRef` | struct | A single reference returned by Remote::list_refs. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.RemoteRef.html) |
| `grit_lib::remote::RemoteSummary` | struct | Result of inspecting one configured remote. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.RemoteSummary.html) |
| `grit_lib::remote::RemoteUrl` | enum | A parsed remote URL by transport kind. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/enum.RemoteUrl.html) |
| `grit_lib::remote::bundle_uri` | module | bundle-uri API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/bundle_uri/index.html) |
| `grit_lib::remote::bundle_uri::BundleList` | struct | A bundle list as the bundle-uri command returns it. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/bundle_uri/struct.BundleList.html) |
| `grit_lib::remote::bundle_uri::BundleListEntry` | struct | One bundle in a BundleList. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/bundle_uri/struct.BundleListEntry.html) |
| `grit_lib::remote::bundle_uri::BundleListMode` | enum | How a client should use the bundles in a BundleList (bundle.mode). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/bundle_uri/enum.BundleListMode.html) |
| `grit_lib::remote::bundle_uri::BundleSeed` | enum | What [seed_from_bundle_uri] did. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/bundle_uri/enum.BundleSeed.html) |
| `grit_lib::remote::clone` | module | clone API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/index.html) |
| `grit_lib::remote::clone::CloneCheckout` | enum | Whether clone checked out the default branch or left the work tree empty. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/enum.CloneCheckout.html) |
| `grit_lib::remote::clone::CloneError` | enum | Clone-specific failures from clone; remote, object, and repository failures are reported in their own areas. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/enum.CloneError.html) |
| `grit_lib::remote::clone::CloneHead` | enum | Initial checkout disposition after clone (before working-tree checkout). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/enum.CloneHead.html) |
| `grit_lib::remote::clone::CloneIntoOptions` | struct | Options for clone_into: configure a remote and fetch into an already-open repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/struct.CloneIntoOptions.html) |
| `grit_lib::remote::clone::CloneIntoOutcome` | struct | Result of clone_into. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/struct.CloneIntoOutcome.html) |
| `grit_lib::remote::clone::CloneOptions` | struct | Options for clone. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/struct.CloneOptions.html) |
| `grit_lib::remote::clone::CloneOutcome` | struct | Result of a successful clone. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/struct.CloneOutcome.html) |
| `grit_lib::remote::clone::CloneTags` | enum | Which tags to fetch during clone, matching git clone tag behavior. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/enum.CloneTags.html) |
| `grit_lib::remote::credentials` | module | credentials API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/index.html) |
| `grit_lib::remote::credentials::Credential` | struct | A structured Git credential. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/struct.Credential.html) |
| `grit_lib::remote::credentials::CredentialProvider` | trait | The pluggable credential seam an embedder implements (or wraps). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/trait.CredentialProvider.html) |
| `grit_lib::remote::credentials::HelperCredentialProvider` | struct | Git-compatible CredentialProvider that runs the configured credential.helper programs. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/struct.HelperCredentialProvider.html) |
| `grit_lib::remote::credentials::HelperValueError` | enum | Why helper_config_value cannot express a helper command as a credential.helper value. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/enum.HelperValueError.html) |
| `grit_lib::remote::fetch_request` | module | Explicit fetch refspec resolution. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/fetch_request/index.html) |
| `grit_lib::remote::fetch_request::FetchInvocation` | struct | Remote name and explicit refspec strings after parsing grit fetch positionals. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/fetch_request/struct.FetchInvocation.html) |
| `grit_lib::remote::fetch_request::FetchRefspecError` | enum | Errors while resolving fetch refspecs before transfer. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/fetch_request/enum.FetchRefspecError.html) |
| `grit_lib::remote::partial_clone` | module | Partial-clone filter specs and promisor-remote config. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/partial_clone/index.html) |
| `grit_lib::remote::partial_clone::ObjectFilterSpec` | enum | Client-side object filter for fetch and clone (partial clone). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/partial_clone/enum.ObjectFilterSpec.html) |
| `grit_lib::remote::partial_clone::PartialCloneError` | enum | Errors parsing a partial-clone filter spec. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/partial_clone/enum.PartialCloneError.html) |
| `grit_lib::remote::pkt_line` | module | pkt-line framing for the wire protocol. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/pkt_line/index.html) |
| `grit_lib::remote::pkt_line::Packet` | enum | A single packet read from the wire. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/pkt_line/enum.Packet.html) |
| `grit_lib::remote::protocol` | module | protocol API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/protocol/index.html) |
| `grit_lib::remote::protocol::ProtocolError` | enum | Errors returned when a transport protocol is not allowed. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/protocol/enum.ProtocolError.html) |
| `grit_lib::remote::protocol::ProtocolPolicyInputs` | struct | Explicit inputs for protocol allow/deny evaluation. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/protocol/struct.ProtocolPolicyInputs.html) |
| `grit_lib::remote::push_bundle` | module | Resumable push bundle upload path suffix (smart HTTP servers). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/push_bundle/index.html) |
| `grit_lib::remote::push_plan` | module | Resolve remotes and refspecs for Remote::push. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/index.html) |
| `grit_lib::remote::push_plan::ForceMode` | enum | How non-fast-forward updates are allowed during a push. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/enum.ForceMode.html) |
| `grit_lib::remote::push_plan::LeaseExpectation` | enum | What a force-with-lease push compares the remote ref against. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/enum.LeaseExpectation.html) |
| `grit_lib::remote::push_plan::PushInvocation` | struct | Remote and refspec strings after classifying grit push [<remote>] [<refspec>...]. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/struct.PushInvocation.html) |
| `grit_lib::remote::push_plan::PushPlanContext` | struct | Extra inputs needed to DWIM delete targets and short push destinations. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/struct.PushPlanContext.html) |
| `grit_lib::remote::push_plan::PushPlanError` | enum | Errors while planning a push (typed; no stringly matching in callers). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/enum.PushPlanError.html) |
| `grit_lib::remote::push_plan::PushPlanKind` | enum | JSON / CLI classification of what was pushed. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/enum.PushPlanKind.html) |
| `grit_lib::remote::push_plan::PushRequest` | struct | What the caller wants to push (remote override, refspecs, tags, deletions). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/struct.PushRequest.html) |
| `grit_lib::remote::push_plan::ResolvedPush` | struct | A fully resolved push target. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/struct.ResolvedPush.html) |
| `grit_lib::remote::push_report` | module | push_report API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/push_report/index.html) |
| `grit_lib::remote::push_report::PushRefResult` | struct | One reference’s resolved push result, ready for display. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/push_report/struct.PushRefResult.html) |
| `grit_lib::remote::push_report::PushRefStatus` | enum | The resolved outcome of a single reference update during a push. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/push_report/enum.PushRefStatus.html) |
| `grit_lib::remote::resumable` | module | Resumable HTTP downloads and TUS uploads. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/resumable/index.html) |
| `grit_lib::remote::resumable::ResumableDownloadDest` | enum | Where to download when several processes share one resumable cache slot. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/resumable/enum.ResumableDownloadDest.html) |
| `grit_lib::remote::resumable::ResumableError` | enum | Why a resumable transfer failed. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/resumable/enum.ResumableError.html) |
| `grit_lib::remote::resumable::ResumableEvent` | enum | Progress of a resumable transfer, reported through ProgressSink::resumable_transfer. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/resumable/enum.ResumableEvent.html) |
| `grit_lib::remote::resumable::TransferDirection` | enum | Which way a resumable transfer moves data. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/resumable/enum.TransferDirection.html) |
| `grit_lib::remote::serve` | module | serve API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/index.html) |
| `grit_lib::remote::serve::DeepenNotError` | enum | Why a deepen-not argument was rejected; see ServeError::InvalidDeepenNot. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/enum.DeepenNotError.html) |
| `grit_lib::remote::serve::MissingObjectReason` | enum | Why a missing object could not be served; see ServeError::ObjectMissing. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/enum.MissingObjectReason.html) |
| `grit_lib::remote::serve::ProtocolVersion` | enum | Wire protocol version requested by the client. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/enum.ProtocolVersion.html) |
| `grit_lib::remote::serve::ReceiveHook` | trait | In-process checks an embedding server runs on every push. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/trait.ReceiveHook.html) |
| `grit_lib::remote::serve::ReceiveHookContext` | struct | Push options and other session context for ReceiveHook. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceiveHookContext.html) |
| `grit_lib::remote::serve::ReceiveOutcome` | struct | What a push session did. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceiveOutcome.html) |
| `grit_lib::remote::serve::ReceivePack` | struct | One push session served into a repository (the server side of git-receive-pack): advertise refs, read the ref updates and pack, store the objects, apply the updates, and report the result to the client. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePack.html) |
| `grit_lib::remote::serve::ReceivePolicy` | struct | Which pushed objects and ref updates the server refuses. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePolicy.html) |
| `grit_lib::remote::serve::RefCommand` | struct | One <old> <new> <ref> update requested by a pushing client. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.RefCommand.html) |
| `grit_lib::remote::serve::RefUpdateRefusal` | enum | Why the server refused one ref update. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/enum.RefUpdateRefusal.html) |
| `grit_lib::remote::serve::RefUpdateResult` | struct | The result of one requested ref update. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.RefUpdateResult.html) |
| `grit_lib::remote::serve::RequestBodyLimitExceeded` | struct | A fetch request body grew past the transport’s decoded-size limit. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.RequestBodyLimitExceeded.html) |
| `grit_lib::remote::serve::ServeError` | enum | Protocol-level failures while serving a fetch or a push; repository failures are reported in their own areas. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/enum.ServeError.html) |
| `grit_lib::remote::serve::ServeOptions` | struct | How a serving session is framed on the wire. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ServeOptions.html) |
| `grit_lib::remote::serve::UnpackError` | enum | Why a pushed pack could not be stored. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/enum.UnpackError.html) |
| `grit_lib::remote::serve::UploadOutcome` | struct | Summary of one completed or partial upload-pack session. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.UploadOutcome.html) |
| `grit_lib::remote::serve::UploadPack` | struct | One fetch session served from a repository (the server side of git-upload-pack): advertise refs, negotiate, and send a pack. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.UploadPack.html) |
| `grit_lib::remote::shallow` | module | Shallow-boundary helpers exposed for integration tests. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/shallow/index.html) |
| `grit_lib::remote::sideband_lines` | module | sideband_lines API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/sideband_lines/index.html) |
| `grit_lib::remote::sideband_lines::RemoteLine` | enum | One decoded fragment of remote progress text. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/sideband_lines/enum.RemoteLine.html) |
| `grit_lib::remote::sideband_lines::SidebandLines` | struct | Incrementally decode channel-2 progress bytes into RemoteLine items. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/sideband_lines/struct.SidebandLines.html) |
| `grit_lib::remote::transfer` | module | transfer API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/index.html) |
| `grit_lib::remote::transfer::CloneReflog` | struct | Identity and message for clone reflog entries written by the library. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.CloneReflog.html) |
| `grit_lib::remote::transfer::FetchAllOptions` | struct | Options for RepositoryRemotes::fetch_all: the shared settings for every remote, and command-line overrides of each remote’s prune and tag config. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchAllOptions.html) |
| `grit_lib::remote::transfer::FetchDepth` | enum | Shallow-history control for fetch and clone (--depth, --deepen, --unshallow). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/enum.FetchDepth.html) |
| `grit_lib::remote::transfer::FetchOptions` | struct | Options controlling a fetch. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOptions.html) |
| `grit_lib::remote::transfer::FetchOutcome` | struct | The structured result of a fetch, ready for the embedder’s ref-store apply. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOutcome.html) |
| `grit_lib::remote::transfer::PackBuildOptions` | struct | Options controlling pack-objects output (also used by build_pack). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PackBuildOptions.html) |
| `grit_lib::remote::transfer::PackObjects` | struct | Streaming pack-objects builder over an Odb. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PackObjects.html) |
| `grit_lib::remote::transfer::PackObjectsOptions` | struct | Extended options for PackObjects. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PackObjectsOptions.html) |
| `grit_lib::remote::transfer::PackStats` | struct | Counters reported after a successful pack write. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PackStats.html) |
| `grit_lib::remote::transfer::PushOptions` | struct | Options controlling a push. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PushOptions.html) |
| `grit_lib::remote::transfer::PushOutcome` | struct | The structured result of a push. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PushOutcome.html) |
| `grit_lib::remote::transfer::PushRefSpec` | struct | A single ref update requested by a push. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PushRefSpec.html) |
| `grit_lib::remote::transfer::RefUpdate` | struct | The resolved outcome of one reference during a fetch. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.RefUpdate.html) |
| `grit_lib::remote::transfer::TagMode` | enum | Which tags to fetch alongside the requested refs. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/enum.TagMode.html) |
| `grit_lib::remote::transfer::TransferEndpoint` | enum | The other side of a fetch or push whose transport the caller supplies, for RepositoryRemotes::fetch_from and RepositoryRemotes::push_to. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/enum.TransferEndpoint.html) |
| `grit_lib::remote::transfer::TransferStats` | struct | Object and byte counts for objects received during a fetch or clone. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.TransferStats.html) |
| `grit_lib::remote::transfer::UpdateKind` | enum | What a fetch did to one local ref, as reported to a user (UpdateMode::kind). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/enum.UpdateKind.html) |
| `grit_lib::remote::transfer::UpdateMode` | enum | How a single reference resolved during a fetch (or would resolve in a push). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/enum.UpdateMode.html) |
| `grit_lib::remote::transport` | module | transport API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/index.html) |
| `grit_lib::remote::transport::Advertisement` | struct | The captured ref/capability advertisement for a v0/v1 connection. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/struct.Advertisement.html) |
| `grit_lib::remote::transport::ConnectOptions` | struct | Options controlling the transport handshake. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/struct.ConnectOptions.html) |
| `grit_lib::remote::transport::Connection` | trait | A live, bidirectional pkt-line connection to a Git service, with the ref/capability advertisement captured during the handshake. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/trait.Connection.html) |
| `grit_lib::remote::transport::GitDaemonTransport` | struct | The native git:// daemon transport. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/struct.GitDaemonTransport.html) |
| `grit_lib::remote::transport::Service` | enum | The Git service a Connection speaks. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/enum.Service.html) |
| `grit_lib::remote::transport::SshCommand` | enum | How the SshTransport invokes ssh. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/enum.SshCommand.html) |
| `grit_lib::remote::transport::SshTransport` | struct | The ssh transport: spawn ssh [opts] <host> git-upload-pack '<path>' and expose the child’s stdio as a Connection. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/struct.SshTransport.html) |
| `grit_lib::remote::transport::Transport` | trait | A factory that connects to a remote and performs the protocol handshake. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/trait.Transport.html) |
| `grit_lib::remote::transport::http` | module | Smart-HTTP Git transport over a pluggable HTTP client. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/http/index.html) |
| `grit_lib::remote::transport::http::HttpClient` | trait | The minimal HTTP surface the smart-HTTP transport needs. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/http/trait.HttpClient.html) |
| `grit_lib::remote::transport::http::HttpMethod` | enum | Method of an HttpRequest. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/http/enum.HttpMethod.html) |
| `grit_lib::remote::transport::http::HttpRequest` | struct | A request for HttpClient::send. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/http/struct.HttpRequest.html) |
| `grit_lib::remote::transport::http::HttpResponse` | struct | A response from HttpClient::send. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/http/struct.HttpResponse.html) |
| `grit_lib::remote::transport::http::SmartHttpTransport` | struct | A smart-HTTP Transport over a pluggable HttpClient. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/http/struct.SmartHttpTransport.html) |
| `grit_lib::remote::transport_path` | module | transport_path API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport_path/index.html) |
| `grit_lib::remote::transport_path::NoDirectoryName` | struct | Error returned by [git_url_basename] when no directory name can be derived from a URL. | [API](https://docs.rs/grit-lib/latest/grit_lib/remote/transport_path/struct.NoDirectoryName.html) |
| `grit_lib::repo` | module | Repository discovery and the primary Repository handle. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/index.html) |
| `grit_lib::repo::DiscoveryInfo` | struct | Provenance flags recorded when a repository is discovered or opened explicitly. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.DiscoveryInfo.html) |
| `grit_lib::repo::InitOptions` | struct | Options for Repository::init. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.InitOptions.html) |
| `grit_lib::repo::InitOutcome` | struct | Result of Repository::init. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.InitOutcome.html) |
| `grit_lib::repo::Repository` | struct | A handle to an open Git repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) |
| `grit_lib::repo::RepositoryLocation` | struct | Where a repository lives on disk: its git directory and, when it has one, its work tree. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.RepositoryLocation.html) |
| `grit_lib::repo::caches` | module | Per-repository caches shared across open handles. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/caches/index.html) |
| `grit_lib::repo::caches::RepoCaches` | struct | Per-repository cache arena (held behind Arc on Repository). | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/caches/struct.RepoCaches.html) |
| `grit_lib::repo::error` | module | Repository layout, discovery, init, and embedding failures. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/error/index.html) |
| `grit_lib::repo::error::FilesOnlyOperation` | enum | An operation that only the files-backed object store supports. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html) |
| `grit_lib::repo::error::RepositoryError` | enum | Operation stopped because CancelToken fired before completion. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html) |
| `grit_lib::repo::error::RepositoryError` | enum | Failures opening, discovering, initializing, or validating a repository layout. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html) |
| `grit_lib::repo::error::RepositoryError` | enum | Per-repository caches shared across open handles. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html) |
| `grit_lib::repo::error::UnknownRepositoryExtensions` | struct | One or more unknown extensions.* keys (repository format version ≥ 1). | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/error/struct.UnknownRepositoryExtensions.html) |
| `grit_lib::repo::error::V1OnlyExtensionsInFormatZero` | struct | Format version 0 with extensions.* keys that require format version 1. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo/error/struct.V1OnlyExtensionsInFormatZero.html) |
| `grit_lib::repo_handles` | module | Typed Repository handles for remotes, worktrees, stash, notes, reflogs, and bundles. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/index.html) |
| `grit_lib::repo_handles::Branches` | struct | Branch create, delete, list, rename, upstream, and comparison helpers for one repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Branches.html) |
| `grit_lib::repo_handles::Checkout` | struct | Checkout, switch, reset, restore, clean, and worktree path maintenance for one repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Checkout.html) |
| `grit_lib::repo_handles::ConfiguredRemote` | struct | A remote that has a remote.<name>.* section in config. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.ConfiguredRemote.html) |
| `grit_lib::repo_handles::ExpireOptions` | struct | Options for RepositoryReflogs::expire. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.ExpireOptions.html) |
| `grit_lib::repo_handles::HookInfo` | struct | One hook script on disk. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.HookInfo.html) |
| `grit_lib::repo_handles::HookSource` | enum | Where a traditional hook script was discovered. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/enum.HookSource.html) |
| `grit_lib::repo_handles::IndexedReflogEntry` | struct | One reflog line with its newest-first index (0 is the latest entry). | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.IndexedReflogEntry.html) |
| `grit_lib::repo_handles::LockWorktreeOptions` | struct | Options for locking during RepositoryWorktrees::add or Worktrees::lock. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.LockWorktreeOptions.html) |
| `grit_lib::repo_handles::MessageMatcher` | struct | Case-sensitive substring filter for reflog message text (--grep). | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.MessageMatcher.html) |
| `grit_lib::repo_handles::Note` | struct | One note with its contents, from RepositoryNotes::list_with_bodies. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Note.html) |
| `grit_lib::repo_handles::NoteAddOutcome` | enum | What RepositoryNotes::add did to the annotated object’s note. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/enum.NoteAddOutcome.html) |
| `grit_lib::repo_handles::NoteAddPlan` | struct | Preview of RepositoryNotes::add without writing objects, refs, or reflogs. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.NoteAddPlan.html) |
| `grit_lib::repo_handles::NoteListing` | struct | One (annotated object, note blob) pair from a notes tree. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.NoteListing.html) |
| `grit_lib::repo_handles::NoteRemoveManyPlan` | struct | Preview of RepositoryNotes::remove_many without writing objects, refs, or reflogs. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.NoteRemoveManyPlan.html) |
| `grit_lib::repo_handles::NoteRemovePlan` | struct | Preview of removing a note on one object without writing objects, refs, or reflogs. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.NoteRemovePlan.html) |
| `grit_lib::repo_handles::NotesWriteOptions` | struct | Author, committer, and commit message for a notes ref update. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.NotesWriteOptions.html) |
| `grit_lib::repo_handles::RefExpireResult` | struct | Per-ref prune count from RepositoryReflogs::expire. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RefExpireResult.html) |
| `grit_lib::repo_handles::ReflogCreate` | enum | When RepositoryReflogs::append may start a reflog that does not exist yet. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/enum.ReflogCreate.html) |
| `grit_lib::repo_handles::ReflogExpireOutcome` | struct | Summary returned by RepositoryReflogs::expire. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.ReflogExpireOutcome.html) |
| `grit_lib::repo_handles::ReflogPage` | struct | One page of reflog query results. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.ReflogPage.html) |
| `grit_lib::repo_handles::ReflogQuery` | struct | Filters for RepositoryReflogs::query. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.ReflogQuery.html) |
| `grit_lib::repo_handles::RemoteRemoval` | struct | Outcome of removing a remote. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RemoteRemoval.html) |
| `grit_lib::repo_handles::RemoteRename` | struct | Result of RepositoryRemotes::rename. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RemoteRename.html) |
| `grit_lib::repo_handles::RemoteUrlKind` | enum | Which URL field RepositoryRemotes::set_url updates. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/enum.RemoteUrlKind.html) |
| `grit_lib::repo_handles::RemoveOptions` | struct | Options for RepositoryRemotes::remove. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RemoveOptions.html) |
| `grit_lib::repo_handles::RepositoryBundles` | struct | Bundle file operations for one open repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryBundles.html) |
| `grit_lib::repo_handles::RepositoryHooks` | struct | Hook discovery and dispatch for one open repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryHooks.html) |
| `grit_lib::repo_handles::RepositoryNotes` | struct | Notes read/write for one open repository (default ref: NotesRef::commits). | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryNotes.html) |
| `grit_lib::repo_handles::RepositoryReflogs` | struct | Reflog read/write helpers scoped to an open repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryReflogs.html) |
| `grit_lib::repo_handles::RepositoryRemotes` | struct | Remote names and network operations for one open repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html) |
| `grit_lib::repo_handles::RepositoryStash` | struct | Stash list/push/apply/pop/drop for one open repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryStash.html) |
| `grit_lib::repo_handles::RepositoryWorkspaceSnapshot` | struct | Capture and restore full workspace state (index stages, worktree, refs, operation sentinels). | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryWorkspaceSnapshot.html) |
| `grit_lib::repo_handles::RepositoryWorktrees` | struct | Worktree listing and linked-worktree mutations for one open repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryWorktrees.html) |
| `grit_lib::repo_handles::SetHead` | enum | How RepositoryRemotes::set_head updates refs/remotes/<name>/HEAD. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/enum.SetHead.html) |
| `grit_lib::repo_handles::SetHeadOutcome` | struct | Result of RepositoryRemotes::set_head. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.SetHeadOutcome.html) |
| `grit_lib::repo_handles::TagListOptions` | struct | Listing mode for Tags::list, collapsing [list_tags] and [list_tags_with_detail]. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.TagListOptions.html) |
| `grit_lib::repo_handles::Tags` | struct | Tag ref create, list, delete, and verify for one repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Tags.html) |
| `grit_lib::repo_handles::UrlChange` | struct | Result of RepositoryRemotes::set_url. | [API](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.UrlChange.html) |
| `grit_lib::revwalk` | module | Revision walking: rev-parse, rev-list, merge-base, and commit-graph acceleration. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/index.html) |
| `grit_lib::revwalk::AbbrevLength` | enum | How many hex digits RevWalk::abbreviate starts from. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.AbbrevLength.html) |
| `grit_lib::revwalk::AheadBehind` | struct | How far a commit is ahead of and behind another (RevWalk::ahead_behind). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.AheadBehind.html) |
| `grit_lib::revwalk::AheadBehindOptions` | struct | Options for RevWalk::ahead_behind. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.AheadBehindOptions.html) |
| `grit_lib::revwalk::CommitExtent` | enum | How much of each commit object a walk reads and hands back to its caller. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.CommitExtent.html) |
| `grit_lib::revwalk::DescribeOptions` | struct | Options for RevWalk::describe. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.DescribeOptions.html) |
| `grit_lib::revwalk::DescribedCommit` | struct | Result of a successful describe: nearest tag by exact range count. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.DescribedCommit.html) |
| `grit_lib::revwalk::GraphCharset` | struct | Character set for graph rendering. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.GraphCharset.html) |
| `grit_lib::revwalk::GraphCommitInput` | struct | One commit row fed into GraphLayout. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.GraphCommitInput.html) |
| `grit_lib::revwalk::GraphLayout` | struct | Incremental graph layout state. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.GraphLayout.html) |
| `grit_lib::revwalk::GraphLineKind` | enum | Kind of graph line relative to a commit entry. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.GraphLineKind.html) |
| `grit_lib::revwalk::GraphRenderedLine` | struct | A rendered graph prefix (two columns per lane: glyph + space), without commit text. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.GraphRenderedLine.html) |
| `grit_lib::revwalk::GraphRowTopology` | struct | Abstract lane topology for tests (column indices and parent edges). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.GraphRowTopology.html) |
| `grit_lib::revwalk::IndexDwim` | enum | How a name that matches no ref or object is treated: as a possible path (porcelain) or as a bad revision (plumbing). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.IndexDwim.html) |
| `grit_lib::revwalk::LeftRightCounts` | struct | Left/right commit counts for a symmetric range (A...B), matching git rev-list --left-right --count. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.LeftRightCounts.html) |
| `grit_lib::revwalk::MergeBaseMode` | enum | Which merge bases RevWalk::merge_bases computes. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.MergeBaseMode.html) |
| `grit_lib::revwalk::MergeFilter` | enum | Parent-count filter for commit lists (Git --merges / --no-merges). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.MergeFilter.html) |
| `grit_lib::revwalk::Peel` | enum | Object kind RevWalk::resolve peels the named object to. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.Peel.html) |
| `grit_lib::revwalk::ReachableWalkOptions` | struct | Options for RevWalk::reachable_excluding. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.ReachableWalkOptions.html) |
| `grit_lib::revwalk::RefSelection` | enum | Positive ref tips to include in a rev walk (Git --all, --branches, --tags, --remotes). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.RefSelection.html) |
| `grit_lib::revwalk::ResolveOptions` | struct | How RevWalk::resolve interprets a revision spec. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.ResolveOptions.html) |
| `grit_lib::revwalk::ResolvePurpose` | enum | The kind of argument being resolved, which tunes disambiguation like Git’s per-command lookups. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.ResolvePurpose.html) |
| `grit_lib::revwalk::RevWalkCommitIterOptions` | struct | Options for RevWalk::commits_iter: lazy commit-only walks without object/cherry tables. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkCommitIterOptions.html) |
| `grit_lib::revwalk::RevWalkCommitStream` | struct | Lazy commit walk over the same tokens and RevWalkListOptions as RevWalk::rev_list_result, for plain default-order reachable history. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkCommitStream.html) |
| `grit_lib::revwalk::RevWalkCommitStreamItem` | struct | One commit from RevWalk::commits_stream. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkCommitStreamItem.html) |
| `grit_lib::revwalk::RevWalkListOptions` | struct | Options for listing or counting commits through RevWalk. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkListOptions.html) |
| `grit_lib::revwalk::RevWalkParsedSpecs` | struct | Positive and negative revision specs produced by [parse_rev_walk_tokens]. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkParsedSpecs.html) |
| `grit_lib::revwalk::filter` | module | Commit message and identity filters for revision walks (--author, --grep, …). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/filter/index.html) |
| `grit_lib::revwalk::filter::CommitFilter` | struct | Compiled commit filter applied during [crate::rev_list::rev_list]. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/filter/struct.CommitFilter.html) |
| `grit_lib::revwalk::filter::CommitFilterBuilder` | struct | Builder for CommitFilter. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/filter/struct.CommitFilterBuilder.html) |
| `grit_lib::revwalk::filter::CommitFilterError` | enum | Invalid commit-filter pattern or compilation failure. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/filter/enum.CommitFilterError.html) |
| `grit_lib::revwalk::group_by` | module | Group walked commits for summary views (author shortlog-style reports). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/group_by/index.html) |
| `grit_lib::revwalk::group_by::AuthorGroup` | struct | One author’s commits after grouping a walk result. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/group_by/struct.AuthorGroup.html) |
| `grit_lib::revwalk::group_by::GroupByAuthorOptions` | struct | Options for RevWalk::group_by_author and RevWalk::group_by_author_in_walk. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/group_by/struct.GroupByAuthorOptions.html) |
| `grit_lib::revwalk::handle` | module | Repository-scoped revision parsing and walking via RevWalk. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/index.html) |
| `grit_lib::revwalk::handle::RevWalk` | struct | Parse revision specs and walk commit history for one repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html) |
| `grit_lib::revwalk::handle::RevWalkCommitIter` | struct | Iterator over commits from RevWalk::commits_iter. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalkCommitIter.html) |
| `grit_lib::revwalk::handle::StdinRevisionSpecs` | struct | Revision specs from RevWalk::parse_stdin_specs, ready for RevWalk::rev_list. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.StdinRevisionSpecs.html) |
| `grit_lib::revwalk::history` | module | In-memory history rewrite planning and apply. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/index.html) |
| `grit_lib::revwalk::history::AbsorbExcludedRef` | struct | A local branch tip excluded from the absorb stack when --base is omitted. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.AbsorbExcludedRef.html) |
| `grit_lib::revwalk::history::AbsorbOptions` | struct | Options for History::absorb. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.AbsorbOptions.html) |
| `grit_lib::revwalk::history::AbsorbPlan` | struct | Result of History::absorb: rewrite plan plus assignment detail. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.AbsorbPlan.html) |
| `grit_lib::revwalk::history::AppliedRewrite` | struct | Result of History::apply and the fixup and absorb applies. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.AppliedRewrite.html) |
| `grit_lib::revwalk::history::ApplyOptions` | struct | Identity and reflog text recorded when History::apply moves refs. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.ApplyOptions.html) |
| `grit_lib::revwalk::history::CommitEdit` | enum | Per-commit edit applied during planning. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.CommitEdit.html) |
| `grit_lib::revwalk::history::EmptyPolicy` | enum | Behavior when a replayed commit’s tree matches its new parent’s tree but did not before. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.EmptyPolicy.html) |
| `grit_lib::revwalk::history::ExecReport` | struct | Successful exec invocations captured during one verification or recovery call. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.ExecReport.html) |
| `grit_lib::revwalk::history::ExecRunRecord` | struct | One --exec invocation at a specific commit. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.ExecRunRecord.html) |
| `grit_lib::revwalk::history::ExecSpec` | struct | Shell commands to run at each replayed commit during rebase --exec. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.ExecSpec.html) |
| `grit_lib::revwalk::history::FixupOptions` | struct | Options for History::fixup. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.FixupOptions.html) |
| `grit_lib::revwalk::history::HeadEffect` | struct | Effect on HEAD from the rewrite (commit pointer and trees). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.HeadEffect.html) |
| `grit_lib::revwalk::history::History` | struct | History edits (reword, drop, move, fixup, squash, split, absorb), undo and rebase for one open repository, from Repository::history. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html) |
| `grit_lib::revwalk::history::HistoryError` | enum | Failure modes while building a super::RewritePlan. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html) |
| `grit_lib::revwalk::history::HistoryLastRecord` | struct | Parsed .git/grit/history-last contents. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.HistoryLastRecord.html) |
| `grit_lib::revwalk::history::HunkAssignment` | struct | A staged hunk assigned to a historical commit. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.HunkAssignment.html) |
| `grit_lib::revwalk::history::HunkRange` | struct | 1-based unified-diff style coordinates for one staged hunk. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.HunkRange.html) |
| `grit_lib::revwalk::history::NewCommit` | struct | Description of a new commit to insert immediately before an existing one. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.NewCommit.html) |
| `grit_lib::revwalk::history::Placement` | enum | Where to place a moved commit relative to an anchor on the first-parent chain. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.Placement.html) |
| `grit_lib::revwalk::history::PlannedRefUpdate` | struct | Planned movement of one ref (refs, index, and worktree are not updated by History::plan_rewrite). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.PlannedRefUpdate.html) |
| `grit_lib::revwalk::history::PlanningError` | enum | Failure modes for invalid planning inputs, as opposed to repository read failures (which surface as their own Error area). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.PlanningError.html) |
| `grit_lib::revwalk::history::PreRebase` | enum | Whether a rebase runs the pre-rebase hook before it rewrites anything, and what the hook is told. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.PreRebase.html) |
| `grit_lib::revwalk::history::RebaseAbort` | struct | Result of History::abort_rebase. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RebaseAbort.html) |
| `grit_lib::revwalk::history::RebaseCheckPlan` | enum | Predicted outcome of [plan_rebase_check] (no ref, index, or worktree updates). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebaseCheckPlan.html) |
| `grit_lib::revwalk::history::RebaseOntoOptions` | struct | Options for History::rebase_onto and History::plan_rebase. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RebaseOntoOptions.html) |
| `grit_lib::revwalk::history::RebaseOutcome` | enum | Result of starting or advancing a rebase session. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebaseOutcome.html) |
| `grit_lib::revwalk::history::RebasePlan` | enum | Result of History::plan_rebase: already current, a rewrite plan, or a conflict report (not an error). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebasePlan.html) |
| `grit_lib::revwalk::history::RebaseRequest` | struct | Inputs for History::plan_rebase, matching git rebase [--onto <base>] <upstream> on a single branch tip. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RebaseRequest.html) |
| `grit_lib::revwalk::history::RebaseSessionError` | enum | Failures while driving a rebase session. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebaseSessionError.html) |
| `grit_lib::revwalk::history::RebaseStop` | struct | Snapshot when a resumable rebase stops on conflicts. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RebaseStop.html) |
| `grit_lib::revwalk::history::RefScope` | enum | Which local refs may move when a plan is applied later. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RefScope.html) |
| `grit_lib::revwalk::history::RewordOptions` | struct | Fields to change when rewriting one commit’s message and/or author with History::reword. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewordOptions.html) |
| `grit_lib::revwalk::history::RewriteApplyRecovery` | enum | Outcome of History::recover_interrupted_apply. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RewriteApplyRecovery.html) |
| `grit_lib::revwalk::history::RewriteOptions` | struct | Inputs for History::plan_rewrite and the other history edits. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewriteOptions.html) |
| `grit_lib::revwalk::history::RewritePlan` | struct | Result of History::plan_rewrite: new objects are already in the ODB. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewritePlan.html) |
| `grit_lib::revwalk::history::RewrittenCommit` | struct | One original commit and its replacement (if any). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewrittenCommit.html) |
| `grit_lib::revwalk::history::SplitOptions` | struct | Options for History::split. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.SplitOptions.html) |
| `grit_lib::revwalk::history::SquashMessage` | enum | How to choose the message on the squashed commit. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.SquashMessage.html) |
| `grit_lib::revwalk::history::SquashOptions` | struct | Inputs for History::squash. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.SquashOptions.html) |
| `grit_lib::revwalk::history::StartRebaseOptions` | struct | Options for History::start_rebase, History::continue_rebase and History::skip_rebase. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.StartRebaseOptions.html) |
| `grit_lib::revwalk::history::UnassignedHunk` | struct | A staged hunk left in the index. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.UnassignedHunk.html) |
| `grit_lib::revwalk::history::UnassignedReason` | enum | Why a staged hunk could not be absorbed. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.UnassignedReason.html) |
| `grit_lib::revwalk::history::UndoMode` | enum | Whether History::undo_last moves refs or only reports what it would do. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.UndoMode.html) |
| `grit_lib::revwalk::history::UndoOutcome` | struct | Result of History::undo_last. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.UndoOutcome.html) |
| `grit_lib::revwalk::log_walk` | module | Log-order revision walking helpers re-exported at this path. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/log_walk/index.html) |
| `grit_lib::revwalk::log_walk::LogWalkCursor` | struct | Opaque continuation token for paged grit log history walks. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/log_walk/struct.LogWalkCursor.html) |
| `grit_lib::revwalk::log_walk::LogWalkPage` | struct | One page of commits plus an optional continuation cursor. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/log_walk/struct.LogWalkPage.html) |
| `grit_lib::revwalk::log_walk::LogWalkQuery` | struct | Tips, exclusions, and date cutoffs for a resumable date-order log walk. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/log_walk/struct.LogWalkQuery.html) |
| `grit_lib::revwalk::log_walk::WalkedCommits` | struct | Commit objects a log walk already read, kept as raw object bytes and parsed when taken. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/log_walk/struct.WalkedCommits.html) |
| `grit_lib::revwalk::merge_base` | module | merge_base API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/merge_base/index.html) |
| `grit_lib::revwalk::merge_base::ReachableCountFilter` | struct | Filters applied when counting reachable commits (parent count and committer dates). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/merge_base/struct.ReachableCountFilter.html) |
| `grit_lib::revwalk::merge_base::ReachableWalkCommitterCutoffs` | struct | Commits reachable from tips that are not ancestors of any hide tip, in committer-date order (newest first). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/merge_base/struct.ReachableWalkCommitterCutoffs.html) |
| `grit_lib::revwalk::merge_base::ReachableWalkLimit` | enum | How RevWalk::reachable_excluding bounds its output. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/merge_base/enum.ReachableWalkLimit.html) |
| `grit_lib::revwalk::object_inspect` | module | Typed revision resolution and object display payloads. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/object_inspect/index.html) |
| `grit_lib::revwalk::object_inspect::ObjectContents` | enum | Parsed object payload for display or serialization. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/object_inspect/enum.ObjectContents.html) |
| `grit_lib::revwalk::object_inspect::OidAbbrevBatch` | struct | Memoized collision-aware abbreviations for a batch of known-present object ids. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/object_inspect/struct.OidAbbrevBatch.html) |
| `grit_lib::revwalk::object_inspect::ResolveError` | enum | Failure resolving a revision spec for object inspection. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/object_inspect/enum.ResolveError.html) |
| `grit_lib::revwalk::object_inspect::ResolvedObject` | struct | Result of resolving one revision spec to a concrete object. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/object_inspect/struct.ResolvedObject.html) |
| `grit_lib::revwalk::object_inspect::ResolvedRefName` | struct | Full and shortened ref names for a spec (rev-parse --symbolic-full-name / --abbrev-ref). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/object_inspect/struct.ResolvedRefName.html) |
| `grit_lib::revwalk::object_inspect::RevisionLabel` | enum | A branch or tag label for a revision, independent of its display format. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/object_inspect/enum.RevisionLabel.html) |
| `grit_lib::revwalk::rev_list` | module | rev_list API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/index.html) |
| `grit_lib::revwalk::rev_list::CherryMatch` | struct | Commits on the two sides of a symmetric range (A...B) that share one patch-id. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.CherryMatch.html) |
| `grit_lib::revwalk::rev_list::CommitExtent` | enum | How much of each commit object a walk reads and hands back to its caller. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/enum.CommitExtent.html) |
| `grit_lib::revwalk::rev_list::FilterObjectKind` | enum | Kind selector for object:type=<kind> filters. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/enum.FilterObjectKind.html) |
| `grit_lib::revwalk::rev_list::LogGraphLinkage` | struct | Parents and subjects collected during a bounded --graph rev-list walk. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.LogGraphLinkage.html) |
| `grit_lib::revwalk::rev_list::MissingAction` | enum | Behavior when reachable objects are missing. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/enum.MissingAction.html) |
| `grit_lib::revwalk::rev_list::ObjectFilter` | enum | Object filter specification for --filter=. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/enum.ObjectFilter.html) |
| `grit_lib::revwalk::rev_list::ObjectFilterError` | enum | Why a --filter=<spec> value could not be parsed (ObjectFilter::parse). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/enum.ObjectFilterError.html) |
| `grit_lib::revwalk::rev_list::OrderingMode` | enum | Ordering mode for commit output. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/enum.OrderingMode.html) |
| `grit_lib::revwalk::rev_list::RevListOptions` | struct | Parsed and normalized options for rev-list traversal. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListOptions.html) |
| `grit_lib::revwalk::rev_list::RevListResult` | struct | Final commit selection result. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListResult.html) |
| `grit_lib::revwalk::rev_list_error` | module | Typed rev-list failures surfaced on crate::revwalk::RevWalk. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list_error/index.html) |
| `grit_lib::revwalk::rev_list_error::RevListError` | enum | Failure modes when walking revisions or parsing rev-list options. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list_error/enum.RevListError.html) |
| `grit_lib::revwalk::rev_parse` | module | rev_parse API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_parse/index.html) |
| `grit_lib::revwalk::rev_parse::IndexColonSpec` | struct | Parsed :path / :N:path index revision syntax (leading colon, not :/search). | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_parse/struct.IndexColonSpec.html) |
| `grit_lib::revwalk::rev_parse::TreeishBlobAtPath` | struct | Resolved blob (non-tree) at treeish:path for diff plumbing. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_parse/struct.TreeishBlobAtPath.html) |
| `grit_lib::revwalk::rev_parse_error` | module | Typed revision parsing failures. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_parse_error/index.html) |
| `grit_lib::revwalk::rev_parse_error::AmbiguousChangeIdHint` | struct | One commit when a change-id lookup is ambiguous. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_parse_error/struct.AmbiguousChangeIdHint.html) |
| `grit_lib::revwalk::rev_parse_error::AmbiguousObjectHint` | struct | One candidate line when a short object id is ambiguous. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_parse_error/struct.AmbiguousObjectHint.html) |
| `grit_lib::revwalk::rev_parse_error::RevParseError` | enum | Failure modes when resolving revision specs, upstream/push refs, paths, and reflogs. | [API](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_parse_error/enum.RevParseError.html) |
| `grit_lib::stash` | module | Stash stack read/write — stable types for RepositoryStash. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/index.html) |
| `grit_lib::stash::CorruptStashReason` | enum | Why a stash commit object cannot be interpreted for apply, show, or branch. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.CorruptStashReason.html) |
| `grit_lib::stash::FlatTreeEntry` | struct | A single blob entry from a recursively flattened tree. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.FlatTreeEntry.html) |
| `grit_lib::stash::StashApplyOptions` | struct | Options for RepositoryStash::apply and RepositoryStash::pop. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashApplyOptions.html) |
| `grit_lib::stash::StashApplyOutcome` | struct | Result of RepositoryStash::apply, RepositoryStash::apply_commit, and RepositoryStash::pop. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashApplyOutcome.html) |
| `grit_lib::stash::StashBranchOutcome` | struct | Result of RepositoryStash::branch. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashBranchOutcome.html) |
| `grit_lib::stash::StashDiffOptions` | struct | Options for RepositoryStash::diff. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashDiffOptions.html) |
| `grit_lib::stash::StashEntry` | struct | One entry from RepositoryStash::list (stash@{{index}} in newest-first order). | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashEntry.html) |
| `grit_lib::stash::StashError` | enum | Stash list, push, apply, pop, drop, and branch failures. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.StashError.html) |
| `grit_lib::stash::StashMode` | enum | Which local changes a stash push saves and how the worktree/index are left afterward. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.StashMode.html) |
| `grit_lib::stash::StashPreview` | struct | Paths that would be recorded by RepositoryStash::preview. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashPreview.html) |
| `grit_lib::stash::StashPushOptions` | struct | Options for RepositoryStash::push, RepositoryStash::create, and RepositoryStash::preview. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashPushOptions.html) |
| `grit_lib::stash::StashPushResult` | struct | Result of a successful RepositoryStash::push. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashPushResult.html) |
| `grit_lib::stash::StashPushValidationError` | enum | Incompatible super::stash::StashPushOptions flag combinations. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.StashPushValidationError.html) |
| `grit_lib::stash::StashReference` | enum | How to address a stash entry or a stash-shaped commit. | [API](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.StashReference.html) |
| `grit_lib::state` | module | Repository state machine — HEAD resolution, branch status, and in-progress operation detection. | [API](https://docs.rs/grit-lib/latest/grit_lib/state/index.html) |
| `grit_lib::state::HeadState` | enum | The current state of HEAD. | [API](https://docs.rs/grit-lib/latest/grit_lib/state/enum.HeadState.html) |
| `grit_lib::state::InProgressOperation` | enum | An in-progress operation that the repository is in the middle of. | [API](https://docs.rs/grit-lib/latest/grit_lib/state/enum.InProgressOperation.html) |
| `grit_lib::state::NextStep` | enum | A suggested follow-up action while an operation is paused. | [API](https://docs.rs/grit-lib/latest/grit_lib/state/enum.NextStep.html) |
| `grit_lib::state::Operation` | struct | In-progress operation plus the steps grit can suggest today. | [API](https://docs.rs/grit-lib/latest/grit_lib/state/struct.Operation.html) |
| `grit_lib::state::WtStatusState` | struct | Snapshot of repository state used by git status long-format output (wt-status.c). | [API](https://docs.rs/grit-lib/latest/grit_lib/state/struct.WtStatusState.html) |
| `grit_lib::status` | module | Working-tree status for one repository (Status from Repository::status). | [API](https://docs.rs/grit-lib/latest/grit_lib/status/index.html) |
| `grit_lib::status::Status` | struct | Compute staged, unstaged, untracked, and ignored paths for one repository. | [API](https://docs.rs/grit-lib/latest/grit_lib/status/struct.Status.html) |
| `grit_lib::status::StatusSummary` | struct | Typed dashboard outcome: worktree model plus branch standing and follow-up guidance. | [API](https://docs.rs/grit-lib/latest/grit_lib/status/struct.StatusSummary.html) |
| `grit_lib::status::StatusSummaryOptions` | struct | Options for super::Status::assemble_summary. | [API](https://docs.rs/grit-lib/latest/grit_lib/status/struct.StatusSummaryOptions.html) |
| `grit_lib::status::UntrackedCachePolicy` | enum | Whether untracked collection may refresh and read the index UNTR extension. | [API](https://docs.rs/grit-lib/latest/grit_lib/status/enum.UntrackedCachePolicy.html) |
| `grit_lib::status::UntrackedOptions` | struct | Options for Status::untracked and related untracked walks. | [API](https://docs.rs/grit-lib/latest/grit_lib/status/struct.UntrackedOptions.html) |
| `grit_lib::tree_sha256` | module | SHA-256 tree digest over repository file contents (tree-sha256 spec). | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/index.html) |
| `grit_lib::tree_sha256::MissingSubmodule` | struct | One submodule that blocked hashing. | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.MissingSubmodule.html) |
| `grit_lib::tree_sha256::MissingSubmoduleReason` | enum | Why a submodule could not be hashed. | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/enum.MissingSubmoduleReason.html) |
| `grit_lib::tree_sha256::SignatureVerdict` | enum | Signature verification outcome for a tag object. | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/enum.SignatureVerdict.html) |
| `grit_lib::tree_sha256::TagTreeSha256Outcome` | struct | Tree-sha256 digest, counts, and timing from explicit tag creation (CreateTagRequest::tree_sha256). | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TagTreeSha256Outcome.html) |
| `grit_lib::tree_sha256::TagVerification` | struct | Combined signature and tree-sha256 verification outcome. | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TagVerification.html) |
| `grit_lib::tree_sha256::TagVerifyOptions` | struct | Options for verify_tag. | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TagVerifyOptions.html) |
| `grit_lib::tree_sha256::TreeSha256` | struct | 32-byte tree-sha256 digest. | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256.html) |
| `grit_lib::tree_sha256::TreeSha256Claim` | struct | Digest and excluded submodule paths recorded on an annotated tag. | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256Claim.html) |
| `grit_lib::tree_sha256::TreeSha256ClaimError` | enum | Failure modes when reading or validating a TreeSha256Claim from tag headers. | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/enum.TreeSha256ClaimError.html) |
| `grit_lib::tree_sha256::TreeSha256Options` | struct | Submodule exclusion and glob options for Repository::tree_sha256. | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256Options.html) |
| `grit_lib::tree_sha256::TreeSha256Report` | struct | Outcome of a successful tree-sha256 computation. | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256Report.html) |
| `grit_lib::tree_sha256::TreeSha256TagHeaders` | struct | Parsed tree-sha256-related headers from a raw annotated tag object. | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256TagHeaders.html) |
| `grit_lib::tree_sha256::TreeSha256Verdict` | struct | Recomputed tree-sha256 compared to the tag header claim. | [API](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256Verdict.html) |
| `grit_lib::worktree` | module | Working tree, ignore/attributes, and checkout path helpers. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/index.html) |
| `grit_lib::worktree::AddLinkedWorktreeOptions` | struct | Options for RepositoryWorktrees::add. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.AddLinkedWorktreeOptions.html) |
| `grit_lib::worktree::LinkedWorktreeError` | enum | Linked worktree registry failures (add, remove, move, lock, repair). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.LinkedWorktreeError.html) |
| `grit_lib::worktree::LinkedWorktreeOperation` | enum | Linked worktree mutation that was pointed at the main working tree. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.LinkedWorktreeOperation.html) |
| `grit_lib::worktree::LockWorktreeOptions` | struct | Options for locking during RepositoryWorktrees::add or Worktrees::lock. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.LockWorktreeOptions.html) |
| `grit_lib::worktree::MoveWorktreeOptions` | struct | Options for [move_linked_worktree]. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.MoveWorktreeOptions.html) |
| `grit_lib::worktree::PrunableReason` | enum | Why Git marks a linked worktree as prunable in worktree list --porcelain. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.PrunableReason.html) |
| `grit_lib::worktree::PruneWorktreesOptions` | struct | Options for [prune_linked_worktrees]. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.PruneWorktreesOptions.html) |
| `grit_lib::worktree::PrunedWorktreeEntry` | struct | One linked worktree removed or that would be removed by [prune_linked_worktrees]. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.PrunedWorktreeEntry.html) |
| `grit_lib::worktree::WorktreeBranch` | enum | How RepositoryWorktrees::add attaches HEAD to a branch. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.WorktreeBranch.html) |
| `grit_lib::worktree::WorktreeEntry` | struct | One row returned by [list_worktrees]. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.WorktreeEntry.html) |
| `grit_lib::worktree::WorktreeError` | enum | Worktree-area failure (checkout, status, add/rm/mv/restore/clean, pathspec, filters, linked worktrees). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.WorktreeError.html) |
| `grit_lib::worktree::WorktreeRepair` | struct | One repair action recorded by [repair_worktrees]. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.WorktreeRepair.html) |
| `grit_lib::worktree::WorktreeRepairKind` | enum | What [repair_worktrees] fixed for one worktree path. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.WorktreeRepairKind.html) |
| `grit_lib::worktree::attributes` | module | attributes API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/attributes/index.html) |
| `grit_lib::worktree::attributes::AttrRule` | struct | One line in a gitattributes file. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/attributes/struct.AttrRule.html) |
| `grit_lib::worktree::attributes::AttrValue` | enum | Parsed attribute value for display (check-attr output). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/attributes/enum.AttrValue.html) |
| `grit_lib::worktree::attributes::MacroTable` | struct | Macro definitions from [attr]name ... | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/attributes/struct.MacroTable.html) |
| `grit_lib::worktree::attributes::ParsedGitAttributes` | struct | Result of parsing a gitattributes file. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/attributes/struct.ParsedGitAttributes.html) |
| `grit_lib::worktree::crlf` | module | crlf API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/index.html) |
| `grit_lib::worktree::crlf::AutoCrlf` | enum | What core.autocrlf is set to. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/enum.AutoCrlf.html) |
| `grit_lib::worktree::crlf::ConversionConfig` | struct | Global conversion settings derived from config. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/struct.ConversionConfig.html) |
| `grit_lib::worktree::crlf::ConvertToGitOpts` | struct | Optional inputs for convert_to_git_with_opts (Git CONV_EOL_RENORMALIZE / index blob). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/struct.ConvertToGitOpts.html) |
| `grit_lib::worktree::crlf::CoreEol` | enum | What core.eol is set to. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/enum.CoreEol.html) |
| `grit_lib::worktree::crlf::CrlfLegacyAttr` | enum | Legacy crlf gitattribute (deprecated in Git; still honored for EOL conversion). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/enum.CrlfLegacyAttr.html) |
| `grit_lib::worktree::crlf::DiffAttr` | enum | How the diff gitattribute affects diff output. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/enum.DiffAttr.html) |
| `grit_lib::worktree::crlf::EolAttr` | enum | Per-file eol attribute from .gitattributes. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/enum.EolAttr.html) |
| `grit_lib::worktree::crlf::FileAttrs` | struct | Per-file attributes relevant to conversion. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/struct.FileAttrs.html) |
| `grit_lib::worktree::crlf::MergeAttr` | enum | Per-file merge attribute from .gitattributes. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/enum.MergeAttr.html) |
| `grit_lib::worktree::crlf::SafeCrlf` | enum | What core.safecrlf is set to. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/enum.SafeCrlf.html) |
| `grit_lib::worktree::crlf::TextAttr` | enum | Per-file text attribute from .gitattributes. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/enum.TextAttr.html) |
| `grit_lib::worktree::fsmonitor` | module | fsmonitor API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/fsmonitor/index.html) |
| `grit_lib::worktree::fsmonitor::FsmonitorQueryBoundary` | struct | Nanoseconds since the Unix epoch, sampled immediately before a fsmonitor hook query. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/fsmonitor/struct.FsmonitorQueryBoundary.html) |
| `grit_lib::worktree::ignore` | module | ignore API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/ignore/index.html) |
| `grit_lib::worktree::ignore::IgnoreCheck` | struct | Result of checking one path against repository ignore rules. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/ignore/struct.IgnoreCheck.html) |
| `grit_lib::worktree::ignore::IgnoreMatch` | struct | Metadata for a matching rule. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/ignore/struct.IgnoreMatch.html) |
| `grit_lib::worktree::ignore::IgnoreMatcher` | struct | Engine used to evaluate ignore patterns against repository-relative paths. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/ignore/struct.IgnoreMatcher.html) |
| `grit_lib::worktree::ignore::IgnorePatternList` | struct | Patterns parsed from one exclude file (such as a .gitignore), for matching single paths. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/ignore/struct.IgnorePatternList.html) |
| `grit_lib::worktree::ignore::IgnorePatternMatch` | struct | The pattern that decided an IgnorePatternList::last_match query. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/ignore/struct.IgnorePatternMatch.html) |
| `grit_lib::worktree::ignore::IgnoreSource` | enum | Where an ignore pattern was loaded from. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/ignore/enum.IgnoreSource.html) |
| `grit_lib::worktree::ignore::RepoPathNormalizer` | struct | Converts user-supplied paths, relative to one working directory, into normalized repository-relative paths (as normalize_repo_relative does for a single path). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/ignore/struct.RepoPathNormalizer.html) |
| `grit_lib::worktree::pathspec` | module | pathspec API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/index.html) |
| `grit_lib::worktree::pathspec::PathspecFile` | struct | Raw bytes for [ResolvedPathspecs::resolve] from --pathspec-from-file (read by the caller). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.PathspecFile.html) |
| `grit_lib::worktree::pathspec::PathspecGlobalFlags` | struct | Git global pathspec mode flags (GIT_LITERAL_PATHSPECS, GIT_GLOB_PATHSPECS, …). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.PathspecGlobalFlags.html) |
| `grit_lib::worktree::pathspec::PathspecGlobalsError` | enum | Global pathspec flags (GIT_*_PATHSPECS) that cannot be combined. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/enum.PathspecGlobalsError.html) |
| `grit_lib::worktree::pathspec::PathspecOptions` | struct | Options for building a Pathspec (Pathspec::parse or Repository::pathspec). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.PathspecOptions.html) |
| `grit_lib::worktree::pathspec::PathspecParseError` | enum | Errors while assembling pathspec argv / from-file tokens (before work-tree resolution). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/enum.PathspecParseError.html) |
| `grit_lib::worktree::wildmatch` | module | wildmatch API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/wildmatch/index.html) |
| `grit_lib::worktree::worktree_cwd` | module | worktree_cwd API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/worktree_cwd/index.html) |
| `grit_lib::worktree::worktree_ref` | module | worktree_ref API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/worktree_ref/index.html) |
| `grit_lib::worktree::worktree_ref::RefWorktreeType` | enum | How a ref name maps to on-disk storage across worktrees. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/worktree_ref/enum.RefWorktreeType.html) |
| `grit_lib::worktree::worktree_rules` | module | worktree_rules API (re-exported at this path). | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/worktree_rules/index.html) |
| `grit_lib::worktree::worktree_rules::WorktreeRules` | struct | Attribute/ignore/conversion state shared across one porcelain operation. | [API](https://docs.rs/grit-lib/latest/grit_lib/worktree/worktree_rules/struct.WorktreeRules.html) |

# https://grit-scm.com/docs/library/bitmaps/index.md

# Reachability bitmaps

> Query pack and MIDX commit bitmaps for fast object reachability and counting.

Git stores optional **reachability bitmaps** alongside pack and multi-pack-index (MIDX) files. grit-lib reads and writes Git-compatible **BITM v1** sidecars (EWAH-compressed sets, XOR commit chains, optional name-hash cache and lookup table). Use them for fast rev-list counting, fetch negotiation, and pack generation without walking the full object graph on every request.

For pack-only write options and on-disk layout details, see the **pack-bitmaps** guide page in this section (`content/docs/library/pack-bitmaps.md`).

## Reading pack and MIDX bitmaps

[`BitmapIndex::open`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html) on a [`Repository`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) picks the active index: **MIDX bitmap when present**, otherwise the largest pack’s `.bitmap`. It returns `Ok(None)` when no valid sidecar exists (missing file, zero-byte placeholder, or corrupt header).

After open:

- [`BitmapIndex::commit_bitmap`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html) decodes one commit’s reachability set (type-filtered EWAH).
- [`BitmapIndex::oid_at`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html) / [`object_count`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html) map pack positions to object ids.
- Optional [`name_hash`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html) entries come from the name-hash cache (path hashes during tree walks).
- [`has_lookup_table`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html) reports whether a lookup table chunk is present.

Integration tests in `grit-lib/tests/pack_bitmap_read_git_compat.rs` round-trip **git-written** and **grit-written** pack bitmaps and MIDX bitmaps against `git rev-list --test-bitmap`.

## Querying reachability

[`BitmapIndex::reachability`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html) (see the [`objects::bitmap`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/index.html) domain module) takes a [`ReachabilityQuery`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.ReachabilityQuery.html) (wants, haves, optional [`ObjectFilter`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/enum.ObjectFilter.html)), and [`MissingAction`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/enum.MissingAction.html) for missing links. It returns [`ReachableSet`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.ReachableSet.html) or [`BitmapWalkUnsupported`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapWalkUnsupported.html) when the repository is shallow or the filter needs a non-bitmap walk (`sparse:oid`, `tree:<n>` with `n > 0`, and similar).

[`ReachableSet`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.ReachableSet.html) exposes `object_ids` for indexed and **extended** (out-of-namespace) objects, and `iter_grouped_by_kind` for oids in Git’s bitmap order (commits, trees, blobs, tags).

[`BitmapIndex::verify_commit`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html) compares a stored commit bitmap with a fresh non-bitmap walk (same idea as `git rev-list --test-bitmap`).

## Writing pack bitmaps

[`PackBitmapWriter`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.PackBitmapWriter.html) and [`Repository::write_largest_pack_bitmap`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) build a `.bitmap` for an **existing** pack index whose objects are closed under reachability from the repository’s refs (typical after `git repack -ad`). Pass [`PackBitmapWriteOptions`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.PackBitmapWriteOptions.html) explicitly, or use [`ConfigSet::pack_bitmap_write_options`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html) for Git’s `pack.writeBitmapHashCache`, `pack.writeBitmapLookupTable`, and `pack.preferBitmapTips`.

If no `.rev` sidecar exists, the writer creates one so object order matches Git’s pack-offset order. Output is deterministic for identical inputs. A pack that is not closed under reachability returns [`PackBitmapWriteError::NotClosed`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/enum.PackBitmapWriteError.html).

## MIDX bitmaps

When grit writes or compacts a multi-pack-index with bitmap support enabled, it emits real MIDX `.bitmap` chunks (and matching `.rev` sidecars) instead of zero-byte placeholders. [`BitmapIndex::open`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html) prefers that MIDX bitmap for reachability queries. See `grit-lib/tests/midx_write_coverage.rs` and `reads_git_midx_bitmap` in `pack_bitmap_read_git_compat.rs`.

## Fallback semantics

When bitmaps are missing, truncated, or unsupported for the requested walk:

- [`BitmapIndex::open`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html) returns `Ok(None)`; callers fall back to graph walks.
- Corrupt sidecars may emit diagnostics (for example EWAH or index corruption) while still completing the operation via fallback where Git would.
- [`RevWalk::rev_list`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.rev_list) uses bitmap fast paths when [`RevListOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListOptions.html) allow it (`--use-bitmap-index` semantics); incompatible options or shallow repos fall back transparently (see `grit-lib/tests/rev_list_bitmaps.rs`).
- [`build_pack`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_objects/fn.build_pack.html) and upload-pack use [`enumerate_pack_objects`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_object_select/fn.enumerate_pack_objects.html) when [`PackBuildOptions::use_bitmaps`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_objects/struct.PackBuildOptions.html) is true and a [`BitmapIndex`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html) is available; otherwise the object walk runs with the same resulting set.

## Not supported yet

- **Pseudo-merge** and other experimental bitmap encodings Git may gate behind feature flags.
- **Incremental MIDX** bitmap chains (Git rejects `repack -d` with bitmaps unless `--no-write-bitmap-index`; grit does not write bitmaps for incremental repacks).
- UX-only upstream cases (`--progress`, JGit interop, `pack.preferBitmapTips` misconfiguration messages) are not CLI goals; library APIs accept explicit tip lists via `PackBitmapWriteOptions`.

## Example

```rust
//! Count objects reachable from a commit using pack/MIDX bitmaps when available.
//!
//! Usage: `cargo run --example count_reachable -- <repo> <commit>`

use std::env;
use std::path::Path;
use std::process::ExitCode;
use std::sync::Arc;

use grit_lib::config::environment::RepositoryOptions;
use grit_lib::error::{Error, ObjectError};
use grit_lib::objects::bitmap::BitmapIndex;
use grit_lib::objects::bitmap::{BitmapWalkError, ReachabilityQuery};
use grit_lib::objects::ObjectId;
use grit_lib::repo::Repository;
use grit_lib::revwalk::rev_list::MissingAction;
use grit_lib::revwalk::{ResolveOptions, ResolvePurpose};

fn main() -> ExitCode {
    let mut args = env::args().skip(1);
    let Some(repo_path) = args.next() else {
        eprintln!("usage: count_reachable <repo> <commit>");
        return ExitCode::from(2);
    };
    let Some(rev) = args.next() else {
        eprintln!("usage: count_reachable <repo> <commit>");
        return ExitCode::from(2);
    };

    let repo = match Repository::discover(
        Some(Path::new(&repo_path)),
        &RepositoryOptions::from_process(),
    ) {
        Ok(r) => r,
        Err(err) => {
            eprintln!("open repository: {err}");
            return ExitCode::from(1);
        }
    };
    let commit: ObjectId = match repo.revwalk().resolve(
        &rev,
        &ResolveOptions::default().with_purpose(ResolvePurpose::RangeEnd),
    ) {
        Ok(oid) => oid,
        Err(err) => {
            eprintln!("resolve {rev}: {err}");
            return ExitCode::from(1);
        }
    };

    let index: Arc<BitmapIndex> = match BitmapIndex::open(&repo) {
        Ok(Some(idx)) => idx,
        Ok(None) => {
            eprintln!("no reachability bitmap in this repository");
            return ExitCode::from(1);
        }
        Err(err) => {
            eprintln!("open bitmap: {err}");
            return ExitCode::from(1);
        }
    };

    let wants = [commit];
    let query = ReachabilityQuery::new(&wants, &[]);
    match index.reachability(&repo, query, MissingAction::Error) {
        Ok(set) => {
            println!("reachable objects: {}", set.count());
            println!(
                "  commits: {}",
                set.count_by_kind(grit_lib::objects::ObjectKind::Commit)
                    .unwrap_or(0)
            );
            println!(
                "  trees: {}",
                set.count_by_kind(grit_lib::objects::ObjectKind::Tree)
                    .unwrap_or(0)
            );
            println!(
                "  blobs: {}",
                set.count_by_kind(grit_lib::objects::ObjectKind::Blob)
                    .unwrap_or(0)
            );
            println!(
                "  tags: {}",
                set.count_by_kind(grit_lib::objects::ObjectKind::Tag)
                    .unwrap_or(0)
            );
            ExitCode::SUCCESS
        }
        Err(Error::Object(ObjectError::BitmapWalk(BitmapWalkError::Unsupported(_)))) => {
            eprintln!("bitmap walk unsupported for this query (use rev-list without bitmaps)");
            ExitCode::from(1)
        }
        Err(err) => {
            eprintln!("bitmap walk failed: {err}");
            ExitCode::from(1)
        }
    }
}
```

Run against a repository with a pack bitmap (`git repack -adb` or grit’s writer):

```bash
cargo run --example count_reachable -- /path/to/repo HEAD
```

# https://grit-scm.com/docs/library/bundle/index.md

# Bundle

> Offline pack bundles — create, verify, list heads, unbundle, and fetch.

Git bundle files combine a header and thin pack for offline transfer. The [`bundle`](https://docs.rs/grit-lib/latest/grit_lib/bundle/index.html) domain implements read/write/verify compatible with system `git bundle`. [`Repository::bundles`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.bundles) returns [`RepositoryBundles`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryBundles.html) scoped to one open repository. Every operation has one method; long-running ones take a trailing `&mut dyn ProgressSink` and `&CancelToken` (pass `NullProgress` and `CancelToken::never()` when you need neither).

| Method | Role |
| --- | --- |
| `write` | Write a bundle file from `BundleSpec` tips (atomic replace via `*.bundle.part`); returns the ref count |
| `write_from_revs` | Same, from `bundle create`-style revision arguments (`BundleCreateOptions`: tips, `A..B`, `--all`) |
| `write_to` | Stream a bundle (header, then pack) into any `Write` |
| `plan_create` / `plan_create_from_revs` | Dry run: the refs, prerequisites and object count a write would produce |
| `verify` | Check prerequisites and connectivity (`BundleVerifyReport`) |
| `list_heads` | Parse ref tips from the header |
| `plan_unbundle` | Dry run of `unbundle`: verification and the ref updates it implies |
| `unbundle` | Ingest the pack without updating refs |
| `fetch` | `git fetch` from a bundle file: verify, ingest, and update refs per `FetchOptions` |

Failed or cancelled `write` calls leave an existing destination file unchanged. Grit writes to a sibling `path.bundle.part` and renames onto `path` only after the pack stream succeeds. Missing objects surface as [`ObjectError::NotFound`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.NotFound) under [`Error::Object`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Object), not a generic I/O string.

With a files-backed repository `unbundle` installs the pack under `objects/pack/`. With a custom primary object store it writes every object of the pack into that store instead (see [Object stores](https://grit-scm.com/docs/library/bundle/object-stores.md/index.md#receiving-packs-into-a-custom-store)).

[`write_to`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryBundles.html#method.write_to) streams the pack into the `Write` you pass (wrap files in a `BufWriter`), so the whole pack is never held in memory. When the repository has local packs, deltas and whole objects already stored there are copied verbatim instead of being recomputed, so bundling a packed repository costs about as much as copying its pack.

Cloning from a bundle path goes through the normal clone API; network transport is covered on the [Network](https://grit-scm.com/docs/library/network/index.md) page.

## Example

```rust
//! Create a bundle file and verify ref tips with [`Bundles`](https://grit-scm.com/docs/library/bundle/grit_lib::repo_handles::Bundles/index.md).
//!
//! Source for the library guide "Bundle" page (included in the docs site).

use anyhow::Result;
use grit_lib::bundle::BundleSpec;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::objects::ObjectId;
use grit_lib::progress::{CancelToken, NullProgress};
use grit_lib::repo::Repository;

use std::path::{Path, PathBuf};

fn open_repo(root: &Path) -> Result<Repository> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::from_process();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Ok(Repository::open(&git_dir, &opts)?)
}

fn main() -> Result<()> {
    let root = std::env::args()
        .nth(1)
        .map(PathBuf::from)
        .or_else(|| std::env::current_dir().ok())
        .ok_or_else(|| anyhow::anyhow!("missing repository path"))?;
    let bundle_path = std::env::args()
        .nth(2)
        .map(PathBuf::from)
        .unwrap_or_else(|| root.join("guide.bundle"));

    let repo = open_repo(&root)?;
    let head = repo.references().head()?;
    let tip: ObjectId = head
        .oid()
        .cloned()
        .ok_or_else(|| anyhow::anyhow!("HEAD has no commit"))?;

    repo.bundles().write(
        &BundleSpec::default().with_include(vec![(tip, "refs/heads/main".into())]),
        &bundle_path,
        &mut NullProgress,
        &CancelToken::never(),
    )?;

    let report = repo.bundles().verify(&bundle_path)?;
    println!("bundle_ok={}", report.is_ok());

    let heads = repo.bundles().list_heads(&bundle_path, None)?.items;
    for head in heads {
        println!("bundle_head {} {}", head.name, head.oid.to_hex());
    }

    Ok(())
}
```

```bash
cargo run --bin guide_bundle . /tmp/demo.bundle
git bundle verify /tmp/demo.bundle
```

The test runs `git bundle verify` on the file grit wrote.

# https://grit-scm.com/docs/library/change-ids/index.md

# Change ids

> Stable change-id commit headers, derivation, and grit.changeIds config.

Every commit Grit creates can carry a **`change-id`** header: an opaque token that stays with the same logical change across rewrites (amend, rebase, history edits). Commits without the header still have a **derived** id (Jujutsu-compatible) computed from the commit object id.

For CLI usage, interop, config, and revision syntax, see the [Change ids](https://grit-scm.com/docs/library/change-ids/index.md) guide.

## Header format

- Primary header: `change-id <value>`
- Legacy name: `gitbutler-change-id <value>` (read for compatibility; new writes use `change-id` only)
- Random ids use **reverse-hex**: 16 bytes encoded as 32 characters where nibble `n` maps to `'z' - n` (alphabet `k`–`z`).

[`ChangeId::from_bytes`](https://docs.rs/grit-lib/latest/grit_lib/change_id/struct.ChangeId.html#method.from_bytes) and [`ChangeId::parse_reverse_hex`](https://docs.rs/grit-lib/latest/grit_lib/change_id/struct.ChangeId.html#method.parse_reverse_hex) handle that encoding. Legacy values may be arbitrary strings (for example UUIDs).

## Reading and writing

On [`CommitData`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.CommitData.html):

- [`change_id`](https://docs.rs/grit-lib/latest/grit_lib/change_id/fn.change_id.html) — stored header if present
- [`set_change_id`](https://docs.rs/grit-lib/latest/grit_lib/change_id/fn.set_change_id.html) — set or replace the header before any `gpgsig` / `gpgsig-sha256` block
- [`resolved_change_id`](https://docs.rs/grit-lib/latest/grit_lib/change_id/fn.resolved_change_id.html) — stored id or [`ChangeId::derived_from_commit_id`](https://docs.rs/grit-lib/latest/grit_lib/change_id/struct.ChangeId.html#method.derived_from_commit_id)

Derivation takes object-id bytes `4..20`, reverses their order, bit-reverses each byte, then reverse-hex encodes (same scheme as Jujutsu/GitButler).

## Policy and config

[`ChangeIdPolicy::from_config`](https://docs.rs/grit-lib/latest/grit_lib/change_id/struct.ChangeIdPolicy.html#method.from_config) reads:

| Key | Default | Effect |
| --- | --- | --- |
| `grit.changeIds` | `true` | When false, [`id_for_new_commit`](https://docs.rs/grit-lib/latest/grit_lib/change_id/struct.ChangeIdPolicy.html#method.id_for_new_commit) returns `None` |
| `grit.testing.changeId` | unset | `content-hash` derives ids from the hash of the serialized commit without change-id headers; any other non-empty value is used verbatim as the id |

Embedders inject randomness with [`ChangeIdGenerator`](https://docs.rs/grit-lib/latest/grit_lib/change_id/trait.ChangeIdGenerator.html) on [`RepositoryOptions::with_change_id_generator`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_change_id_generator); [`Repository::change_id_generator`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.change_id_generator) exposes the active generator.

## Where ids are assigned

[`create_commit`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitRequest.html) (and the CLI `grit commit` built on it) applies [`ChangeIdPolicy`](https://docs.rs/grit-lib/latest/grit_lib/change_id/struct.ChangeIdPolicy.html) before serializing: new commits, the initial commit, merge conclusions, and amends that need a stored id. Amends keep an existing `change-id` / `gitbutler-change-id` header; when the replaced tip had none, the derived id from that tip is stored.

[`prepare_commit_bytes`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Objects.html#method.write_commit) and [`write_commit_object`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Objects.html#method.write_commit) do **not** add change ids — stash, notes, and other auxiliary commits stay header-free unless the caller sets one.

## Revisions

After refs and abbreviated object ids, grit resolves **change ids** as revision tokens:

- **Alphabet:** reverse-hex ids use `k`–`z` (4–32 characters). A token in that range is treated as a change-id prefix, not a Git object id.
- **Lookup:** [`find_commits_by_change_id_prefix`](https://docs.rs/grit-lib/latest/grit_lib/change_id/fn.find_commits_by_change_id_prefix.html) walks commits reachable from all refs and `HEAD` (not reflogs), compares [`resolved_change_id`](https://docs.rs/grit-lib/latest/grit_lib/change_id/fn.resolved_change_id.html) on each commit, and returns a unique match or [`RevParseError::AmbiguousChangeId`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_parse_error/enum.RevParseError.html#variant.AmbiguousChangeId). Stored headers are found on a custom object store too; see [Change ids and author counts](https://grit-scm.com/docs/library/object-stores/index.md#change-ids-and-author-counts) for what each lookup reads there.
- **Composition:** change ids compose with the usual suffixes — `\<cid\>~1`, `\<cid\>^`, `\<cid\>..main`, peel suffixes, and path suffixes — because they plug into the same base-name resolution as branches and short oids.
- **Precedence:** a branch or tag named like a change-id token wins (for example `refs/heads/zzzz` before the change-id `zzzz…`).

Use `grit resolve`, `grit show`, `grit log`, and other commands that take revisions; no separate flag is required.

## Git compatibility

The header is an ordinary commit header line. System `git` preserves it on read/write; `git fsck --strict` accepts commits that carry `change-id`.

# https://grit-scm.com/docs/library/config/index.md

# Config

> Merged config reads and scoped writes through Repository::config and ConfigEditor.

Configuration in grit-lib follows Git’s cascade (system, global, local, worktree, and environment overrides). Use [`Repository::config`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.config) for reads and for writes that target a scope in an open repository. For global, system, or `-f` file edits outside a repository, use [`ConfigEditor`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigEditor.html).

## Loading outside a handle

[`ConfigSet::load`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html) parses the cascade from disk given an [`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html) and optional git directory. The library does not read `std::env` during load — embedders pass variables explicitly (see [Embedding](https://grit-scm.com/docs/library/embedding/index.md) and [Repository](https://grit-scm.com/docs/library/repository/index.md)).

## Typed values

[`ConfigSet::get_bool`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.get_bool) and [`ConfigSet::get_i64`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.get_i64) return `None` for an unset key. A value of the wrong type is a [`ConfigError::InvalidValue`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ConfigError.html) carrying the key and a [`ConfigValueError`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ConfigValueError.html) that says what was wrong: not a boolean, an empty or malformed integer, an integer that overflows `i64` once its `k`/`m`/`g` suffix is applied, or a bad color. `get_bool(key).transpose()?` reads an optional boolean and propagates a bad value as `grit_lib::error::Error::Config`. The key-less parsers [`parse_bool`](https://docs.rs/grit-lib/latest/grit_lib/config/fn.parse_bool.html), [`parse_i64`](https://docs.rs/grit-lib/latest/grit_lib/config/fn.parse_i64.html) and [`parse_color`](https://docs.rs/grit-lib/latest/grit_lib/config/fn.parse_color.html) return the bare `ConfigValueError`; call `for_key` on it to attach the key.

For a setting with a Git default, apply it to the unset case: `config.get_bool("commit.autoStage")?.unwrap_or(true)`. The `core` booleans that many operations consult have accessors carrying Git's default: [`ignore_case`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.ignore_case) and [`precompose_unicode`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.precompose_unicode) (both `false`), and [`preload_index`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.preload_index) and [`file_mode`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.file_mode) (both `true`).

## Errors

Every config failure is a specific [`ConfigError`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ConfigError.html) variant with the offending key or value in its fields, so callers match on the variant instead of the message. For example, [`canonical_key`](https://docs.rs/grit-lib/latest/grit_lib/config/fn.canonical_key.html) returns `ConfigError::InvalidKey` with an [`InvalidKeyReason`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.InvalidKeyReason.html) naming the malformed part. Bad `GIT_CONFIG_COUNT` or `GIT_CONFIG_PARAMETERS` input is `InvalidEnvironmentCount`, `MissingEnvironmentKey` or `MalformedConfigParameters`. A value outside a key's fixed word list (`protocol.version`, `gpg.format`) is `UnknownValue`, and a `--local` or `--worktree` location without a repository is `RepositoryRequired`. [`ConfigSet::get_regexp`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.get_regexp) returns `ConfigError::InvalidPattern` when the pattern is not valid regex. [`validate_repo_config`](https://docs.rs/grit-lib/latest/grit_lib/repo/fn.validate_repo_config.html) returns `ConfigError::UnsupportedRepositoryFormatVersion` when `core.repositoryformatversion` is not supported. Submodule git-dir layout problems are not config errors. They are reported as `Error::Submodule` with a [`SubmoduleError`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.SubmoduleError.html).

## Writes

Pass a [`ConfigScope`](https://docs.rs/grit-lib/latest/grit_lib/config/enum.ConfigScope.html) (`Local`, `Worktree`, `Global`, or `System`) and [`ConfigWriteOptions`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigWriteOptions.html) to [`Config::set`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.set), [`Config::add_value`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.add_value), [`Config::unset`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.unset), [`Config::unset_all`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.unset_all), [`Config::rename_section`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.rename_section), or [`Config::remove_section`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.remove_section). Successful writes reload the in-memory snapshot on the open `Repository`. `ConfigWriteOptions` carries dry-run mode, optional `--type` canonicalization, Git-style `replace-all` with an optional value pattern, and unset value patterns instead of bare boolean flags.

---
title: Config
summary: Merged config reads and scoped writes through Repository::config and ConfigEditor.
---

Configuration in grit-lib follows Git’s cascade (system, global, local, worktree, and environment overrides). Use [`Repository::config`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.config) for reads and for writes that target a scope in an open repository. For global, system, or `-f` file edits outside a repository, use [`ConfigEditor`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigEditor.html).

## Loading outside a handle

[`ConfigSet::load`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html) parses the cascade from disk given an [`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html) and optional git directory. The library does not read `std::env` during load — embedders pass variables explicitly (see [Embedding](https://grit-scm.com/docs/library/embedding/index.md) and [Repository](https://grit-scm.com/docs/library/repository/index.md)).

## Typed values

[`ConfigSet::get_bool`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.get_bool) and [`ConfigSet::get_i64`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.get_i64) return `None` for an unset key. A value of the wrong type is a [`ConfigError::InvalidValue`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ConfigError.html) carrying the key and a [`ConfigValueError`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ConfigValueError.html) that says what was wrong: not a boolean, an empty or malformed integer, an integer that overflows `i64` once its `k`/`m`/`g` suffix is applied, or a bad color. `get_bool(key).transpose()?` reads an optional boolean and propagates a bad value as `grit_lib::error::Error::Config`. The key-less parsers [`parse_bool`](https://docs.rs/grit-lib/latest/grit_lib/config/fn.parse_bool.html), [`parse_i64`](https://docs.rs/grit-lib/latest/grit_lib/config/fn.parse_i64.html) and [`parse_color`](https://docs.rs/grit-lib/latest/grit_lib/config/fn.parse_color.html) return the bare `ConfigValueError`; call `for_key` on it to attach the key.

For a setting with a Git default, apply it to the unset case: `config.get_bool("commit.autoStage")?.unwrap_or(true)`. The `core` booleans that many operations consult have accessors carrying Git's default: [`ignore_case`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.ignore_case) and [`precompose_unicode`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.precompose_unicode) (both `false`), and [`preload_index`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.preload_index) and [`file_mode`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.file_mode) (both `true`).

## Errors

Every config failure is a specific [`ConfigError`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ConfigError.html) variant with the offending key or value in its fields, so callers match on the variant instead of the message. For example, [`canonical_key`](https://docs.rs/grit-lib/latest/grit_lib/config/fn.canonical_key.html) returns `ConfigError::InvalidKey` with an [`InvalidKeyReason`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.InvalidKeyReason.html) naming the malformed part. Bad `GIT_CONFIG_COUNT` or `GIT_CONFIG_PARAMETERS` input is `InvalidEnvironmentCount`, `MissingEnvironmentKey` or `MalformedConfigParameters`. A value outside a key's fixed word list (`protocol.version`, `gpg.format`) is `UnknownValue`, and a `--local` or `--worktree` location without a repository is `RepositoryRequired`. Submodule git-dir layout problems are not config errors. They are reported as `Error::Submodule` with a [`SubmoduleError`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.SubmoduleError.html).

## Writes

Pass a [`ConfigScope`](https://docs.rs/grit-lib/latest/grit_lib/config/enum.ConfigScope.html) (`Local`, `Worktree`, `Global`, or `System`) and [`ConfigWriteOptions`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigWriteOptions.html) to [`Config::set`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.set), [`Config::add_value`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.add_value), [`Config::unset`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.unset), [`Config::unset_all`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.unset_all), [`Config::rename_section`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.rename_section), or [`Config::remove_section`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.remove_section). Successful writes reload the in-memory snapshot on the open `Repository`. `ConfigWriteOptions` carries dry-run mode, optional `--type` canonicalization, Git-style `replace-all` with an optional value pattern, and unset value patterns instead of bare boolean flags.

Without an open `Repository`, [`ConfigEditor::global`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigEditor.html#method.global), [`ConfigEditor::system`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigEditor.html#method.system), or [`ConfigEditor::open`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigEditor.html#method.open) edit one file. For local or worktree config tied to a path you discover yourself, call [`Repository::discover`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) (or [`Repository::open`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) when you already know the git directory) and use [`Repository::config`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.config) with the right [`ConfigScope`](https://docs.rs/grit-lib/latest/grit_lib/config/enum.ConfigScope.html) (`Local` or `Worktree`). The `grit config` command follows the same split: it edits with `ConfigEditor` when there is no repository, and `Repository::config` when one is open.

Writes go through `config.lock` and an atomic rename and keep the file's permission bits. Like Git, they do not fsync the file, so a crash may lose the update, but readers never see a partial file.

## Example

```rust
//! Read and write repository-local config through [`Repository::config`](https://grit-scm.com/docs/library/config/grit_lib::repo::Repository::config/index.md)
//! ([`grit_lib::config::Config`]).
//!
//! Source for the library guide "Config" page (included in the docs site).

use anyhow::Result;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::repo::Repository;
use std::path::{Path, PathBuf};

fn open_repo(root: &Path) -> Result<Repository> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::from_process();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Ok(Repository::open(&git_dir, &opts)?)
}

fn main() -> Result<()> {
    let root = std::env::args()
        .nth(1)
        .map(PathBuf::from)
        .or_else(|| std::env::current_dir().ok())
        .ok_or_else(|| anyhow::anyhow!("missing repository path"))?;
    let repo = open_repo(&root)?;

    repo.config().set(
        grit_lib::config::ConfigScope::Local,
        "user.name",
        "Library Guide Config",
        &grit_lib::config::ConfigWriteOptions::new(),
    )?;

    let name = repo.config().get("user.name")?.unwrap_or_default();
    println!("user.name={name}");

    let format = repo
        .config()
        .get("core.repositoryformatversion")?
        .unwrap_or_default();
    println!("core.repositoryformatversion={format}");

    Ok(())
}
```

```bash
cargo run --bin guide_config /path/to/repo
git -C /path/to/repo config user.name
```

The integration test checks the printed `user.name` against `git config user.name`.

Writes go through `config.lock` and an atomic rename and keep the file's permission bits. Like Git, they do not fsync the file, so a crash may lose the update, but readers never see a partial file.

## Example

```rust
//! Read and write repository-local config through [`Repository::config`](https://grit-scm.com/docs/library/config/grit_lib::repo::Repository::config/index.md)
//! ([`grit_lib::config::Config`]).
//!
//! Source for the library guide "Config" page (included in the docs site).

use anyhow::Result;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::repo::Repository;
use std::path::{Path, PathBuf};

fn open_repo(root: &Path) -> Result<Repository> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::from_process();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Ok(Repository::open(&git_dir, &opts)?)
}

fn main() -> Result<()> {
    let root = std::env::args()
        .nth(1)
        .map(PathBuf::from)
        .or_else(|| std::env::current_dir().ok())
        .ok_or_else(|| anyhow::anyhow!("missing repository path"))?;
    let repo = open_repo(&root)?;

    repo.config().set(
        grit_lib::config::ConfigScope::Local,
        "user.name",
        "Library Guide Config",
        &grit_lib::config::ConfigWriteOptions::new(),
    )?;

    let name = repo.config().get("user.name")?.unwrap_or_default();
    println!("user.name={name}");

    let format = repo
        .config()
        .get("core.repositoryformatversion")?
        .unwrap_or_default();
    println!("core.repositoryformatversion={format}");

    Ok(())
}
```

```bash
cargo run --bin guide_config /path/to/repo
git -C /path/to/repo config user.name
```

The integration test checks the printed `user.name` against `git config user.name`.

# https://grit-scm.com/docs/library/conflicts/index.md

# Conflicts during replay

> Multi-commit cherry-pick and revert sequences, on-disk sequencer state, and continue/abort.

Pick and revert ranges use [`porcelain::replay_sequence`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/index.html) instead of single-commit replay. On conflict, grit writes Git-compatible `CHERRY_PICK_HEAD` or `REVERT_HEAD`, `MERGE_MSG`, `ORIG_HEAD`, and `.git/sequencer/` (todo, head, abort-safety, opts) so `git cherry-pick --continue` and `grit pick --continue` can interoperate.

[`ReplayOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/struct.ReplayOptions.html) controls mainline parent selection for merge commits, `-x` / `record_origin`, empty-commit policy (`Stop`, `Drop`, `Keep`), merge favor, and conflict marker style. [`Merge::start_sequence`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.start_sequence) returns [`SequenceOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/enum.SequenceOutcome.html) — `Completed`, `Conflicts`, or `Empty`. Every commit created so far is a [`ReplayCreated`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/struct.ReplayCreated.html) carrying its source, new oid, stored change id, and subject (also for steps committed before an earlier stop), and a stop reports the subject of the commit it stopped on, so callers can render results without re-reading commits. Resolve conflicts in the worktree, stage paths, then call [`Merge::continue_sequence`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.continue_sequence). [`Merge::skip_sequence_step`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.skip_sequence_step) and [`Merge::abort_sequence`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.abort_sequence) match Git's skip/abort semantics. Abort rewinds to `sequencer/head` when grit wrote a sequencer directory, otherwise to the current branch tip (for example a single pick or revert started by Git); a leftover `ORIG_HEAD` from an earlier reset or merge is not the restore target. Abort clears replay state without moving the branch when `HEAD` no longer matches `sequencer/abort-safety`.

Conflict markers and unmerged index stages reuse the same tree-merge path as [`porcelain::merge`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/index.html) (`apply_conflict_merge_worktree`). [`status`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/fn.status_options_from_config.html) surfaces cherry-pick/revert operation guidance via [`state::status_operation`](https://docs.rs/grit-lib/latest/grit_lib/state/fn.status_operation.html). On the returned model, [`StatusModel::conflict_groups`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.StatusModel.html#method.conflict_groups) groups unmerged paths by [`ConflictKind`](https://docs.rs/grit-lib/latest/grit_lib/operation/enum.ConflictKind.html), and [`StatusModel::guidance`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.StatusModel.html#method.guidance) picks the next step `grit status` suggests: the paused operation's runnable steps, the conflict and merge fallbacks, or everyday [`StatusAction`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/enum.StatusAction.html)s (discard, stage, commit, pull when strictly behind).

## Sequencer and merge errors ([`MergeError`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html))

[`Merge::start_sequence`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.start_sequence), [`Merge::continue_sequence`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.continue_sequence), skip, and abort propagate the same [`MergeError`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html) variants as merge (wrapped in [`Error::Merge`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Merge)). Examples: [`ReplayContinueUnmerged`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html#variant.ReplayContinueUnmerged) when continue is attempted with unmerged index entries; [`ReplayContinueDirtyIndex`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html#variant.ReplayContinueDirtyIndex) when the index differs from `HEAD` after the step was already committed; [`NoReplayInProgress`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html#variant.NoReplayInProgress) for continue/skip/abort with no sequence; [`OperationInProgress`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html#variant.OperationInProgress) when a merge (or other paused operation) blocks starting a new pick/revert. Merge commits without [`ReplayOptions::mainline`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/struct.ReplayOptions.html#structfield.mainline) return [`MergeCommit`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html#variant.MergeCommit).

## One conflict model

Every API that reports conflicts uses [`operation::Conflict`](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.Conflict.html) (a path and a [`ConflictKind`](https://docs.rs/grit-lib/latest/grit_lib/operation/enum.ConflictKind.html)): [`StatusModel::conflict_details`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.StatusModel.html#structfield.conflict_details), merge and pull outcomes, [`SequenceOutcome::Conflicts`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/enum.SequenceOutcome.html#variant.Conflicts), a stopped rebase's [`RebaseStop`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RebaseStop.html), rebase predictions and [`HistoryError::Conflict`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.Conflict), and [`StashApplyOutcome`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashApplyOutcome.html). The kind is read from which unmerged index stages a path has ([`conflict_kind_from_stagemask`](https://docs.rs/grit-lib/latest/grit_lib/operation/fn.conflict_kind_from_stagemask.html), the same classification as Git's porcelain v2 `u` lines), so an operation's conflicts equal what `status` reports right after it stops, and a UI needs one renderer. Only a tree-merge result ([`conflicts_from_tree_merge`](https://docs.rs/grit-lib/latest/grit_lib/operation/fn.conflicts_from_tree_merge.html)) can add [`ConflictKind::RenameRename`](https://docs.rs/grit-lib/latest/grit_lib/operation/enum.ConflictKind.html#variant.RenameRename) and the directory rename kinds ([`DirectoryRenameMoved`](https://docs.rs/grit-lib/latest/grit_lib/operation/enum.ConflictKind.html#variant.DirectoryRenameMoved), [`DirectoryRenameSplit`](https://docs.rs/grit-lib/latest/grit_lib/operation/enum.ConflictKind.html#variant.DirectoryRenameSplit), [`DirectoryRenameBlocked`](https://docs.rs/grit-lib/latest/grit_lib/operation/enum.ConflictKind.html#variant.DirectoryRenameBlocked)), which need information the index does not keep; [`conflicts_from_index`](https://docs.rs/grit-lib/latest/grit_lib/operation/fn.conflicts_from_index.html) classifies an index alone. [`ConflictKind::as_str`](https://docs.rs/grit-lib/latest/grit_lib/operation/enum.ConflictKind.html#method.as_str) gives the snake_case name `grit` prints in `--json`, and with the `serde-models` feature a `Conflict` serializes to the same `{"path", "kind"}` object.

```rust
use grit_lib::merge::ReplayOptions;
use grit_lib::merge::{Merge, SequenceOutcome};
use grit_lib::operation::ConflictKind;
use grit_lib::progress::{CancelToken, NullProgress};

let outcome = Merge::start_sequence(&repo, &request, &ReplayOptions::default(), &mut NullProgress, &CancelToken::never())?;
let conflicts = match outcome {
    SequenceOutcome::Conflicts { conflicts, .. } => conflicts,
    _ => return Ok(()),
};
for conflict in &conflicts {
    if conflict.kind == ConflictKind::DeletedByUs {
        println!("{}: deleted here, changed on the incoming side", conflict.path);
    }
}
```

## Example

```rust
//! Cherry-pick / revert sequences that stop on conflicts (library API).
//!
//! Source for the library guide "Conflicts during replay" page.

use anyhow::Result;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::merge::{ReplayEmptyPolicy, ReplayOptions, ReplaySequenceRequest, SequenceOutcome};
use grit_lib::objects::ObjectId;
use grit_lib::porcelain::add::StageOptions;
use grit_lib::porcelain::replay::ReplayDirection;
use grit_lib::progress::NullProgress;
use grit_lib::repo::Repository;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;

const IDENT: &str = "Library Guide <guide@grit-scm.com> 1735689600 +0000";

fn replay_identity() -> grit_lib::ident::Signature {
    grit_lib::ident::parse_signature(IDENT)
        .unwrap_or_else(|| panic!("guide IDENT must parse as a signature: {IDENT}"))
}

fn open_repo(root: &Path) -> Result<Repository> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::empty();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Ok(Repository::open(&git_dir, &opts)?)
}

fn git(root: &Path, args: &[&str]) -> Result<()> {
    let home = root.join(".git-home");
    fs::create_dir_all(&home)?;
    let out = Command::new("git")
        .current_dir(root)
        .args(args)
        .env("HOME", &home)
        .env("GIT_CONFIG_GLOBAL", "/dev/null")
        .env("GIT_CONFIG_SYSTEM", "/dev/null")
        .output()?;
    if !out.status.success() {
        return Err(anyhow::anyhow!(format!(
            "git {:?}: {}",
            args,
            String::from_utf8_lossy(&out.stderr)
        )));
    }
    Ok(())
}

fn oid_from_rev(root: &Path, rev: &str) -> Result<ObjectId, anyhow::Error> {
    let home = root.join(".git-home");
    let out = Command::new("git")
        .current_dir(root)
        .args(["rev-parse", rev])
        .env("HOME", &home)
        .env("GIT_CONFIG_GLOBAL", "/dev/null")
        .env("GIT_CONFIG_SYSTEM", "/dev/null")
        .output()?;
    if !out.status.success() {
        return Err(anyhow::anyhow!("rev-parse failed"));
    }
    let hex = String::from_utf8_lossy(&out.stdout).trim().to_owned();
    ObjectId::from_hex(&hex).map_err(|_| anyhow::anyhow!("bad oid"))
}

/// Build a tiny repo with one conflicting pick, run start → resolve → continue.
fn demo_conflict_sequence(root: &Path) -> Result<()> {
    git(root, &["init", "-q", "-b", "main", "."])?;
    git(root, &["config", "user.email", "guide@grit-scm.com"])?;
    git(root, &["config", "user.name", "Library Guide"])?;
    fs::write(root.join("f"), "base\n")?;
    git(root, &["add", "f"])?;
    git(root, &["commit", "-qm", "base"])?;

    git(root, &["switch", "-c", "topic"])?;
    fs::write(root.join("f"), "topic\n")?;
    git(root, &["commit", "-qam", "topic"])?;
    let pick = oid_from_rev(root, "HEAD")?;

    git(root, &["switch", "main"])?;
    fs::write(root.join("f"), "main\n")?;
    git(root, &["commit", "-qam", "main"])?;

    let repo = open_repo(root)?;
    let req = ReplaySequenceRequest::new(vec![pick], ReplayDirection::Pick, replay_identity())
        .with_options(ReplayOptions::default().with_empty(ReplayEmptyPolicy::Stop));

    match repo.merge().start_sequence(
        &req,
        &mut NullProgress,
        &grit_lib::progress::CancelToken::never(),
    )? {
        SequenceOutcome::Conflicts {
            conflicts,
            current,
            created_so_far,
            ..
        } => {
            println!(
                "stopped on {} conflict(s) at {}",
                conflicts.len(),
                current.to_hex()
            );
            println!("created_so_far={}", created_so_far.len());
        }
        other => {
            return Err(anyhow::anyhow!(format!(
                "expected conflicts, got {other:?}"
            )));
        }
    }

    fs::write(root.join("f"), "merged\n")?;
    repo.index().stage(
        &StageOptions::default(),
        &mut NullProgress,
        &grit_lib::progress::CancelToken::never(),
    )?;

    match repo.merge().continue_sequence(
        &replay_identity(),
        &mut NullProgress,
        &grit_lib::progress::CancelToken::never(),
    )? {
        SequenceOutcome::Completed {
            created, dropped, ..
        } => {
            println!(
                "sequence completed; created={} dropped={}",
                created.len(),
                dropped.len()
            );
            for record in created {
                println!(
                    "replay source={} new={} change_id={}",
                    record.source.to_hex(),
                    record.new_oid.to_hex(),
                    record
                        .change_id
                        .map(|c| c.to_string())
                        .unwrap_or_else(|| "-".into())
                );
            }
        }
        other => {
            return Err(anyhow::anyhow!(format!(
                "expected completed after continue, got {other:?}"
            )));
        }
    }

    Ok(())
}

fn main() -> Result<()> {
    if std::env::args().nth(1).is_none() {
        let temp = tempfile::tempdir()?;
        demo_conflict_sequence(temp.path())?;
        return Ok(());
    }

    let root = std::env::args()
        .nth(1)
        .map(PathBuf::from)
        .ok_or_else(|| anyhow::anyhow!("missing repository path"))?;
    let repo = open_repo(&root)?;

    if repo.git_dir().join("CHERRY_PICK_HEAD").exists()
        || repo.git_dir().join("REVERT_HEAD").exists()
    {
        if repo
            .index()
            .load(&grit_lib::index::IndexLoadOptions::default())?
            .has_unmerged_entries()
        {
            println!("unmerged index — resolve and stage before continue");
            return Ok(());
        }
        match repo.merge().continue_sequence(
            &replay_identity(),
            &mut NullProgress,
            &grit_lib::progress::CancelToken::never(),
        )? {
            SequenceOutcome::Completed { created, .. } => {
                println!("continued; new commits={}", created.len());
            }
            SequenceOutcome::Conflicts { conflicts, .. } => {
                println!("stopped again on {} conflict(s)", conflicts.len());
            }
            SequenceOutcome::Empty { current, .. } => {
                println!("empty step at {}", current.to_hex());
            }
            _ => println!("stopped with an outcome this example does not handle"),
        }
    } else {
        println!(
            "no replay in progress (omit path to run the built-in conflict demo, or call start_replay_sequence first)"
        );
    }

    Ok(())
}
```

The integration test `replay_sequence_git_compat` cross-checks trees, messages, and on-disk state against system `git` after `git fsck --strict`.

# https://grit-scm.com/docs/library/diff/index.md

# Diff

> Tree-to-tree and index-to-worktree diffs, blob patches, and the DiffEntry model the grit CLI renders.

Diffing in grit-lib centers on the [`diff`](https://docs.rs/grit-lib/latest/grit_lib/diff/index.html) domain module (tree/content diff, merge helpers, patch-ids). Prefer `Repository::diff` (`Diff`) for tree, index, and worktree comparisons on one open handle. Results are `DiffEntry` rows with a `DiffStatus` letter (`M`, `A`, `D`, …), paths, modes, and object ids — the same shape [`grit diff`](https://grit-scm.com/docs/diff/index.md) and `porcelain::status` use before formatting output. See [API layout](https://grit-scm.com/docs/library/api-layout/index.md) for the flat-path map.

Two public structs carry per-file diff output: [`FileDiff`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.FileDiff.html) from [`Diff::files`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.files) always includes structured hunks when line diff ran; [`ListedFileDiff`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.ListedFileDiff.html) from [`Diff::files_for_entries`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.files_for_entries) is the stat-or-patch row where structured hunks and line counts are filled according to [`DiffDetail`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.DiffDetail.html).

## Entry points

Every diff is a method on the [`Diff`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html) handle from `repo.diff()`. The metadata diffs list changed paths without loading contents. They take one [`TreeDiffOptions`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html) and return a [`DiffEntriesResult`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffEntriesResult.html): the entries, a notice when `diff.renameLimit` skipped inexact rename scoring, and whether an index-to-work-tree scan refreshed stat data. Configuration (`diff.renameLimit`, attributes, `core.autocrlf`, thread settings) is read from the repository inside the handle.

| Method | Compares | Git equivalent |
| --- | --- | --- |
| [`tree_to_tree`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.tree_to_tree) | two trees (either may be the empty tree) | `git diff-tree -r A B` |
| [`commits`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.commits) | the trees of two commits | `git diff-tree -r A B` on commits |
| [`index_to_tree`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.index_to_tree) | the index against a tree | `git diff --cached` |
| [`index_to_worktree`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.index_to_worktree) | the work tree against the index | `git diff-files` |
| [`tree_to_worktree`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.tree_to_worktree) | the work tree against a tree, through the index | `git diff <tree>` |
| [`detect_renames`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.detect_renames) | pairs entries you already have | `diffcore` rename, copy and break passes |

`TreeDiffOptions::default()` compares every path and pairs nothing. Its fields, each with a `with_<field>` setter:

| Field | Meaning |
| --- | --- |
| [`renames`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html#structfield.renames) | [`RenameDetection::Similarity(n)`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.RenameDetection.html) is Git `-M<n>`; `Similarity(100)` pairs identical content only |
| [`copies`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html#structfield.copies) | [`CopyDetection::Similarity(n)`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.CopyDetection.html) is `-C<n>` (sources are paths changed in the same diff); `FindHarder(n)` adds `--find-copies-harder` (every old path is a source) |
| [`break_rewrites`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html#structfield.break_rewrites) | [`BreakRewrites::DEFAULT`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.BreakRewrites.html) is a bare `-B`; with renames or copies on, broken pairs are split so their halves can pair elsewhere |
| [`pathspec`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html#structfield.pathspec) | a [`Pathspec`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html); tree walks skip directories it cannot reach and work-tree scans read only the paths it selects |
| [`show_tree_entries`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html#structfield.show_tree_entries) | also report changed subtrees (`diff-tree -t`); tree and commit diffs |
| [`prefix`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html#structfield.prefix) | prepended to reported paths when the trees are subtrees; tree and commit diffs |
| [`submodules`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html#structfield.submodules) | [`SubmoduleIgnoreMode`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.SubmoduleIgnoreMode.html) (`--ignore-submodules=none|untracked|dirty|all`); `All` omits gitlink paths |
| [`threads`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html#structfield.threads) | a [`ThreadPolicy`](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ThreadPolicy.html) for rename scoring and stat workers; `None` uses the repository's |
| [`refresh_index_stat`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html#structfield.refresh_index_stat), [`for_status`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html#structfield.for_status) | index-to-work-tree only: adopt fresh stat data in the same scan, and status shortcuts that skip reading files whose size changed |

```rust
use grit_lib::diff::{CopyDetection, RenameDetection, TreeDiffOptions};
use grit_lib::worktree::pathspec::{Pathspec, PathspecGlobalFlags};

// `git diff-tree -r -M50 -C50 --find-copies-harder old new -- src/`
let options = TreeDiffOptions::default()
    .with_renames(RenameDetection::Similarity(50))
    .with_copies(CopyDetection::FindHarder(50))
    .with_pathspec(Some(Pathspec::scoped(["src/"], PathspecGlobalFlags::default())));
let result = repo.diff().tree_to_tree(Some(&old_tree), Some(&new_tree), &options)?;
if let Some(skipped) = &result.inexact_rename_skipped {
    eprintln!("raise diff.renameLimit to {}", skipped.suggested_limit);
}
for entry in &result.entries {
    println!("{}\t{}", entry.status.letter(), entry.path());
}
```

The content methods turn entries into hunks and line counts under a [`DiffOptions`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffOptions.html): [`files_for_entries`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.files_for_entries) at any [`DiffDetail`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.DiffDetail.html), [`for_each_file`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.for_each_file) one patch row at a time, [`stat`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.stat) for a [`DiffStat`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffStat.html), and [`structured`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.structured) / [`for_each_structured`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.for_each_structured) for [`TreeDiffStructured`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffStructured.html) rows in input order. [`commit_files`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.commit_files) diffs one commit against its parents (`grit show`), [`object_changes`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.object_changes) loads both sides of stored-object entries, and [`hunk_bundle`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.hunk_bundle) gathers unstaged hunks for hunk-level staging.

## Pickaxe

[`Pickaxe`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Pickaxe.html) implements Git's pickaxe filters for revision walks: [`Pickaxe::occurrences`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Pickaxe.html#method.occurrences) (`-S`, occurrence-count change per file) and [`Pickaxe::line_grep`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Pickaxe.html#method.line_grep) (`-G`, regex on added/removed lines). Call [`Pickaxe::matches_commit`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Pickaxe.html#method.matches_commit) to test one commit against its first parent; wire the filter through [`RevWalkListOptions::pickaxe`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkListOptions.html) for `grit log` / `grit revs`.

## Choosing what to compare

[`Diff::resolve_request`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.resolve_request) turns diff operands as a user typed them ([`DiffRequest`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffRequest.html): `--staged`, `--unstaged`, `--against`, operands before and after `--`, and pathspec-file entries) into a [`DiffTarget`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.DiffTarget.html) plus a [`Pathspec`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html) on [`DiffArguments::pathspec`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffArguments.html#structfield.pathspec). This is the resolver [`grit diff`](https://grit-scm.com/docs/commands/diff.md/index.md) uses. Operands that are not revisions but name known paths become pathspecs, so `file.txt` and `HEAD~1 file.txt` need no `--`. One revision selects that commit's own patch, `A..B` and `A...B` select a tree diff (merge base of `A` and `B` against `B` for three dots), and two revisions compare their trees. Failures are typed [`ResolveDiffArgumentsError`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.ResolveDiffArgumentsError.html) variants: flag conflicts, `UnresolvedRevision` (carrying the library cause), `NotACommit`, `NoMergeBase`, and pathspec errors. When explicit paths or pathspec-file entries accompany an unresolved revision, the resolver returns `UnresolvedRevision`; only a lone unresolved operand without path limits falls back to a worktree path. Hand the target and path limit to [`Diff::files`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.files) (`&Pathspec`) for structured file diffs. [`Diff::resolve_pathspec`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.resolve_pathspec) returns a [`Pathspec`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html) for commit diffs on their own (as `grit show` and `grit log -p` do), without requiring the paths to exist in the checkout.

## Tree-to-tree

[`Diff::tree_to_tree`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.tree_to_tree) reads tree metadata only and prunes identical subtree object ids without opening them. The walk retains active directory frames and the ODB’s bounded parsed-tree cache; completed siblings do not accumulate in a second cache, and trees read for that cache are not also copied into the ODB’s raw-object cache. The returned entries own changed paths, modes and ids, so result memory still grows with the number of changes. Rename, copy and break pairing run only when `TreeDiffOptions` asks for them; when a list has no added/deleted pair to score, rename detection returns it unchanged without reading content. [`Diff::files_for_entries`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.files_for_entries) applies [`DiffOptions::renames`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffOptions.html#structfield.renames) (default similarity 50, Git `-M`) before stat or patch work; pass [`RenameDetection::Off`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.RenameDetection.html#variant.Off) when the entries are already paired. For metadata-only output, [`FileDiff::from_metadata`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.ListedFileDiff.html#method.from_metadata) builds a row from one entry without line-diff blob reads. Diff lists are in Git’s order, raw path bytes; [`sort_entries_by_path`](https://docs.rs/grit-lib/latest/grit_lib/diff/fn.sort_entries_by_path.html) restores that order after filtering or merging lists and costs one comparison pass when the list is already ordered. See the [tree metadata measurements](https://grit-scm.com/docs/benchmarks/index.md#tree-metadata-diff-2026-10-27) and the [CLI follow-up](https://grit-scm.com/docs/benchmarks/index.md#tree-metadata-diff-through-the-cli-2026-10-27).

[`Diff::commits`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.commits) resolves each commit’s tree and diffs them the same way; it returns `RefError::Invalid` (as `Error::Ref`) when an id is not a commit.

## Index-to-worktree

[`Diff::index_to_worktree`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.index_to_worktree) compares the files on disk with the index. Entries whose stat data matches are not read, and racily clean entries (modified within the index file's timestamp) are hashed to be sure. The work-tree side of a changed file carries a null `new_oid` unless its content had to be hashed. Gitlinks follow [`TreeDiffOptions::submodules`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html#structfield.submodules). With [`refresh_index_stat`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.TreeDiffOptions.html#structfield.refresh_index_stat) the in-memory index adopts fresh stat data for unchanged entries in the same scan, and [`DiffEntriesResult::index_stat_refreshed`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffEntriesResult.html#structfield.index_stat_refreshed) says whether writing it back is worthwhile. [`Diff::tree_to_worktree`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.tree_to_worktree) compares the work tree with any tree through the index, reading work-tree bytes through attributes and clean filters. Both return [`RepositoryError::RequiresWorkTree`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html#variant.RequiresWorkTree) in a bare repository.

## Staged, unstaged, and working-tree changes

[`Diff::uncommitted`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.uncommitted) loads the index once and returns an [`UncommittedDiff`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UncommittedDiff.html) for the comparisons `grit diff` makes without revisions. [`staged_entries`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UncommittedDiff.html#method.staged_entries) compares the index with `HEAD`'s tree, [`unstaged_entries`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UncommittedDiff.html#method.unstaged_entries) compares the working tree with the index, and [`worktree_entries`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UncommittedDiff.html#method.worktree_entries) compares the working tree and index together with any tree (`HEAD`'s for `grit diff`, another revision's for `--against`). Each returns sorted `DiffEntry` rows without reading blob content, so filter them by pathspec first and then load only what you need. [`load_worktree_changes`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UncommittedDiff.html#method.load_worktree_changes) reads new sides from the working tree (clean filters and line-ending rules applied, a gitlink shown as its checked-out commit with `-dirty` when modified); [`Diff::object_changes`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.object_changes) reads both sides from the object database in parallel, for staged or tree entries. Both return [`FileChange`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.FileChange.html) rows, which give structured hunks with [`structured`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.FileChange.html#method.structured) or line counts with [`line_stat`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.FileChange.html#method.line_stat). One `UncommittedDiff` reuses its index and worktree rules across all of these calls. The working-tree methods return [`RepositoryError::RequiresWorkTree`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html#variant.RequiresWorkTree) (as [`Error::Repository`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Repository)) in a bare repository, and [`Diff::resolve_request`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.resolve_request) rejects a working-tree target there with `ResolveDiffArgumentsError::NoWorkTree`.

To go straight from a resolved [`DiffTarget`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.DiffTarget.html) to its changed paths, call [`UncommittedDiff::entries`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UncommittedDiff.html#method.entries) with the target, a [`Pathspec`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html), and a `DiffOptions`: it picks the comparison above (with `HEAD`'s tree for `WorktreeVsHead`), keeps the entries within the pathspecs, and applies [`DiffOptions::filter`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffOptions.html#structfield.filter) (Git `--diff-filter`) after rename detection. Load the result on the same handle. For commit and range targets, [`Diff::entries`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.entries) does the same without reading the index. This is how `grit diff` and `grit diff --patch-text` choose their entries. To give staged and unstaged hunks stable ids, [`UncommittedDiff::peer_changes`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UncommittedDiff.html#method.peer_changes) loads the changes on the other side of the index for the same paths, ready to pass as the peer hunks of [`hunk_ids`](https://docs.rs/grit-lib/latest/grit_lib/diff/fn.hunk_ids.html).

## Blob diffs

For a single modified file, read old and new bytes from [`Odb`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) and pass them to [`unified_diff`](https://docs.rs/grit-lib/latest/grit_lib/diff/fn.unified_diff.html) (see [Text diffs](#text-diffs)) or the structured helpers in [`structured`](https://docs.rs/grit-lib/latest/grit_lib/diff/structured/index.html). For tree diffs meant for `git apply`, stream [`write_patch`](https://docs.rs/grit-lib/latest/grit_lib/diff/fn.write_patch.html) over a `DiffEntry` slice with [`PatchTextOptions`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.PatchTextOptions.html) (same headers and `GIT binary patch` bodies as `git diff --binary`). For index and work-tree diffs, [`write_patch_resolved`](https://docs.rs/grit-lib/latest/grit_lib/diff/fn.write_patch_resolved.html) takes [`PatchResolvedSide`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.PatchResolvedSide.html) values whose sides are a [`PatchSide`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.PatchSide.html): bytes you already hold, a blob in the object database, or the work-tree file (read through clean filters and line-ending rules). Binary files get full ids of the written content on their `index` line, which `git apply` requires. Line-level hunks honor one shared [`DiffOptions`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffOptions.html) value (algorithm, context, indent heuristic, renames, optional word-level inline emphasis) whether you emit unified patch text or structured hunks for the CLI. Defaults match Git (`Myers`, `-U3`, indent heuristic on, rename similarity 50). Patch writers load `.gitattributes` once per diff (work tree, `info/attributes`, `GIT_ATTR_SOURCE`, and `attr.tree`, matching `git diff`) and resolve each path's `diff` driver for `@@` function-name suffixes and structured `hunks[].context`. Commit-tree patches (`git show` / `git log -p`) use the commit tree's attributes instead. The CLI builds human, `--json`, and `--markdown` views from `DiffEntry` lists plus structured or unified bodies; [`grit diff --patch-text`](https://grit-scm.com/docs/commands/diff.md/index.md) calls `write_patch` for revisions and `write_patch_resolved` for staged and work-tree changes.

## Text diffs

[`unified_diff`](https://docs.rs/grit-lib/latest/grit_lib/diff/fn.unified_diff.html) turns two strings into a unified patch, and [`line_change_counts`](https://docs.rs/grit-lib/latest/grit_lib/diff/fn.line_change_counts.html) counts the `+` and `-` lines of that same patch without building it. Both take one [`UnifiedDiffOptions`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html), whose defaults are Git's: Myers alignment, three context lines, the indent heuristic, Git's default function-name rule and `\ No newline at end of file` markers. The output matches `git diff --no-index` with the same options byte for byte, from the `---` line on. `grit-lib/tests/text_diff_options.rs` checks this against the system `git` for every option.

```rust
use grit_lib::diff::{unified_diff, DiffAlgorithm, UnifiedDiffOptions, WhitespaceMode};

let options = UnifiedDiffOptions::new()
    .with_paths("src/lib.rs", "src/lib.rs")
    .with_algorithm(DiffAlgorithm::Histogram)
    .with_whitespace(WhitespaceMode::ignore_space_change());
let patch = unified_diff(&old_text, &new_text, &options);
```

| Option | Git | Field |
| --- | --- | --- |
| `---` / `+++` labels | `--src-prefix`, `--dst-prefix`, `--no-prefix` | [`old_label`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html#structfield.old_label), [`new_label`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html#structfield.new_label) ([`DiffLabel`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.DiffLabel.html)); unset means hunks only |
| Path quoting | `core.quotePath` | [`path_quoting`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html#structfield.path_quoting) ([`PathQuoting`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.PathQuoting.html)) |
| Context | `-U<n>`, `--inter-hunk-context` | [`context_lines`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html#structfield.context_lines), [`inter_hunk_context`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html#structfield.inter_hunk_context) |
| Function context | `-W` | [`extent`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html#structfield.extent) ([`HunkExtent::Function`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.HunkExtent.html#variant.Function)) |
| Hunk-header function names | `diff.<driver>.xfuncname` | [`funcname`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html#structfield.funcname), a matcher from [`userdiff`](https://docs.rs/grit-lib/latest/grit_lib/diff/userdiff/index.html) |
| Algorithm | `--diff-algorithm` | [`algorithm`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html#structfield.algorithm) ([`DiffAlgorithm`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.DiffAlgorithm.html)) |
| Indent heuristic | `--[no-]indent-heuristic` | [`indent_heuristic`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html#structfield.indent_heuristic) ([`IndentHeuristic`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.IndentHeuristic.html)) |
| Anchors | `--anchored=<text>` | [`anchors`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html#structfield.anchors); non-empty anchors use patience alignment, as in Git |
| Whitespace | `-w`, `-b`, `--ignore-space-at-eol`, `--ignore-blank-lines` | [`whitespace`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html#structfield.whitespace) ([`WhitespaceMode`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.WhitespaceMode.html)) |
| No-newline markers | always on | [`no_newline_marker`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.UnifiedDiffOptions.html#structfield.no_newline_marker) ([`NoNewlineMarker`](https://docs.rs/grit-lib/latest/grit_lib/diff/enum.NoNewlineMarker.html)) |

When equal sides, or a whitespace rule, leave no hunk, `unified_diff` returns an empty string, labels included, as Git prints nothing. `UnifiedDiffOptions::from(&diff_options)` carries the line settings of a repository [`DiffOptions`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffOptions.html) over to a text diff. Under whitespace rules the patch compares normalized lines but shows the original text, with context lines from the new side. Anchors pin a line that starts with one of the given prefixes and occurs exactly once on each side, so it stays as context instead of showing up as removed and re-added.

For combined (`--cc`) patches of a merge path, [`format_combined_textconv_patch`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_diff/fn.format_combined_textconv_patch.html) takes a [`CombinedPatchOptions`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_diff/struct.CombinedPatchOptions.html), and [`format_worktree_conflict_combined`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_diff/fn.format_worktree_conflict_combined.html) takes the three index stages of a conflicted path as [`ConflictStages`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_diff/struct.ConflictStages.html).

## Diffstat

[`DiffStat`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffStat.html) is the data behind `--stat`, `--numstat` and `--shortstat`. [`Diff::stat`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.stat) builds one for a list of entries. [`DiffStat::from_files`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffStat.html#method.from_files) takes the rows from `Diff::files_for_entries` at any detail level: each row's counts come from [`FileDiff::line_stat`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.ListedFileDiff.html#method.line_stat), which uses the stat when one was computed and otherwise counts the structured or combined hunk lines, so a patch-mode listing and a stat-mode listing give the same diffstat. [`totals`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffStat.html#method.totals) sums the rows. To draw bars, scale each row with [`LineStat::bar`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.LineStat.html#method.bar) against [`max_changes`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffStat.html#method.max_changes) and a column budget; the returned [`StatBar`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.StatBar.html) gives `+` and `-` column counts. `grit diff --stat`, `grit show`, `grit log --stat` and `grit stash show` render this model.

```rust
use grit_lib::diff::{DiffOptions, TreeDiffOptions};

let entries = repo
    .diff()
    .tree_to_tree(Some(&old_tree), Some(&new_tree), &TreeDiffOptions::default())?
    .entries;
// `DiffOptions::default()` pairs renames at Git's -M50 before counting lines. When the
// entries are already rename-aware, pass `DiffOptions::default().with_renames(RenameDetection::Off)`.
let stat = repo.diff().stat(entries, &DiffOptions::default())?;
for file in stat.files() {
    let bar = file.lines.bar(stat.max_changes(), 40);
    println!("{} | {}{}", file.path, "+".repeat(bar.plus), "-".repeat(bar.minus));
}
let totals = stat.totals();
println!("{} files, +{} -{}", totals.files_changed, totals.insertions, totals.deletions);
```

Under any whitespace rule (`-w`, `-b`, `--ignore-space-at-eol`, `--ignore-blank-lines`), Git leaves out of `--stat` any modified text file whose changes were all ignored. [`FileDiff::changes_all_ignored`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.ListedFileDiff.html#method.changes_all_ignored) tells you which rows those are. Additions, deletions, renames, mode changes and binary files stay listed. For a stash, [`RepositoryStash::diff_stat`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryStash.html#method.diff_stat) returns the finished `DiffStat` of `stash@{n}` against its base (`git stash show --stat`). It counts lines without building hunks and applies that whitespace rule.

For history listings, [`Diff::commit_files_many`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.commit_files_many) diffs a batch of commits against their first parents in parallel, reusing each parent tree when the commits are newest-first linear history; `grit log --stat`, `--numstat` and `-p` use it. When you only need per-commit counts, [`Diff::commit_line_totals`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.commit_line_totals) returns one [`DiffTotals`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffTotals.html) per commit (the numbers in `git log --shortstat`), limited to the [`Pathspec`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html) you pass. Merges are not diffed and get `None`; a root commit is compared with the empty tree. A terminal `grit log` draws these as the `+added -removed` column and hides commits whose totals are zero.

## Porcelain models

- **Status** — combines index vs HEAD and index vs worktree scans into structured sections (the CLI maps them to default / `--json` / `--markdown` output).
- **Add** — uses diff results to decide which paths to hash and stage.
- **Diff command** — tree-to-tree for commit ranges, index-to-worktree for uncommitted changes, then blob-level rendering for text files.

## Example

The program below diffs the latest commit against its parent (tree-to-tree), checks whether the work tree is dirty, and counts unified-diff lines for one modified blob:

```rust
//! Tree-to-tree, index-to-worktree, and blob diffs used by porcelain and the CLI.
//!
//! Source for the library guide "Diff" page (included in the docs site).

use anyhow::Result;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::diff::{unified_diff, DiffEntry, DiffStatus, TreeDiffOptions, UnifiedDiffOptions};
use grit_lib::repo::Repository;

use std::path::{Path, PathBuf};

fn open_repo(root: &Path) -> Result<Repository> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::from_process();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Ok(Repository::open(&git_dir, &opts)?)
}

fn print_name_status(entries: &[DiffEntry]) {
    for entry in entries {
        let letter = entry.status.letter();
        let path = entry.path();
        if entry.status == DiffStatus::Renamed {
            if let (Some(old), Some(new)) = (&entry.old_path, &entry.new_path) {
                println!("{letter}\t{old}\t{new}");
                continue;
            }
        }
        println!("{letter}\t{path}");
    }
}

fn main() -> Result<()> {
    let root = std::env::args()
        .nth(1)
        .map(PathBuf::from)
        .or_else(|| std::env::current_dir().ok())
        .ok_or_else(|| anyhow::anyhow!("missing repository path"))?;
    let repo = open_repo(&root)?;

    let head = repo.references().head()?;
    let new_commit = head
        .oid()
        .cloned()
        .ok_or_else(|| anyhow::anyhow!("HEAD has no commit"))?;
    let new_commit_data = repo.objects().read_commit(&new_commit)?;
    let parent = new_commit_data
        .parents
        .first()
        .copied()
        .ok_or_else(|| anyhow::anyhow!("need a commit with a parent"))?;

    let old_tree = repo.objects().commit_tree(&parent)?;
    let new_tree = new_commit_data.tree;

    let tree_changes = repo
        .diff()
        .tree_to_tree(
            Some(&old_tree),
            Some(&new_tree),
            &TreeDiffOptions::default(),
        )?
        .entries;
    println!("tree_diff_begin");
    print_name_status(&tree_changes);
    println!("tree_diff_end");

    if repo.work_tree().is_some() {
        let mut index = repo
            .index()
            .load(&grit_lib::index::IndexLoadOptions::default())?;
        let wt_changes = repo.diff().index_to_worktree(
            &mut index,
            &TreeDiffOptions::default(),
            &mut grit_lib::progress::NullProgress,
            &grit_lib::progress::CancelToken::never(),
        )?;
        println!("index_worktree_dirty={}", !wt_changes.entries.is_empty());
    }

    if let (Some(entry),) = (tree_changes.first(),) {
        if entry.status == DiffStatus::Modified {
            let old_blob = repo.odb().read(&entry.old_oid)?.data;
            let new_blob = repo.odb().read(&entry.new_oid)?.data;
            let old_text = String::from_utf8_lossy(&old_blob);
            let new_text = String::from_utf8_lossy(&new_blob);
            let old_path = entry.old_path.as_deref().unwrap_or(entry.path());
            let new_path = entry.new_path.as_deref().unwrap_or(entry.path());
            let options = UnifiedDiffOptions::new().with_paths(old_path, new_path);
            let patch = unified_diff(&old_text, &new_text, &options);
            let hunk_lines = patch
                .lines()
                .filter(|l| l.starts_with('-') || l.starts_with('+'))
                .count();
            println!("blob_unified_hunk_lines={hunk_lines}");
        }
    }

    Ok(())
}
```

Requires a repository whose `HEAD` has a parent (at least two commits):

```bash
cargo run --bin guide_diff /path/to/repo
git -C /path/to/repo diff --name-status HEAD~1 HEAD
```

# https://grit-scm.com/docs/library/embedding/index.md

# Embedding grit-lib

> Run multiple repositories in one process with explicit Environment, sinks, subprocess injection, and typed errors.

Grit is designed to be **linked into other Rust programs**, not only invoked as the `grit` CLI. The library avoids hidden process globals: discovery variables, config identity, subprocesses, warnings, and wall-clock references are supplied through explicit types at the boundary.

## Environment

[`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html) holds Git discovery and configuration variables (`GIT_DIR`, `GIT_WORK_TREE`, `GIT_CONFIG_*`, home paths, author/committer overrides, transport trace flags, and related fields). Construct it with:

- [`Environment::capture_process`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html#method.capture_process) — an explicit snapshot of the calling process (`HOME`, `GIT_*`, Windows `ProgramFiles`, identity variables, …). This is what the `grit` CLI uses, and what a tool working on a user's repositories should use. Call it in your program, never from library code.
- [`Environment::from_vars`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html#method.from_vars) — parse an iterator of `(key, value)` pairs plus an explicit working directory (no reads from `std::env` inside the library).
- [`Environment::empty`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html#method.empty) — no variables at all (`cwd = "."`). There is no home directory, so the global `~/.gitconfig` is not read, and on Windows the Git for Windows system gitconfig cannot be found. On Unix `/etc/gitconfig` still loads unless you set `git_config_nosystem`.

Pass the same `Environment` into `Repository` (`discover` / `open`) and into `ConfigSet` loading.

### Matching `git` and `grit` on user repositories

System and global config decide much of what a repository operation does: `core.autocrlf` (Git for Windows sets it to `true` in its system config), `user.name` / `user.email`, `safe.directory`, `core.excludesFile`, credential helpers. A program that should give the same answers as `git` and `grit` on the user's machine opens repositories with [`RepositoryOptions::from_process`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.from_process):

```rust
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::repo::Repository;

let repo = Repository::discover(None, &RepositoryOptions::from_process())?;
```

With [`RepositoryOptions::empty`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.empty) none of that config applies. For example, on Windows `status` then reports CRLF files that `git status` calls clean as modified. Use `empty()` for hermetic work such as tests or a repository your program created itself. The examples on these pages that open your repository use `from_process()`; the ones that create a throwaway repository (`guide_embedding` below, and `guide_index`, `guide_objects` and `guide_replay_conflicts` when run without a path) stay on `empty()`, and `guide_embedding` sets its home directory and disables the system config explicitly.

Clones share the captured variable map, avoiding a copy of every inherited variable during
repository setup. Typed fields remain independent: changing or clearing an override on a
clone leaves the original snapshot unchanged. Untyped variables, including non-Unicode
values, remain available to subprocesses after the original snapshot is dropped.
Empty snapshots need no allocation for the captured map.

## RepositoryOptions

[`RepositoryOptions`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html) bundles everything needed to open a repository besides paths:

| Field | Role |
| --- | --- |
| `environment` | Discovery/config/identity snapshot |
| `command_runner` | Injectable subprocess execution (hooks, filters, signing helpers) |
| `diagnostics` | `DiagnosticSink` for warnings and trace events |
| `network_trace` | When true, emit network trace events via the diagnostics sink |
| `reference_unix_time` | Wall clock for rev-parse date selectors (`@{yesterday}`, etc.) |
| `ownership_check` | Injectable [`OwnershipCheck`](https://docs.rs/grit-lib/latest/grit_lib/ownership_check/trait.OwnershipCheck.html) for `safe.directory` (default [`SystemOwnershipCheck`](https://docs.rs/grit-lib/latest/grit_lib/ownership_check/struct.SystemOwnershipCheck.html)) |

Construct options with one of the associated constructors, then chain the builder methods:

| Constructor | Environment |
| --- | --- |
| [`RepositoryOptions::from_process()`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.from_process) | Snapshot of the calling process, like `git` and `grit` |
| [`RepositoryOptions::with_environment(env)`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_environment) | An [`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html) you built |
| [`RepositoryOptions::empty()`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.empty) | [`Environment::empty`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html#method.empty) |

`with_environment` takes the environment and returns new options, so write `RepositoryOptions::with_environment(env).with_command_runner(runner)`; `RepositoryOptions::empty().with_environment(env)` does not compile. Assign `diagnostics` (or call `with_diagnostics`) when you need a custom sink.

## DiagnosticSink and ProgressSink

Non-fatal conditions are `Warning` values delivered to a `DiagnosticSink`. The default is `NullDiagnostics`. Tests and embedders often use `CollectingDiagnostics` to assert warnings without parsing stderr.

Long-running work (status, staging and commit, stash, merge, rebase, checkout and switch, fetch, pack indexing) takes a [`ProgressSink`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html) and a [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html). Pass [`NullProgress`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.NullProgress.html) and [`CancelToken::never`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html#method.never) when you don't want progress updates or interruption.

Share cancellation across threads or wire a UI stop button with [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html): clone the token, call [`cancel`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html#method.cancel) from another thread, and pass `&token` anywhere a [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html) is accepted today. Do not poll cancellation from a custom [`ProgressSink`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html); see [Progress and cancellation](https://grit-scm.com/docs/library/embedding/parallelism.md/index.md#progress-and-cancellation) for where a cancel lands. Progress is separate from diagnostics: progress reports throughput; diagnostics report Git-style warnings.

## CommandRunner

`CommandRunner` is the only production path that spawns OS processes from the library (`SystemCommandRunner`). Hooks, smudge/clean filters, credential helpers, and signing helpers build a `CommandSpec` and call `spawn`.

Shell commands use a `CommandSpec` whose program is `sh`. `SystemCommandRunner` runs that the way Git does: `/bin/sh` on Unix. On Windows it uses the `sh` of the Git for Windows install that owns the `git` on the child's `PATH` (`usr\bin`, then `bin`), then any `sh` on that `PATH`. Filters and helpers therefore work when only Git's `cmd` directory is on `PATH`.

For tests, [`RecordingRunner`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.RecordingRunner.html) records specs and returns scripted exit codes. Install it on [`RepositoryOptions`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html) before [`Repository::open`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) or [`Repository::discover`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html).

## Typed errors

Library APIs return `grit_lib::error::Result`. Match on the umbrella's area variant and then the area enum's variant (`Error::Revision(RevisionError::Parse(..))`, `Error::Hook(..)`, `Error::Worktree(WorktreeError::Filter(..))`, …) instead of parsing `"fatal:"` strings. The CLI maps variants to exit codes and human messages in its own words.

Area enums, shared leaf types, JSON `kind` slugs, and migration rules are documented in [Typed errors](https://grit-scm.com/docs/library/embedding/docs/library/errors/index.md). The umbrella [`Error`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html) has one variant per area; [`Error::kind_name`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#method.kind_name) names the specific failure and [`Error::area`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#method.area) its area.

Common conditions use dedicated variants rather than message strings: bare or missing work tree → [`RepositoryError::RequiresWorkTree`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html#variant.RequiresWorkTree) (via [`Error::Repository`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Repository)); empty commit body → [`CommitError::EmptyCommitMessage`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.CommitError.html#variant.EmptyCommitMessage) (via [`Error::Commit`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Commit)); path missing from a revision tree → [`RevParseError::PathNotInRevision`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_parse_error/enum.RevParseError.html#variant.PathNotInRevision); parent navigation past root → [`RevParseError::RevisionOutOfRange`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_parse_error/enum.RevParseError.html#variant.RevisionOutOfRange); pack deltas whose bases are in neither the pack nor the object database (a thin pack received without its bases) → [`ObjectError::UnresolvedDeltas`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.UnresolvedDeltas); a `.idx` whose trailing checksum is wrong, on reads that verify it → [`ObjectError::PackIndexChecksumMismatch`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.PackIndexChecksumMismatch).

## Code layout

Enable the `hot-text-layout` feature to have grit-lib's hot code path (the library, runtime and dependency functions its common operations run) placed contiguously in your binary:

```toml
[dependencies]
grit-lib = { version = "0.5", features = ["hot-text-layout"] }
```

A short operation then faults in a few contiguous code pages instead of windows scattered over the whole binary. `grit status` on 10,000 files drops from 14.2 to 11.5 MB of peak RSS with it, and nothing changes at run time. The feature acts only on `x86_64-unknown-linux-gnu`, where rustc links with LLD; elsewhere it does nothing. Set `GRIT_HOT_TEXT_LAYOUT=0` at build time if you link with another linker. See [Hot text layout](https://grit-scm.com/docs/library/benchmarking.md/index.md#hot-text-layout).

## Serializable results

Enable the `serde-models` feature to get `serde::Serialize` on the results a front end renders, so you don't write your own JSON types for them:

```toml
[dependencies]
grit-lib = { version = "0.5", features = ["serde-models"] }
```

The feature covers [`StatusModel`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.StatusModel.html) (including its paused [`Operation`](https://docs.rs/grit-lib/latest/grit_lib/state/struct.Operation.html), state flags and conflict kinds; the loaded index is not serialized), [`DiffEntry`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffEntry.html), [`LoadedCommit`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/log/struct.LoadedCommit.html), porcelain outcomes for merge ([`IntegrateBranchOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/enum.IntegrateBranchOutcome.html)), pull ([`PullOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/struct.PullOutcome.html)), clone ([`CloneOutcome`](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/struct.CloneOutcome.html); the open [`Repository`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) is omitted), checkout ([`CheckoutOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/checkout/struct.CheckoutOutcome.html)), stage/clean/restore/remove/move ([`StageOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/add/struct.StageOutcome.html), [`CleanOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/clean/struct.CleanOutcome.html), [`RestoreOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/restore/struct.RestoreOutcome.html), [`RemoveOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/paths/struct.RemoveOutcome.html), [`MoveOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/paths/struct.MoveOutcome.html)), tag create ([`CreateTagOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/struct.CreateTagOutcome.html); tree-sha256 detail is omitted), stash push ([`StashPushResult`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashPushResult.html)), commit/switch/reset, branch listing ([`BranchList`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.BranchList.html), [`BranchSummary`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.BranchSummary.html), [`TargetComparison`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.TargetComparison.html)), stash apply/list, fetch/push, history rewrites and rebase ([`CommitOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitOutcome.html), [`SwitchOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/switch/struct.SwitchOutcome.html), [`ResetOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/reset/struct.ResetOutcome.html), [`StashEntry`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashEntry.html), [`StashApplyOutcome`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashApplyOutcome.html), [`FetchOutcome`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOutcome.html), [`PushOutcome`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PushOutcome.html), [`RewritePlan`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewritePlan.html), [`RebaseOutcome`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebaseOutcome.html), [`RebasePlan`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebasePlan.html), [`UndoOutcome`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.UndoOutcome.html)), refs and notes ([`RefListing`](https://docs.rs/grit-lib/latest/grit_lib/refs/listing/struct.RefListing.html), [`ReflogEntry`](https://docs.rs/grit-lib/latest/grit_lib/refs/reflog/struct.ReflogEntry.html), [`NoteListing`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.NoteListing.html)), index and objects ([`IndexEntry`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexEntry.html), [`TreeEntry`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeEntry.html), [`ObjectInfo`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectInfo.html)), diff depth ([`FileDiff`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.FileDiff.html), [`DiffStat`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffStat.html) with [`FileStat`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.FileStat.html) rows), maintenance ([`GcStats`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.GcStats.html)), rev-list ([`RevListResult`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListResult.html); internal walk buffers are omitted), smart HTTP serve ([`UploadOutcome`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.UploadOutcome.html), [`ReceiveOutcome`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceiveOutcome.html)), bundles ([`UnbundleOutcome`](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.UnbundleOutcome.html)), config ([`ConfigEntry`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigEntry.html)), plus blame ([`BlameResult`](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameResult.html)), describe ([`DescribedCommit`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.DescribedCommit.html)), tag list ([`TagSummary`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/struct.TagSummary.html), [`TagList`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/enum.TagList.html)), and worktree list ([`WorktreeEntry`](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.WorktreeEntry.html)). The shapes:

| Type | JSON |
| --- | --- |
| [`ObjectId`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectId.html), [`ChangeId`](https://docs.rs/grit-lib/latest/grit_lib/change_id/struct.ChangeId.html) | hex string |
| [`FileMode`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.FileMode.html) | octal string such as `"100644"`; `"000000"` for the missing side of an add or delete |
| [`IndexEntry`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexEntry.html) | `path` as UTF-8 text (lossy when needed); `mode` as a [`FileMode`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.FileMode.html) octal string |
| [`TreeEntry`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeEntry.html) | `name` as UTF-8 text; `mode` as Git's minimal octal (`"40000"` for trees) |
| [`BranchSummary`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.BranchSummary.html) | `committer_time` as RFC 3339 when present |
| [`DiffStat`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffStat.html) | `files` ([`FileStat`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.FileStat.html) rows) and `totals` |
| [`HunkId`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.HunkId.html) | 12 lowercase hex characters |
| [`Signature`](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.Signature.html), [`CommitAuthorInfo`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitAuthorInfo.html) | `{"name", "email", "date"}`, with `date` in RFC 3339 keeping the recorded offset |
| [`Error`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html) | Always `kind`, `message`, and additive `area` ([`Error::area`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#method.area); not a script contract). Selected variants also expose structured fields: `LockHeld` → `path`, optional `holder` `{pid, running}`; `WouldOverwrite` → `reason`, `paths`; `StashCouldNotRestoreUntracked` → `path`; `DirtyWorktree` → `operation`, `paths`; `UnmergedConflictMarkers` → `paths` |
| enums | snake_case variant names (`"type_changed"`, `"merge"`); hook names use Git's spelling (`"pre-commit"`) |

`LoadedCommit` holds typed author and committer signatures. A commit whose identity line has a malformed date still loads, with the Unix epoch as its date, the way `git log` shows it ([`Signature::from_header_lossy`](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.Signature.html#method.from_header_lossy)).

[`CommitOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitOutcome.html) includes the full commit `message`, `author`, and `committer` ([`CommitAuthorInfo`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitAuthorInfo.html) serializes like [`Signature`](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.Signature.html)). [`CommitFile`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitFile.html) status uses snake_case enum names (`modified`, …) in JSON; the `grit commit --json` command still prints Git's single-letter codes and adds scope, subject, and dry-run fields the library outcome does not carry. The same pattern applies to blame, describe, tag list, and worktree list: CLI `--json` is a thin view over these library models (extra fields such as `file`/`rev` on blame, flattened branch/head on worktree list), not a byte-identical dump of `serde_json::to_value` on the library type.

## Concurrency

Two or more `Repository` handles may be used from different threads in one process when each handle is opened with its **own** `Environment`, `RepositoryOptions`, diagnostics sink, and command runner. Repository-scoped caches (config, attributes, pack read caches) do not leak between handles.

Object writes are safe to race. Every loose object is staged in its own uniquely named `objects/xx/tmp_obj_*` file and renamed into place, so handles, threads or processes writing the same object at once all get its id back (whichever rename lands first publishes it, the same as Git). Pack installs are safe to race too, so parallel fetches into one repository all succeed: [`install_pack_path`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.install_pack_path.html) stages each install in its own directory, and fetches from a local remote hard-link or copy its packs through a private temp file. Both publish without replacing a `.pack` or `.idx` that is already there under the same content-addressed name (the `.idx` always lands after its `.pack`), and a failed or cancelled install removes only its private staging files, never a published `.pack` or `.idx` another writer may already rely on. Ref updates such as adding a note are compare-and-swap: when two writers race, one wins and the other gets a typed ref-store error instead of losing the first update.

Integration coverage: `grit-lib/tests/concurrent_repos.rs` runs parallel commit loops and a fetch/merge/notes scenario with isolated config and sinks; `grit-lib/tests/loose_write_concurrent_issue_1875.rs` races identical small and large blob writes from separate handles and checks the result with `git fsck --strict`; `grit-lib/tests/index_pack_parallel.rs` installs one pack from several threads into one repository and checks it the same way.

## Example

```rust
//! Open two repositories in one process with isolated environments and sinks.
//!
//! Source for the library guide "Embedding" page (included in the docs site).

use std::sync::Arc;

use grit_lib::command_runner::RecordingRunner;
use grit_lib::config::environment::{Environment, RepositoryOptions};
use grit_lib::diagnostics::{CollectingDiagnostics, DiagnosticSink};
use grit_lib::error::Error;
use grit_lib::repo::{InitOptions, Repository};

fn main() -> Result<(), Error> {
    let base = tempfile::tempdir().map_err(Error::Io)?;

    let open_named =
        |name: &str, email: &str| -> Result<(Repository, Arc<CollectingDiagnostics>), Error> {
            let root = base.path().join(name);
            let (_repo, _) = Repository::init(
                &root,
                &InitOptions::new()
                    .with_initial_branch("main")
                    .with_ref_storage(grit_lib::refs::ref_storage::RefStorageFormat::Files),
            )?;

            let home = base.path().join(format!("home-{name}"));
            std::fs::create_dir_all(&home).map_err(Error::Io)?;
            let global = home.join(".gitconfig");
            std::fs::write(
                &global,
                format!("[user]\n\tname = {name}\n\temail = {email}\n"),
            )
            .map_err(Error::Io)?;

            let mut env = Environment::empty();
            env.cwd = root.clone();
            env.home = Some(home.into());
            env.git_config_global = Some(global.to_string_lossy().into_owned());
            env.git_config_nosystem = Some("true".into());
            env.git_config_system = Some("/dev/null".into());

            let diagnostics = Arc::new(CollectingDiagnostics::new());
            let sink: Arc<dyn DiagnosticSink + Send + Sync> = diagnostics.clone();
            let runner = RecordingRunner::always_success();
            let mut options = RepositoryOptions::with_environment(env).with_command_runner(runner);
            options.diagnostics = sink;

            let git_dir = root.join(".git");
            let repo = Repository::open(&git_dir, &options.clone().with_work_tree(&root))?;
            Ok((repo, diagnostics))
        };

    let (repo_a, sink_a) = open_named("alpha", "a@example.com")?;
    let (repo_b, sink_b) = open_named("beta", "b@example.com")?;

    let name_a = repo_a
        .config()
        .snapshot()?
        .get("user.name")?
        .unwrap_or_default();
    let name_b = repo_b
        .config()
        .snapshot()?
        .get("user.name")?
        .unwrap_or_default();
    println!("alpha user.name={name_a}");
    println!("beta user.name={name_b}");
    println!("alpha warnings={}", sink_a.warnings().len());
    println!("beta warnings={}", sink_b.warnings().len());

    Ok(())
}
```

Build and run:

```bash
cargo run -p grit-examples --bin guide_embedding
```

## Blame and repository-relative paths

[`Diff::blame`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.blame),
[`compute_blame`](https://docs.rs/grit-lib/latest/grit_lib/blame/fn.compute_blame.html), and
[`Diff::resolve_blame_line_range`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.resolve_blame_line_range)
take **repository-relative** paths. Like [`RevWalk::commits`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.commits) and [`RevWalk::describe`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.describe), they accept a [`ProgressSink`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html) and [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html) after their options (use [`NullProgress`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.NullProgress.html) and [`CancelToken::never`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html#method.never) when unused): the same string names the same file no matter
where the host process is running. Pass status paths unchanged. For a raw byte
path, build the input with `repo_relpath::storage_string`. Non-UTF-8 paths and
names beginning with the reserved `grit+pathhex:` prefix are escaped. Absolute
paths under the work tree and `./` / `../` segments normalize against the
work-tree root. To turn command-line operands into that form (cwd-relative, like
`git blame`), resolve each path with
[`Repository::resolve_worktree_pathspec`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.resolve_worktree_pathspec)
using [`Repository::pathspec_argv_prefix`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.pathspec_argv_prefix)
before calling blame APIs.

Every blame `original_path`, including hunks and rename/copy origins, uses that
same storage representation. Recover its exact bytes with
`repo_relpath::storage_bytes`. Decode once:
a literal filename that itself resembles an encoded path is a separate file.
Line ranges and Git-written changed-path Bloom filters use the decoded path too.

### Blaming uncommitted content

By default `repo.diff().blame` blames the file as committed at
[`BlameOptions::start`](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameOptions.html#structfield.start) (or
`HEAD`). Set
[`BlameOptions::final_source`](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameOptions.html#structfield.final_source)
to [`BlameFinalSource::Worktree`](https://docs.rs/grit-lib/latest/grit_lib/blame/enum.BlameFinalSource.html#variant.Worktree)
to blame the working-tree file, or to
[`BlameFinalSource::Contents`](https://docs.rs/grit-lib/latest/grit_lib/blame/enum.BlameFinalSource.html#variant.Contents)
with an editor buffer's bytes. The content is blamed as a commit on top of the
start revision (plus any `MERGE_HEAD` commits), so returned line numbers match
the buffer. Lines that exist only in that content have
[`BlameAttributedLine::not_committed`](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameAttributedLine.html#structfield.not_committed)
set and the null object id as `commit`; their
[`BlameCommitInfo`](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameCommitInfo.html) carries
[`BlameOptions::now`](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameOptions.html#structfield.now) as the author
time and the placeholder identity Git reports (`Not Committed Yet`, or
`External file (--contents)` for a buffer; see
[`BlameFinalSource::uncommitted_author_name`](https://docs.rs/grit-lib/latest/grit_lib/blame/enum.BlameFinalSource.html#method.uncommitted_author_name)).
[`BlameResult::hunks`](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameResult.html#method.hunks) groups the
lines like `git blame --porcelain`; each
[`BlameHunk`](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameHunk.html) flags `not_committed` and
hands back its own lines through
[`BlameResult::hunk_lines`](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameResult.html#method.hunk_lines). Resolve `-L` specs against the same
text with
[`Diff::resolve_blame_line_range_with_options`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.resolve_blame_line_range_with_options).
Nothing is written to the object database.

```rust
use grit_lib::blame::{BlameFinalSource, BlameOptions};
use grit_lib::progress::{CancelToken, NullProgress};

# fn editor(repo: &grit_lib::repo::Repository, buffer: Vec<u8>) -> grit_lib::error::Result<()> {
let result = repo.diff().blame(
    "src/main.rs",
    &BlameOptions::default().with_final_source(BlameFinalSource::Contents(buffer)),
    &mut NullProgress,
    &CancelToken::never(),
)?;
for line in result.lines.iter().filter(|line| line.not_committed) {
    println!("unsaved or uncommitted: {}", line.content);
}
# Ok(())
# }
```

# https://grit-scm.com/docs/library/errors/index.md

# errors

# Typed errors in grit-lib

Grit-lib returns **structured errors**, not strings. Every fallible library call returns [`grit_lib::error::Result`](https://docs.rs/grit-lib/latest/grit_lib/error/type.Result.html), whose error is the umbrella [`Error`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html). The umbrella has **one variant per functional area**, and each area variant carries that area's own `#[non_exhaustive]` `thiserror` enum (see the [error contract](https://github.com/gitbutlerapp/grit/blob/main/grit-lib/API.md#4-typed-errors-per-area) in `API.md`).

## Matching an error

Match the area first, then the area's variant:

```rust
use grit_lib::error::{Error, RefError, RevisionError};

fn describe(err: &Error) -> &'static str {
    match err {
        Error::Revision(RevisionError::NotFound { .. }) => "no such revision",
        Error::Ref(RefError::UnbornHead) => "no commits yet",
        Error::LockHeld(_) => "another process holds a lock",
        err if err.is_cancelled() => "cancelled",
        _ => "something else",
    }
}
```

Both [`Error`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html) and every area enum are `#[non_exhaustive]`, so a match always ends in a wildcard arm. Area enums convert into the umbrella with `From`, so `?` works across areas inside your own code.

## Rules

- Match on **types and variants**, not message text. Human wording is for the CLI only.
- No catch-all `Message(String)` variant anywhere; no `Result<_, String>` in the public API.
- Named fields only: `PathBuf`, object ids, ref names, reason enums. A bare `String` field is allowed only for **external data** (for example a remote's error line) and must be a **named** field, not a tuple variant.
- Use [`PathIoError`](https://docs.rs/grit-lib/latest/grit_lib/error/struct.PathIoError.html) for path-related I/O; do not add bare `#[from] io::Error` on area enums.
- Area enums never hold another umbrella `Error`. A failure in a lower area surfaces as that area's own umbrella variant (a missing object during a checkout is [`Error::Object`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Object), not a checkout error that wraps it).
- When a variant must report a *secondary* failure next to its own (a rollback that also failed, one promisor remote's failure among several), it keeps an [`ErrorSummary`](https://docs.rs/grit-lib/latest/grit_lib/error/struct.ErrorSummary.html) of it: the inner failure's `kind`, `area`, message and whether it was a cancellation.
- Corrupt loose/packed reads use [`ObjectReadFailure`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectReadFailure.html) as the `source` of [`ObjectError::CorruptLoose`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.CorruptLoose) / [`ObjectError::CorruptPacked`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.CorruptPacked).
- Public functions return `grit_lib::error::Result<T>` (or a small leaf error for pure parsers), not per-area type aliases.

## Shared leaf types

| Type | Role |
| --- | --- |
| [`LockHeldError`](https://docs.rs/grit-lib/latest/grit_lib/error/struct.LockHeldError.html) | Lock file exists; optional [`LockHolder`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/struct.LockHolder.html) from the pid sidecar ([`Error::LockHeld`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.LockHeld)) |
| [`PathIoError`](https://docs.rs/grit-lib/latest/grit_lib/error/struct.PathIoError.html) | Worktree or git-dir path I/O with [`PathIoOperation`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.PathIoOperation.html); read it back with [`Error::path_io`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#method.path_io) |
| [`Cancelled`](https://docs.rs/grit-lib/latest/grit_lib/error/struct.Cancelled.html) | Operation stopped via [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html) ([`Error::Cancelled`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Cancelled); test with [`Error::is_cancelled`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#method.is_cancelled)) |
| [`ErrorSummary`](https://docs.rs/grit-lib/latest/grit_lib/error/struct.ErrorSummary.html) | Kind, area and message of a secondary failure inside another error |
| [`ObjectReadFailure`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectReadFailure.html) | Non-recursive decode failure for corrupt loose/packed object reads |

## Area map

| Umbrella variant | Area enum | Covers |
| --- | --- | --- |
| [`Error::Repository`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Repository) | [`RepositoryError`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html) | open, init, layout, ownership, git-dir path I/O |
| [`Error::Object`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Object) | [`ObjectError`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html) | object ids, ODB, packs, MIDX, bitmaps, promisor fetches |
| [`Error::Index`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Index) | [`IndexError`](https://docs.rs/grit-lib/latest/grit_lib/index/error/enum.IndexError.html) | corrupt bytes, unmerged paths, fsmonitor/cache-tree extensions, split index |
| [`Error::Ref`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Ref) | [`RefError`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.RefError.html) | ref names, `HEAD` state, ref store, reftable, reflog |
| [`Error::Revision`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Revision) | [`RevisionError`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.RevisionError.html) | rev-parse, rev-list, merge bases |
| [`Error::Config`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Config) | [`ConfigError`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ConfigError.html) | config parsing, includes, writes |
| [`Error::Worktree`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Worktree) | [`WorktreeError`](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.WorktreeError.html) | checkout, status, add/rm/mv/restore/clean, pathspec, filters, submodules, linked worktrees |
| [`Error::Diff`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Diff) | [`DiffError`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.DiffError.html) | diff, blame, apply, hunk selection, textconv |
| [`Error::Commit`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Commit) | [`CommitError`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.CommitError.html) | messages, identity, signing, change ids |
| [`Error::Merge`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Merge) | [`MergeError`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html) | merge, pick, revert, sequencer, operation state, pull |
| [`Error::History`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.History) | [`HistoryError`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html) | history rewrites, rebase sessions, undo |
| [`Error::Stash`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Stash) | [`StashError`](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.StashError.html) | stash push, apply, drop |
| [`Error::Branch`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Branch) | [`BranchError`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/enum.BranchError.html) | branch create, delete, rename, switch targets |
| [`Error::Tag`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Tag) | [`TagError`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/enum.TagError.html) | tag create, delete, verify |
| [`Error::Notes`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Notes) | [`NotesError`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.NotesError.html) | notes refs and edits |
| [`Error::Remote`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Remote) | [`RemoteError`](https://docs.rs/grit-lib/latest/grit_lib/remote/enum.RemoteError.html) | transports, fetch, push, clone, bundles, credentials, serve, snapshot checkouts |
| [`Error::Hook`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Hook) | [`HookError`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.HookError.html) | hooks that fail or cannot start |
| [`Error::Io`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Io) | `std::io::Error` | I/O not tied to a repository path |
| [`Error::LockHeld`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.LockHeld) | [`LockHeldError`](https://docs.rs/grit-lib/latest/grit_lib/error/struct.LockHeldError.html) | lock contention in any area |
| [`Error::Cancelled`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Cancelled) | — | cancellation in any area |

Fold tiny areas into a neighbour; do not add an umbrella variant for only one or two failures.

## JSON and scripts

[`Error::kind_name`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#method.kind_name) returns a stable snake_case slug for the specific failure (for example `revision_not_found` or `unborn_head`); each area enum keeps the slugs its variants had before the umbrella collapsed. [`Error::area`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#method.area) returns the area (`"revision"`, `"ref"`, …). With the `serde-models` feature a serialized error carries both, as `kind` and the additive `area` field. See [Embedding — Typed errors](https://grit-scm.com/docs/library/errors/docs/library/embedding/index.md#typed-errors).

## Ratchet

Quality counts in [`api-ratchet.toml`](https://github.com/gitbutlerapp/grit/blob/main/grit-lib/api-ratchet.toml) track the umbrella variant count, catch-all variants, string tuples, missing `#[non_exhaustive]`, area enums that hold an umbrella `Error`, and `Error::Message(` construction sites under `grit-lib/src`. The catch-all, string, `non_exhaustive`, nesting and construction-site counts are all zero; `make api-ratchet-check` in CI keeps them there.

# https://grit-scm.com/docs/library/history/index.md

# History rewrite

> Plan in-memory history edits, then apply ref and worktree updates atomically.

The [`history`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/index.html) module supports stateless history editing: build a [`RewritePlan`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewritePlan.html) in memory, inspect or dry-run it, then [`History::apply`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.apply) to move refs and align the worktree. Every operation is a method on the [`History`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html) handle from [`Repository::history`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.history):

```rust
let history = repo.history();
let plan = history.reword(commit, &RewordOptions::default().with_message("New subject\n"), &rewrite)?;
history.verify_plan(&plan)?;
history.apply(&plan, &apply, &mut NullProgress, &CancelToken::never())?;
```

Methods that apply a plan take a trailing [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html) (and a [`ProgressSink`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html) where they report work-tree progress); a cancel rolls back partial work.

## Model

1. **Plan** — [`History::plan_rewrite`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.plan_rewrite) walks affected commits, writes replacement objects into the ODB, and records ref movements in a [`RewritePlan`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewritePlan.html). Refs, the index, and the worktree are untouched during planning.
2. **Apply** — [`History::apply`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.apply) writes a crash journal under `.git/grit/rewrite-apply/` when a worktree checkout is required, runs a compare-and-swap ref batch, then (in non-bare repos) checks out from the old `HEAD` tree to the new one while preserving unrelated staged and unstaged changes. On success the journal is removed. If the process dies after refs move but before checkout finishes, [`History::recover_interrupted_apply`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.recover_interrupted_apply) (also run from [`status`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/fn.status_options_from_config.html) and before [`create_commit`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitRequest.html)) finishes the checkout when refs already match the plan, or rolls refs and the index/worktree back from the journal. Recovery holds `index.lock` for its whole run: when grit recorded a pid sidecar for the lock (the default; see [`grit_lockfile_pid_enabled`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/fn.grit_lockfile_pid_enabled.html)) and that process has exited, [`LockHolder::remove_if_stale`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/struct.LockHolder.html#method.remove_if_stale) removes the lock first; any other existing lock returns [`Error::LockHeld`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.LockHeld) without touching refs. To finish, it first restores the journal's index and the transition paths it captured (a kill mid-checkout can leave files half written), then checks out the new tree again, so the partial checkout is not mistaken for local edits. Only if that checkout still fails are refs rolled back, and the call returns [`RewriteApplyRecovery::RolledBack`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RewriteApplyRecovery.html#variant.RolledBack) rather than the checkout error. A journal directory without its `meta` file (killed while the snapshots were written, before any ref moved) is removed. [`status`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/fn.status_options_from_config.html) reports what happened in [`StatusModel::interrupted_rewrite`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.StatusModel.html#structfield.interrupted_rewrite), with [`InterruptedRewrite::Pending`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/enum.InterruptedRewrite.html#variant.Pending) when another process holds the index lock. While the journal remains, [`HistoryError::RewriteApplyIncomplete`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.RewriteApplyIncomplete) blocks new commits; `grit rebase --abort` calls [`History::abort_interrupted_apply`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.abort_interrupted_apply) to roll back explicitly.

[`CommitEdit`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.CommitEdit.html) describes per-commit rewrites, drops, and insert-before commits. [`RewriteOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewriteOptions.html) controls scope, empty-commit policy, the committer [`Signature`](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.Signature.html) used for new objects (usually `repo.identity(IdentRole::Committer, now)`), and whether replacement commits are signed ([`RewriteOptions::sign`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewriteOptions.html#structfield.sign) — set `false` for dry-run planning so signers are not invoked).

When a rewrite replays descendant **merge** commits, [`History::plan_rewrite`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.plan_rewrite) remaps every parent and recomputes the merge tree (first-parent transplant when side branches are unchanged, otherwise a fresh merge of the mapped parents). Dropping or reordering a merge commit itself is still rejected ([`HistoryError::MergeCommitInReplay`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.MergeCommitInReplay)).

For a message or author change, [`History::reword`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.reword) takes a [`RewordOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewordOptions.html), builds the [`CommitEdit`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.CommitEdit.html) and runs [`History::plan_rewrite`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.plan_rewrite) after [`normalize_rewrite_message`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/fn.normalize_rewrite_message.html) (stripspace, trailing newline, reject empty).

To reorder one commit on the linear first-parent chain of `HEAD`, [`History::move_commit`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.move_commit) takes a [`Placement`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.Placement.html) (`Before` / `After` another commit), replays the affected segment in the new order, and returns a [`RewritePlan`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewritePlan.html). Commits must sit on the same first-parent chain with no merge commits in the segment; conflicts and no-op moves surface as [`HistoryError`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html) variants.

For rebasing a branch tip onto a new base with fork-point detection and bounded cherry patch-id lookup, see [Rebase planning](https://grit-scm.com/docs/library/history/rebase.md/index.md) ([`History::plan_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.plan_rebase) / [`RebaseRequest`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RebaseRequest.html)).

To assign staged hunks automatically, [`History::absorb`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.absorb) blame-maps each hunk to a candidate commit between [`AbsorbOptions::base`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.AbsorbOptions.html#structfield.base) and `HEAD`, verifies commutation with later commits, builds one combined [`RewritePlan`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewritePlan.html), and returns [`AbsorbPlan`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.AbsorbPlan.html) with [`HunkAssignment`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.HunkAssignment.html) and [`UnassignedHunk`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.UnassignedHunk.html) detail. When `--base` is omitted, [`AbsorbPlan::excluded_refs`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.AbsorbPlan.html#structfield.excluded_refs) lists other local branch tips that bound the stack (another ref at the checked-out tip is not treated as a boundary). [`UnassignedReason::HiddenByRef`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.UnassignedReason.html#variant.HiddenByRef) with [`UnassignedHunk::detail`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.UnassignedHunk.html#structfield.detail) explains when a hunk’s introducing commit sits outside the stack because of one of those tips. Call [`History::apply_absorb`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.apply_absorb) so only assigned hunks are removed from the index.

## Apply options and result

[`ApplyOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.ApplyOptions.html) supplies the reflog identity and message written for every ref update in the batch.

[`AppliedRewrite`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.AppliedRewrite.html) returns the ref updates that were committed and the commit OID `HEAD` resolves to afterward.

## Undo

When [`ApplyOptions::record_operation`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.ApplyOptions.html#structfield.record_operation) is set, the apply records its ref plan in `.git/grit/history-last`, and [`History::undo_last`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.undo_last) inverts it while every recorded ref is still at its post-rewrite tip ([`UndoMode::DryRun`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.UndoMode.html#variant.DryRun) checks and reports without changing anything). Undo writes the inverse as the new record, so calling it again redoes the rewrite.

[`History::apply_fixup`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.apply_fixup), [`History::apply_fixup_hunks`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.apply_fixup_hunks), and [`History::apply_absorb`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.apply_absorb) consume edits from the index (or selected unstaged hunks); [`History::staged_paths`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.staged_paths) lists the staged paths a fixup or absorb consumes. A recorded apply also saves, in `.git/grit/history-last-work`, each consumed path's index entry and work tree file from before the command, plus a fingerprint of the same paths after it. Undo checks that those paths still match the fingerprint (otherwise [`LocalChangesWouldBeOverwritten`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.LocalChangesWouldBeOverwritten)), runs the inverse checkout, then puts the saved entries and files back. A restored entry takes the stat data of the file just written when that file cleans (through `core.autocrlf`, `eol`, `ident` and clean filters) to the restored blob, so neither Git nor grit sees a phantom unstaged change; when the file holds a real unstaged edit, the entry's stat cache stays unset so both rehash it. [`UndoOutcome::restored_paths`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.UndoOutcome.html#structfield.restored_paths) lists them. A record written without saved state still moves refs, and [`UndoOutcome::unrestored_edits`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.UndoOutcome.html#structfield.unrestored_edits) names the commit that holds the consumed edits.

## Inspecting a plan

[`RewritePlan::ref_updates`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewritePlan.html#structfield.ref_updates) lists each ref movement as a [`PlannedRefUpdate`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.PlannedRefUpdate.html) (`name`, `old`, `new`), so callers can preview ref motion without applying.

[`RewritePlan::replacement`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewritePlan.html#method.replacement) maps one original commit to its rewritten OID (`None` when dropped), and [`RewritePlan::head_change`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewritePlan.html#method.head_change) reports `HEAD`'s commit before and after the rewrite, or `None` when `HEAD` does not move. `grit history` builds its `--json` `head` field from it.

## Change ids

History planning preserves [`change-id`](https://docs.rs/grit-lib/latest/grit_lib/change_id/fn.change_id.html) and legacy `gitbutler-change-id` headers on rewritten commits (signatures are stripped). When [`ChangeIdPolicy`](https://docs.rs/grit-lib/latest/grit_lib/change_id/struct.ChangeIdPolicy.html) is enabled and the source commit has no stored id, the planner writes the Jujutsu-derived id for the original commit oid into the replacement object. Commits inserted during a rewrite (for example the parent created by [`History::split`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.split)) receive a new random id via [`ChangeIdPolicy::id_for_new_commit`](https://docs.rs/grit-lib/latest/grit_lib/change_id/struct.ChangeIdPolicy.html#method.id_for_new_commit). With `grit.changeIds=false`, existing headers are still copied but no derived or random ids are added. See [Change ids](https://grit-scm.com/docs/library/history/change-ids.md/index.md) for header format and config.

## Errors

[`HistoryError`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html) covers planning failures (conflicts, out-of-scope commits, branch checked out elsewhere) and apply failures. There is no string catch-all variant: history operations return the umbrella [`Error`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html), with history-specific failures under [`Error::History`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.History) and repository, object, ref or revision failures under their own area variants, and structured fields carry paths, commit ids, and ref names where scripts need them.

- [`LocalChangesWouldBeOverwritten`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.LocalChangesWouldBeOverwritten) — staged, unstaged, or untracked paths would be clobbered by the planned tree checkout.
- [`RefCasMismatch`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.RefCasMismatch) — a ref tip changed after planning; nothing is written.
- [`HeadMovedSincePlan`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.HeadMovedSincePlan) — `HEAD` no longer points at the ref or commit recorded when the plan was built; nothing is written.
- [`RefApply`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.RefApply) / [`WorktreeApply`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.WorktreeApply) — ref batch or post-ref checkout failed (apply rolls back ref updates when checkout fails).
- [`RewriteApplyIncomplete`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.RewriteApplyIncomplete) — refs moved but the worktree checkout did not finish; run recovery or `grit rebase --abort` before committing.
- [`ApplyRollbackIncomplete`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.ApplyRollbackIncomplete) — checkout failed after refs moved and ref rollback or worktree restore also failed.
- [`EmptyMessage`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.EmptyMessage) — reword message cleanup left an empty body.
- [`Signing`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.Signing) — `commit.gpgsign` was enabled but signing a replacement commit failed; refs are not updated.

## Example

Reword one commit on the current branch, plan, and apply:

```rust
//! Plan and apply a single-commit message rewrite (library history API demo).
//!
//! Source for the library guide "History rewrite" page.

use anyhow::Result;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::objects::ObjectId;
use grit_lib::progress::CancelToken;
use grit_lib::repo::Repository;
use grit_lib::revwalk::history::{ApplyOptions, RefScope, RewordOptions, RewriteOptions};
use grit_lib::revwalk::{Peel, ResolveOptions};

use std::path::{Path, PathBuf};

fn open_repo(root: &Path) -> Result<Repository> {
    Ok(Repository::discover(
        Some(root),
        &RepositoryOptions::from_process(),
    )?)
}

fn main() -> Result<()> {
    let mut args = std::env::args().skip(1);
    let root: PathBuf = args
        .next()
        .map(PathBuf::from)
        .or_else(|| std::env::current_dir().ok())
        .ok_or_else(|| anyhow::anyhow!("missing repository path"))?;
    let spec = args
        .next()
        .ok_or_else(|| anyhow::anyhow!("missing commit spec"))?;
    let message = args
        .next()
        .ok_or_else(|| anyhow::anyhow!("missing new message"))?;

    let repo = open_repo(&root)?;
    let commit: ObjectId = repo
        .revwalk()
        .resolve(&spec, &ResolveOptions::default().with_peel(Peel::Commit))?;

    let history = repo.history();
    let plan = history.reword(
        commit,
        &RewordOptions::default().with_message(message),
        &RewriteOptions::new("History Guide <guide@grit.test> 1 +0000".parse()?)
            .with_scope(RefScope::Head),
    )?;

    for update in &plan.ref_updates {
        println!(
            "dry-run: {} {} -> {}",
            update.name,
            update.old.to_short_hex(),
            update.new.to_short_hex(),
        );
    }

    let applied = history.apply(
        &plan,
        &ApplyOptions::new(
            grit_lib::ident::parse_signature("History Guide <guide@grit.test> 1 +0000")
                .unwrap_or_else(|| panic!("guide identity must parse as a signature")),
            "history reword",
        ),
        &mut grit_lib::progress::NullProgress,
        &CancelToken::never(),
    )?;

    println!("head={}", applied.head.to_hex());
    Ok(())
}
```

```bash
cargo run --bin history_reword /path/to/repo <commit-ish> "New message"
```

# https://grit-scm.com/docs/library/maintenance/index.md

# Maintenance

> Object fsck validation and repository hooks.

Repository maintenance runs through one handle, [`repo.maintenance()`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.maintenance), which returns a [`Maintenance`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html). Its options and result types live in [`maintenance`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/index.html). Long-running operations (`gc`, `gc_auto`, `repack`, `repack_all`, `fsck`) take a [`ProgressSink`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html) and a [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html) as their last two parameters; pass `&mut NullProgress` and `&CancelToken::never()` when neither matters.

```rust
use grit_lib::maintenance::GcOptions;
use grit_lib::progress::{CancelToken, NullProgress};

let stats = repo.maintenance().gc(
    &GcOptions::full_run(false, now_unix),
    &mut NullProgress,
    &CancelToken::never(),
)?;
println!("packed {:?} objects", stats.repack.objects_packed);
```

- [`Maintenance::write_commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.write_commit_graph) — atomic monolithic `objects/info/commit-graph` with optional changed-path Bloom filters ([`CommitGraphOptions`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.CommitGraphOptions.html), [`CommitGraphWriteReport`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.CommitGraphWriteReport.html)). Shallow clones, `info/grafts` and enabled replace refs change commit parents, so no graph is written there and any existing one is deleted (Git ignores graphs in that state but `git fsck` still rejects them); [`CommitGraphWriteReport::skipped`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.CommitGraphWriteReport.html#structfield.skipped) holds the [`CommitGraphSkipReason`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.CommitGraphSkipReason.html). Writing needs the files backend; a repository with a custom primary store gets `RepositoryError::UnsupportedObjectStore` with `FilesOnlyOperation::CommitGraphWrite`.
- [`Maintenance::build_commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.build_commit_graph) — the same graph built in memory through any object store, custom primaries included, returned as a [`CommitGraphBuild`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.CommitGraphBuild.html). The [`BuiltCommitGraph`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.BuiltCommitGraph.html) bytes match what `write_commit_graph` installs; a custom store keeps them itself and attaches them with `OdbBuilder::commit_graph` (see [Object stores](https://grit-scm.com/docs/library/maintenance/object-stores.md/index.md#commit-graphs-for-a-custom-store)).
- [`Maintenance::write_midx`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.write_midx) — write `multi-pack-index` ([`MidxOptions`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.MidxOptions.html), [`MidxWriteReport`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.MidxWriteReport.html)). The file is format version 1 by default, readable by every Git with multi-pack-index support; `MidxOptions::version`, then `midx.version` in config, select version 2. Other values fail with [`MidxError::UnknownWriteVersion`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.MidxError.html) before anything is written, including in dry-run mode. Incremental repack follows the same `midx.version` setting when it writes a multi-pack-index bitmap.
- [`Maintenance::pack_refs`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.pack_refs) — pack loose refs into `packed-refs` or compact reftable stacks ([`PackRefsOptions`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.PackRefsOptions.html)).
- [`Maintenance::repack_all`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.repack_all) and [`Maintenance::gc`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.gc) orchestrate repack and prune; [`Maintenance::prune_loose_objects`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.prune_loose_objects) deletes unreachable loose objects older than `gc.pruneExpire`; [`Maintenance::fsck`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.fsck) validates the result. Indexing the new pack reports [`ProgressPhase::IndexingObjects`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html) and `ResolvingDeltas`, and `cancel` is checked between phases and before a new pack is published.
- [`Maintenance::gc_auto`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.gc_auto) is `git gc --auto`: [`Maintenance::auto_gc_needed`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.auto_gc_needed) applies `gc.auto` (loose objects estimated from `objects/17`, two directory reads in total) and `gc.autoPackLimit` and returns an [`AutoGcReason`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.AutoGcReason.html). Too many loose objects packs the reachable ones into one new, self-contained pack without touching existing packs (unreachable ones stay loose for `gc.pruneExpire`), delta-compressed with `pack.window` / `pack.depth` like a full repack; too many packs runs a full consolidating gc. The result is an [`AutoGcOutcome`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.AutoGcOutcome.html) (not needed, already running, declined by the `pre-auto-gc` hook, or ran with [`GcStats`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.GcStats.html)). Call it after writing objects; the library never forks, so an application that honors `gc.autoDetach` ([`ConfigSet::gc_auto_detach`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html#method.gc_auto_detach)) runs it on its own thread or process.
- `gc` and `gc_auto` hold Git's `gc.pid` lock ([`GcLock`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.GcLock.html)) while they run, so maintenance never overlaps another grit or Git gc. A held lock is [`Error::MaintenanceRunning`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html) from `gc` and [`AutoGcOutcome::AlreadyRunning`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.AutoGcOutcome.html) from `gc_auto`. [`Maintenance::try_lock`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.try_lock) takes the same lock for an operation of your own, and [`Maintenance::lock_holder`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.lock_holder) reports a live holder without taking it. During `gc`, `gc.writeCommitGraph` and `core.commitGraph` gate commit-graph generation (existing graphs are kept when skipped), `gc.packRefs` gates pack-refs (`notbare` packs only when the repository has a work tree), and the last of `repack.writeBitmaps` / `pack.writeBitmaps` in config load order selects whether repack writes a bitmap (unset defaults to true on bare repos). Explicit `write_commit_graph` and `pack_refs` ignore the gc-only keys.
- [`Maintenance::prune_loose_objects`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.prune_loose_objects) and [`Maintenance::gc`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.gc) also run on a custom primary that can delete objects ([`PrunableObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.PrunableObjectStore.html)); see [Garbage collection on a custom store](https://grit-scm.com/docs/library/maintenance/object-stores.md/index.md#garbage-collection-on-a-custom-store). With `extensions.preciousObjects` set, `prune_loose_objects` fails with `RepositoryError::PreciousObjectsRepository` on any backend, and `gc` on a custom store skips its prune step.

Maintenance APIs split into **repository fsck**, **object validation**, and **hook execution**:

- [`maintenance::repository_fsck`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/index.html) — repository-wide integrity checks (loose/pack objects, connectivity from [`Maintenance::reachability_roots`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.reachability_roots) — every ref tip, reflog entry, stash, linked-worktree `HEAD`, and index including each non-bare worktree's index plus `GIT_INDEX_FILE` when set), dangling objects, refs, MIDX, commit-graph). `reachability_roots` returns that root set for embedders calling [`prune_loose_unreachable`](https://docs.rs/grit-lib/latest/grit_lib/refs/gc/fn.prune_loose_unreachable.html); ref tips alone are not enough for prune. Progress via [`ProgressSink`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html); severity follows Git defaults and `fsck.<msg-id>` config ([`issue_severity`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/fn.issue_severity.html)). Each [`FsckIssue`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/enum.FsckIssue.html) reports the object it concerns ([`FsckIssue::oid`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/enum.FsckIssue.html#method.oid)), the file or ref it was found in ([`FsckIssue::location`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/enum.FsckIssue.html#method.location)), and a one-line description ([`FsckIssue::detail`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/enum.FsckIssue.html#method.detail)), so callers can render findings without matching every variant.
  Packs are memory-mapped and verified in one depth-first pass over their delta trees on worker threads: each object is inflated once, hashed against its index entry and checked, then its bytes are dropped. Peak memory therefore follows the delta chains being walked plus a few dozen bytes per object (commit and tag links, object kinds), not the uncompressed size of the pack. A delta whose base is corrupt, missing or fails its hash check is reported as `corruptObject` along with every delta built on it. The connectivity walk re-reads trees from the object store, as Git does, instead of caching every tree entry.
- [`maintenance::fsck`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/index.html) — validate loose object bytes before hashing ([`fsck_object`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/fn.fsck_object.html), [`FsckError`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/struct.FsckError.html) with Git-compatible message ids). Connectivity walks for receive-pack and bundles live in [`maintenance::repository_fsck`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/index.html).
- [`Maintenance::repack`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.repack) — all-into-one repack using [`Maintenance::reachability_roots`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.reachability_roots), optional `.rev`/`.bitmap` sidecars, pack pruning, and unreachable loose-object pruning via [`RepackOptions`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.RepackOptions.html) / [`RepackReport`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.RepackReport.html). [`Repository::repack`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) is a thin alias. Objects already in a pack keep their stored form (whole objects byte for byte, deltas with their base reference rewritten, chains capped at `pack.depth`); only loose objects and deltas whose base is dropped go through a streaming `pack.window` delta search, and the pack streams to disk. Set [`RepackOptions::force_recompress`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.RepackOptions.html) to recompute every delta, like `git repack -f`. Incremental repack (`RepackOptions::incremental`) keeps existing packs; when combined with `write_bitmap` and multiple packs, grit writes a multi-pack-index reachability bitmap instead of a single-pack sidecar.
- [`hooks`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/index.html) — resolve and run hook scripts through the repository [`CommandRunner`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/trait.CommandRunner.html) ([`RepositoryHooks::run`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryHooks.html#method.run), [`HookResult`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.HookResult.html)). A hook that runs and exits non-zero is `Ok(HookResult::Failed { status, output })` with its real exit status; a hook that cannot be started at all is [`HookError::Spawn`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.HookError.html) carrying the program, the `io::Error`, and whatever earlier hooks for the event (configured `hook.<name>.*` entries run first) already wrote. The library never prints hook output. By default ([`HookStdio::Capture`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.HookStdio.html)) both streams are piped and returned as a [`HookOutput`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/struct.HookOutput.html) in the result, and in [`HookError::Failed`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.HookError.html) when [`HookResult::check`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.HookResult.html#method.check) or [`commit_worktree`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitRequest.html) turns a failing `pre-commit` or `commit-msg` into an error, so a TUI or GUI can show it in its own pane. The `Display` of the error stays one line. A terminal front end that wants Git's live output opens the repository with [`RepositoryOptions::with_hook_stdio`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_hook_stdio)`(HookStdio::Inherit)`: the hook then writes straight to the process's stderr (its stdout too, except for `pre-push`) and the returned output is empty. Output an injected `CommandRunner` returns is only ever handed back, never re-emitted. Server-side hooks run by receive-pack are always captured and relayed to the client on the sideband. Scripts the OS refuses to execute run through `sh` (`/bin/sh` on Unix; on Windows the `#!` interpreter, resolved in the Git for Windows tree and then on the hook's `PATH`). A `post-commit` hook that cannot start never fails the commit; it is reported as [`Warning::HookNotRun`](https://docs.rs/grit-lib/latest/grit_lib/diagnostics/enum.Warning.html). The same holds for the hooks porcelain runs after an operation completes: [`switch_repository`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/switch/struct.SwitchOutcome.html) runs `post-checkout`, [`Merge::integrate_into_branch`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.integrate_into_branch) runs `post-merge`, an amending [`create_commit`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitRequest.html) runs `post-rewrite amend`, and [`History::apply`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.apply) runs `post-checkout` and `post-rewrite rebase` (pairs from [`RewritePlan::rewritten_pairs`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewritePlan.html#method.rewritten_pairs)). Each takes a [`PostOperationHooks`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.PostOperationHooks.html) option (`Skip` to opt out) and reports what ran as [`HookName`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.HookName.html) values; [`RepositoryHooks::run_post_checkout`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryHooks.html#method.run_post_checkout), [`RepositoryHooks::run_post_merge`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryHooks.html#method.run_post_merge) and [`RepositoryHooks::run_post_rewrite`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryHooks.html#method.run_post_rewrite) run one hook with Git's arguments. The hooks that run before an operation records anything can refuse it, with [`Error::Hook`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html) wrapping [`HookError::Failed`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.HookError.html): [`create_commit`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitRequest.html) runs `pre-commit`, `prepare-commit-msg <COMMIT_EDITMSG> <source>` and `commit-msg`; [`integrate_branch_with`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.integrate_into_branch) runs `pre-merge-commit`, then `prepare-commit-msg <MERGE_MSG> merge` and `commit-msg` with `MERGE_HEAD` recorded, and leaves the merge in progress when one refuses; [`History::start_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.start_rebase) runs `pre-rebase` as [`RebaseOntoOptions::pre_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RebaseOntoOptions.html#structfield.pre_rebase) says, once the branch is known not to be up to date and before any commit is replayed, so a refusal comes before a replay conflict and writes nothing ([`History::plan_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.plan_rebase) does the same for callers that plan and apply a rebase themselves, [`RepositoryHooks::run_pre_rebase`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryHooks.html#method.run_pre_rebase) runs the bare hook). [`HookPolicy::SkipVerify`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/enum.HookPolicy.html) ([`CommitRequest::hooks`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitRequest.html#structfield.hooks), [`MergeOptions::verify`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergeOptions.html#structfield.verify)) is `--no-verify`: it skips `pre-commit`, `pre-merge-commit` and `commit-msg`, never `prepare-commit-msg`. Hooks inherit every variable of the repository [`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html) snapshot. [`Repository::hooks`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) lists scripts via [`RepositoryHooks::list`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryHooks.html) ([`HookInfo`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.HookInfo.html), [`HookSource`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/enum.HookSource.html)). Tests often install [`RecordingRunner`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.RecordingRunner.html) via [`RepositoryOptions`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html).
- [`patch_ids`](https://docs.rs/grit-lib/latest/grit_lib/diff/patch_ids/index.html) — [`Repository::patch_id`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) and [`compute_patch_id`](https://docs.rs/grit-lib/latest/grit_lib/diff/patch_ids/fn.compute_patch_id.html) for stable/unstable commit equivalence (merge commits return `None`). Text diffs use unified hunks with three context lines on each side, matching `git show --format= --no-ext-diff -U3 <REV> | git patch-id --stable` in stable mode. Nearby unchanged context is hashed; distant unchanged lines are excluded. [`compute_patch_id_for_paths`](https://docs.rs/grit-lib/latest/grit_lib/diff/patch_ids/fn.compute_patch_id_for_paths.html) applies the same rules to selected paths, while [`compute_patch_ids_from_text`](https://docs.rs/grit-lib/latest/grit_lib/diff/patch_ids/fn.compute_patch_ids_from_text.html) hashes the hunks supplied by its caller, including their chosen context.
  [`Repository::patch_ids_for_revs`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) takes revision specs and expands ranges: `A..B` yields one `(patch_id, commit)` pair per commit in `rev-list` order, and `A...B` yields both sides as one unlabelled sequence. To compare the two sides of `A...B` (for example a branch before and after a force-push), set [`RevWalkListOptions::cherry_mark`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkListOptions.html) and read [`RevListResult::cherry_matches`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListResult.html): each [`CherryMatch`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.CherryMatch.html) lists the left and right commits sharing one patch-id, and for a one-to-one pair says whether the commit message changed.

[`Maintenance::offload_blobs`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.offload_blobs) moves large blobs from a repository to a large-object promisor (LOP), the way `git repack -a -d --filter=blob:limit=<n> --filter-to=<lop>` does in Git's own LOP tests. [`OffloadOptions`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.OffloadOptions.html) names the promisor remote and the filter: `blob:limit=<n>` selects blobs of at least `n` bytes, and the default is the remote's `partialCloneFilter`. The current time is passed in for the `gc.pid` lock. Nothing leaves the main repository before the LOP has it. Candidate blobs are copied into one new LOP pack, whole, and its `.keep` marker ([`IngestPackOptions::keep_message`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/struct.IngestPackOptions.html#structfield.keep_message)) is written before the pack appears, so a gc on the LOP cannot prune the unreferenced blobs. Only a copy the LOP itself holds in a `.keep` pack counts as already there: a loose or unkept copy may be pruned by the LOP's `gc`, and one reached through the LOP's alternates is not the LOP's, so those candidates are copied too. Every candidate is then checked to be in a `.keep` pack of the LOP, and the new pack is flushed to disk. Next `remote.<name>.promisor` is set (and `partialCloneFilter`, when the filter was given), along with `repack.writeBitmaps = false`, without which `git gc` fails on the repository once something is pushed, and the LOP's git directory is added to `grit.lopGitDir` ([`LOP_GIT_DIR_KEY`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/constant.LOP_GIT_DIR_KEY.html)). Finally the main repository's packs and loose objects are rewritten into one `.promisor` pack without the candidates, and that pack is flushed to disk before the old packs go. The blobs that stay go into it too, although only the main repository has them: Git treats every blob a promisor-pack tree names as promised, and its `repack -a -d` and `gc` keep a promised object only when it is in a promisor pack, so a kept blob in an ordinary pack would be deleted. A repository whose kept blobs are in an ordinary pack is folded back on the next run. That rewrite keeps unreachable objects and leaves `.keep` packs alone. It deletes only the packs it listed when it started, so a concurrent push survives. Blobs a worktree's index or `HEAD` needs, and blobs in `.keep` packs, stay. The [`OffloadReport`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.OffloadReport.html) counts what moved, describes each pack it wrote ([`OffloadPack`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.OffloadPack.html): its [role](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.OffloadPackRole.html), path, object count and size), and lists the config it set ([`OffloadConfigChange`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.OffloadConfigChange.html)). It also says whether the LOP can answer lazy fetches ([`LopReadiness`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.LopReadiness.html)) and whether `promisor.advertise` tells clients about it. Refusals are typed [`OffloadError`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.OffloadError.html)s inside `Error::Offload`. Running it again offloads blobs pushed since and folds objects pushed since into the promisor pack, even when no blob moves; it has nothing to do otherwise. Like every maintenance step except `pack_refs`, it takes a trailing [`ProgressSink`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html) and [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html); cancellation is honoured until the blobs are safely in the LOP, and once the main repository starts dropping its copies the run completes.

```rust
use grit_lib::maintenance::OffloadOptions;
use grit_lib::progress::{CancelToken, NullProgress};
use grit_lib::remote::partial_clone::ObjectFilterSpec;

let mut opts = OffloadOptions::new("lop", now_unix);
opts.filter = Some(ObjectFilterSpec::BlobLimit(1024 * 1024));
opts.configure_lop = true; // uploadpack.allowFilter + allowAnySHA1InWant in the LOP
let report = repo
    .maintenance()
    .offload_blobs(&opts, &mut NullProgress, &CancelToken::never())?;
println!("moved {} blobs, main {} -> {} bytes",
    report.dropped_from_main, report.main_bytes_before, report.main_bytes_after);
```

### Dropping promised large blobs

A partial clone keeps every large blob it ever fetched. [`Maintenance::drop_promised_blobs`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.drop_promised_blobs) removes the ones the promisor remote can supply again and nothing has needed recently, so they come back through the ordinary lazy fetch the next time something reads them. [`DropPromisedBlobsOptions`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.DropPromisedBlobsOptions.html) carries the size threshold (`blob:limit` semantics: at least `min_size` bytes), the recency cutoff and the current time, all passed in; [`DropPromisedBlobsOptions::from_config`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.DropPromisedBlobsOptions.html#method.from_config) reads `maintenance.drop-large-blobs.minSize` and `.expire`, and lets a caller's own size or [`DropExpiry`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.DropExpiry.html) (parsed from `never`, `now` or a date) take the place of either key, which is then not read. An `expire` that is not a date is [`ConfigError::InvalidDate`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ConfigError.html). [`drop_large_blobs_enabled`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fn.drop_large_blobs_enabled.html) says whether `gc` runs it as a phase ([`GcOptions::drop_large_blobs`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.GcOptions.html), [`GcStats::drop_large_blobs`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.GcStats.html)); `gc` checks that config before its first phase, and skips the phase ([`DropPromisedBlobsSkip::NoCurrentTime`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.DropPromisedBlobsSkip.html)) when `GcOptions::now_unix` is 0 rather than read a clock.

Only blobs stored in `.promisor` packs are candidates, and one is dropped only when it is stored nowhere else locally, no pack holding it has a `.keep` marker, some tree or tag in a promisor pack names it (so Git still treats it as promised once it is gone), no worktree's index (nor a `GIT_INDEX_FILE` one) or `HEAD` tree uses it, no commit a worktree's `HEAD` reflog named since the cutoff uses it, no promisor pack holding it was written since the cutoff, and a promisor can supply it again. A blob in a promisor pack of a partial clone was fetched from the promisor, but offload's promisor pack also holds blobs only the main repository has, so promisors this machine can read (remotes with a local URL, and the LOP directories in `grit.lopGitDir`) are checked: a blob one of them stores in its own object directory can go. One none of them stores stays when every promisor remote was checked ([`KeptBlobCounts::not_in_promisor`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.KeptBlobCounts.html#structfield.not_in_promisor)) or offload has run here, since a network promisor cannot be asked without fetching ([`KeptBlobCounts::unverified`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.KeptBlobCounts.html#structfield.unverified)). A partial clone of network remotes only, with no `grit.lopGitDir`, trusts its promisor packs as Git does and reads nothing more. The [`DropPromisedBlobsReport`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.DropPromisedBlobsReport.html) lists the dropped blobs ([`DroppedBlob`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.DroppedBlob.html)) and counts the rest by reason ([`KeptBlobCounts`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.KeptBlobCounts.html)). Deciding reads pack headers, the trees of the protected commits and, until every remaining candidate is found, the trees in promisor packs; it never fetches. Packs holding only dropped blobs are deleted and other affected packs rewritten, keeping their `.promisor` contents and modification time. Refusals are typed: [`ObjectError::NoPromisorRemote`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.NoPromisorRemote), [`MergeError::OperationInProgress`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html#variant.OperationInProgress), [`RepositoryError::PreciousObjectsRepository`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html#variant.PreciousObjectsRepository) and [`RepositoryError::MaintenanceRunning`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html#variant.MaintenanceRunning); inside `gc` the first three become [`DropPromisedBlobsSkip`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.DropPromisedBlobsSkip.html) values instead.

```rust
use grit_lib::maintenance::DropPromisedBlobsOptions;
use grit_lib::progress::{CancelToken, NullProgress};

let two_weeks_ago = now - time::Duration::weeks(2);
let opts = DropPromisedBlobsOptions::new(now, 1024 * 1024, Some(two_weeks_ago));
let report = repo
    .maintenance()
    .drop_promised_blobs(&opts, &mut NullProgress, &CancelToken::never())?;
println!("dropped {} blobs, freed {} bytes ({} kept for a checkout)",
    report.dropped.len(), report.bytes_reclaimed, report.kept.checked_out);
```

Like Git's, fsck never fetches: a promised object that is missing stays missing, even with a promisor fetcher installed.

Partial-clone maintenance works offline. Repack keeps existing `.promisor` packs and their sidecars intact, and writes local objects into a separate unmarked pack. GC, reflog expiry, pruning, incremental repack, and dry runs honor promises without hydrating missing history. Missing non-promised objects still fail validation. Bitmaps are omitted when the local pack cannot contain the complete closure; `RepackStats::pack_path` and `pack_bytes` refer to the newly written local pack even when other packs remain.

The `grit` CLI maps fsck and hook failures to its own exit codes and messages; the library returns typed results only.

## Fsck diagnostic summaries

Call [`FsckReport::summary`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/struct.FsckReport.html#method.summary)
with the configuration, fsck options, and an `include_info` boolean to classify a
report for display. The returned
[`FsckSummary`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/struct.FsckSummary.html) keeps
all findings in discovery order as borrowed
[`FsckDiagnostic`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/repository_fsck/struct.FsckDiagnostic.html)
values, each with its resolved severity and listing visibility. No objects are
read or changed by classification.

`summary.ok` is false if any finding has error severity. `summary.has_warnings`
records warnings independently of errors; visible informational findings do not
count as warnings. `include_info` changes visibility only. By default, most
informational findings are hidden, while `missingTaggerEntry` remains visible.
The CLI uses this policy for human listings and summary messages; JSON and
Markdown retain every finding, including hidden informational findings.

## Benchmarking

The October 2026 diagnostic-summary extraction was checked against main
`7cc7979535ce` and system Git 2.55.0 on a Linux factory VM with four AMD EPYC 7763
vCPUs, using Rust 1.99.0 and the `dist` profile. Builds and tests were idle during
measurement. Times below are median milliseconds.

| Repository and operation | Git | Grit before | Grit after |
| --- | ---: | ---: | ---: |
| 20,000 files, 50,000 commits: `fsck --no-dangling` | 267.38 | 221.36 | 221.76 |
| 1,001 warning trees and an informational tag finding: `fsck --no-dangling` | 23.75 | 15.72 | 15.37 |

The large-repository row uses 30 interleaved rounds with randomized tool order,
after three warmups per tool. Maximum process RSS was 60,960 KiB before and
60,724 KiB after, versus 28,444 KiB for Git. The diagnostic-heavy row uses
hyperfine with five warmups and at least 30 runs per tool; it exercises severity
and visibility classification rather than an empty report.

The standard `grit-bench fsck --warmup 3 --min-runs 10` scenario also ran on both
builds: 207.99 to 214.31 ms for grit, with Git at 265.00 and 261.92 ms respectively.
The subsequent interleaved comparison put grit's medians within 0.2%, with the
paired sample variability including no change. Summary classification performs
no additional object reads and resolves severity once per finding.

## Example

```rust
//! Validate objects with fsck rules and run a repository hook.
//!
//! Source for the library guide "Maintenance" page (included in the docs site).

use anyhow::Result;
use grit_lib::command_runner::hooks::HookResult;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::maintenance::fsck::{fsck_object, FsckObjectOptions};
use grit_lib::objects::{HashAlgo, ObjectKind};
use grit_lib::repo::Repository;

use std::fs;
use std::path::{Path, PathBuf};

fn open_repo(root: &Path) -> Result<Repository> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::from_process();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Ok(Repository::open(&git_dir, &opts)?)
}

fn main() -> Result<()> {
    let root = std::env::args()
        .nth(1)
        .map(PathBuf::from)
        .or_else(|| std::env::current_dir().ok())
        .ok_or_else(|| anyhow::anyhow!("missing repository path"))?;
    let repo = open_repo(&root)?;

    let head = repo.references().head()?;
    let commit = head
        .oid()
        .cloned()
        .ok_or_else(|| anyhow::anyhow!("HEAD has no commit"))?;

    let obj = repo.objects().read(&commit)?;
    fsck_object(
        ObjectKind::Commit,
        &obj.data,
        FsckObjectOptions::new(HashAlgo::Sha1),
    )
    .map_err(|e| anyhow::anyhow!("fsck_object failed: {e:?}"))?;
    println!("fsck_object_ok=1");

    let hook_path = repo.git_dir().join("hooks").join("pre-commit");
    if let Some(parent) = hook_path.parent() {
        fs::create_dir_all(parent)?;
    }
    fs::write(&hook_path, b"#!/bin/sh\nexit 0\n")?;
    #[cfg(unix)]
    {
        use std::os::unix::fs::PermissionsExt;
        fs::set_permissions(&hook_path, fs::Permissions::from_mode(0o755))?;
    }

    let hook_result = repo.hooks().run("pre-commit", &[], None)?;
    let ran = matches!(hook_result, HookResult::Success { .. });
    println!("pre_commit_ran={ran}");

    Ok(())
}
```

This example fsck-validates `HEAD`’s commit object, installs a `pre-commit` hook that exits 0, and runs it through [`RepositoryHooks::run`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryHooks.html#method.run) (propagating a spawn failure with `?`). The test expects `git fsck --strict` to stay clean afterward.

# https://grit-scm.com/docs/library/merge/index.md

# Merge

> Three-way tree merge and merge-base helpers in the diff and revwalk domains.

Merge **orchestration** (sequencer state, hooks, editors, messages) stays in `grit-cli`. The library exposes tree and index transforms embedders and porcelain reuse:

- [`RevWalk::merge_bases`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.merge_bases) and [`RevWalk::is_ancestor`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.is_ancestor) — common ancestors and ancestor checks.
- [`merge::merge_trees`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/index.html) — rename-aware three-way tree merge ([`merge_trees_three_way`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/fn.merge_trees_three_way.html)), conflict-marker blobs, and [`TreeMergeOutput`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/struct.TreeMergeOutput.html).
- [`porcelain::merge`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/index.html) — fast-forward/octopus index composition, [`predict_merge`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/enum.MergePrediction.html) (in-memory conflict check via the ODB overlay), [`write_merge_tree`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.WrittenMergeTree.html) (stored merge tree), and checkout helpers the CLI calls.

When two commits have several merge bases (criss-cross history), [`predict_merge`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/enum.MergePrediction.html), [`write_merge_tree`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.WrittenMergeTree.html) and [`integrate_branch`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.integrate_into_branch) merge the bases into one virtual base and merge against that, as Git's recursive and ort strategies do. The bases are taken oldest first, in the order [`RevWalk::merge_bases`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.merge_bases) with `MergeBaseMode::All` reports them (equal commit dates keep Git's order). Content conflicts between the bases stay in the virtual base as nested conflict markers. Binary, modify/delete and symlink conflicts keep the older version, and the caller's `MergeFavor` applies only to the final merge. A single merge base is a plain three-way merge. `merge_trees_three_way` itself always takes one explicit base tree.

Pass explicit [`MergeFavor`](https://docs.rs/grit-lib/latest/grit_lib/diff/merge_file/enum.MergeFavor.html) and [`WhitespaceMergeOptions`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/struct.WhitespaceMergeOptions.html) into tree merges; pass identity and timestamps into commit-writing porcelain.

## Predicting versus writing a merge

Both functions take two commits and [`MergePredictionOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergePredictionOptions.html), never touch refs, the index or the working tree, and work in bare repositories.

| Function | Objects written | Returns |
| --- | --- | --- |
| [`predict_merge`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/enum.MergePrediction.html) | None | Up to date, fast-forward, clean (with the tree id), conflicts, or unrelated |
| [`write_merge_tree`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.WrittenMergeTree.html) | Every new tree and blob of the merge | [`WrittenMergeTree`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.WrittenMergeTree.html): stored tree, conflicts, unmerged stages |

The tree id in [`MergePrediction::Clean`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/enum.MergePrediction.html) is the id `git merge-tree --write-tree` prints, but the tree is **not stored**: committing, diffing or reading it fails with `ObjectNotFound`. Use `predict_merge` to answer "would this merge cleanly?" cheaply (merge queues, `grit merge --check`). Use `write_merge_tree` when you need the result itself: it is the library form of `git merge-tree --write-tree`. A clean result can be committed straight away with `NewCommit::new(tree, ..).with_parents(vec![ours, theirs])`. On conflicts the stored tree holds conflict markers in the conflicted files, and [`WrittenMergeTree::stages`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.WrittenMergeTree.html) lists the `mode`, `oid`, `stage` and `path` rows Git prints after the tree id. Set `ours_label` and `theirs_label` to choose the conflict-marker labels.

`write_merge_tree` always merges (the fast-forward option is ignored), merges several merge bases into a virtual base first (stage 1 entries then come from it, as with `git merge-tree`), and refuses commits with no common ancestor with `Error::UnrelatedHistories` unless `allow_unrelated_histories` is set.

## Directory renames

When one side moves every file out of a directory and the other side adds a file inside it, the new file most likely belongs in the directory's new home. Tree merges detect this the way Git's `ort` merge does, controlled by [`DirectoryRenameMode`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/enum.DirectoryRenameMode.html):

| Mode | `merge.directoryRenames` | Result |
| --- | --- | --- |
| [`Conflict`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/enum.DirectoryRenameMode.html#variant.Conflict) (default) | `conflict` or unset | The file moves to the new directory and stays unmerged at the adding side's stage (stage 3 when theirs added it), so the merge stops for confirmation. |
| [`Apply`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/enum.DirectoryRenameMode.html#variant.Apply) | `true` | The file moves and the merge is clean. |
| [`Off`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/enum.DirectoryRenameMode.html#variant.Off) | `false` | The file stays in the old directory. |

A directory counts as renamed only when the side removed it entirely; the destination is the directory that received the most of its files, and a tie is a split that moves nothing. A destination path the adding side already uses, or that several new files would share, blocks the move; a file the base or the renaming side has at the destination is instead three-way merged with the moved file there. Splits and blocked moves are conflicts in `Conflict` and `Apply` mode even though no index entry is unmerged. All of them are listed in [`TreeMergeOutput::directory_rename_conflicts`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/struct.TreeMergeOutput.html#structfield.directory_rename_conflicts) and reported by [`conflicts_from_tree_merge`](https://docs.rs/grit-lib/latest/grit_lib/operation/fn.conflicts_from_tree_merge.html) as the `directory_rename_*` [`ConflictKind`](https://docs.rs/grit-lib/latest/grit_lib/operation/enum.ConflictKind.html)s.

[`merge_trees_three_way`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/fn.merge_trees_three_way.html) takes the mode as an argument; read the configured one with [`DirectoryRenameMode::from_repo`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/enum.DirectoryRenameMode.html#method.from_repo), which fails with [`ConfigError::InvalidDirectoryRenames`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ConfigError.html#variant.InvalidDirectoryRenames) for an unknown value. [`MergePredictionOptions::directory_renames`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergePredictionOptions.html#structfield.directory_renames) and [`MergeOptions::directory_renames`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergeOptions.html#structfield.directory_renames) override the config for one merge; pick, revert, rebase and history edits always use the config.

## Example

The program resolves `ours` and `theirs` refs, stores the merge with `write_merge_tree`, prints the merged tree oid (compare with `git merge-tree --write-tree`) and, when the merge is clean, commits it with both parents:

```rust
//! Stored three-way merge (`write_merge_tree`) compared with `git merge-tree --write-tree`.
//!
//! Source for the library guide "Merge" page (included in the docs site).

use anyhow::Result;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::ident::Signature;
use grit_lib::merge::MergePredictionOptions;
use grit_lib::objects::{NewCommit, ObjectId};
use grit_lib::repo::Repository;
use grit_lib::revwalk::ResolveOptions;
use std::path::{Path, PathBuf};
use time::OffsetDateTime;

fn open_repo(root: &Path) -> Result<Repository> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::from_process();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Ok(Repository::open(&git_dir, &opts)?)
}

fn main() -> Result<()> {
    let root = std::env::args()
        .nth(1)
        .map(PathBuf::from)
        .or_else(|| std::env::current_dir().ok())
        .ok_or_else(|| anyhow::anyhow!("missing repository path"))?;
    let repo = open_repo(&root)?;

    let ours: ObjectId = repo.revwalk().resolve("ours", &ResolveOptions::default())?;
    let theirs: ObjectId = repo
        .revwalk()
        .resolve("theirs", &ResolveOptions::default())?;

    // Merges over the first merge base and stores the result, like `git merge-tree --write-tree`.
    let merged = repo
        .merge()
        .write_tree(ours, theirs, &MergePredictionOptions::default())?;

    println!("merged_tree={}", merged.tree.to_hex());
    println!("conflicted_paths={}", merged.conflicts.len());
    if merged.is_clean() {
        let committer = Signature::new(
            "Guide",
            "guide@example.com",
            OffsetDateTime::from_unix_timestamp(1_700_000_000)?,
        )?;
        let commit = repo.objects().write_commit(
            &NewCommit::new(
                merged.tree,
                committer.clone(),
                committer,
                "Merge theirs into ours",
            )
            .with_parents(vec![ours, theirs]),
        )?;
        println!("merge_commit={}", commit.to_hex());
    }

    Ok(())
}
```

The integration test builds non-conflicting `ours` / `theirs` branches, asserts the merged tree matches Git’s oracle, and runs `git fsck --strict` on the resulting merge commit.

## Integrating a branch (`integrate_branch`)

[`integrate_branch`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.integrate_into_branch) merges one commit into a local branch and updates the index and work tree (or records merge-in-progress state on conflicts). Pass `into_ref` as either a full ref (for example `refs/heads/main`) or a short branch name (for example `main` or `feature/topic`); short names map to `refs/heads/{name}` and missing branches return [`BranchError::NotFound`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/enum.BranchError.html#variant.NotFound). The `label` argument names the other side in the default merge message (`Merge {label}` unless [`MergeOptions::message`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergeOptions.html#structfield.message) overrides it) and in branch reflog lines (`merge {label}`, or `merge {label}: fast-forward` on fast-forward).

## Typed merge errors ([`MergeError`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html))

Branch integration, [`continue_merge`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.continue_sequence), and replay sequencing return [`Error::Merge`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Merge) wrapping [`MergeError`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html). Stable [`kind_name`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html#method.kind_name) slugs match the CLI `--json` error `kind` field (for example `not_fast_forward`, `unrelated_histories`, `continue_unmerged_paths`, `operation_in_progress`). Common variants:

| Variant | When |
| --- | --- |
| [`NotFastForward`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html#variant.NotFastForward) | [`FastForwardPolicy::Only`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/enum.FastForwardPolicy.html#variant.Only) but histories diverged |
| [`UnrelatedHistories`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html#variant.UnrelatedHistories) | No merge base and `allow_unrelated` is false |
| [`ContinueUnmergedPaths`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html#variant.ContinueUnmergedPaths) | [`continue_merge`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.continue_sequence) with conflict stages still in the index |
| [`NoMergeInProgress`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html#variant.NoMergeInProgress) | Continue/abort/skip with no active merge |
| [`OperationInProgress`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.MergeError.html#variant.OperationInProgress) | Another paused operation (merge, pick, rebase, …) blocks the call |

These arrive as [`Error::Merge`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Merge); repository read, object, and I/O failures arrive as their own area variants of the umbrella [`Error`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html).

## Integrating into detached `HEAD` (`integrate_detached_head`)

[`Merge::integrate`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.integrate) with [`MergeRequest::Detached { into_oid }`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergeOptions.html) takes the current detached tip instead of a branch ref. Outcomes, conflict handling, hooks, and [`MergeOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergeOptions.html) match [`Merge::integrate_into_branch`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.integrate_into_branch), but only `HEAD` moves on a fast-forward or merge commit; no `refs/heads/*` ref is updated. Reflog lines use `merge {label}` / `merge {label}: fast-forward` on `HEAD` only.

# https://grit-scm.com/docs/library/migrating-to-0.6/index.md

# Migrating from 0.5.x to 0.6

> Theme-by-theme API updates for embedders moving to the stable 0.6 library surface, plus a generated path map from v0.5.31.

Grit-lib **0.6** keeps on-disk and wire compatibility with Git, but the **public Rust API** is intentionally smaller: one [`Repository`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) entry point, typed handles, options structs, and per-area errors. This page is for code written against **0.5.x** (snapshot baseline **v0.5.31**).

For the stability rules and handle map, see [`grit-lib/API.md`](https://github.com/gitbutlerapp/grit/blob/main/grit-lib/API.md) and the [API layout](https://grit-scm.com/docs/library/migrating-to-0.6/api-layout.md/index.md). For an overview of the 0.6 surface, see [API layout](https://grit-scm.com/docs/library/migrating-to-0.6/api-layout.md/index.md) and [Repository](https://grit-scm.com/docs/library/migrating-to-0.6/repository.md/index.md).

## 1. Theme-by-theme changes

### Repository handles instead of free functions

Operations that used to take `&Repository`, `repo.git_dir()`, or loose module paths are methods on the handle that owns the area. Open the repo once, then call the accessor:

```rust
// 0.5.x
use grit_lib::{config, worktree, command_runner::hooks};
hooks::run_hook(&repo, "pre-commit", &[], None)?;
worktree::list_worktrees(&repo)?;
let _ = config::set_config_value(
    grit_lib::config::ConfigLocation::Local,
    repo.environment(),
    Some(repo.git_dir()),
    "user.name",
    "Ada",
    false,
)?;

// 0.6
repo.hooks().run("pre-commit", &[], None)?;
repo.worktrees().list()?;
let editor = grit_lib::config::ConfigEditor::open(
    repo.environment().clone(),
    repo.git_dir().to_path_buf(),
    grit_lib::config::ConfigScope::Local,
);
editor.set("user.name", "Ada", &Default::default())?;
```

The same pattern applies across the tree: [`repo.diff()`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.diff) for blame and diffs, [`repo.notes()`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.notes) for notes, [`repo.branches()`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.branches) / [`repo.checkout()`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.checkout) for branch and working-tree porcelain, [`repo.commits()`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.commits) for commit creation, and [`repo.index()`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.index) for staging.

Config **writes** no longer use top-level `config::set_config_value` helpers. Use [`ConfigEditor`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigEditor.html) on a file or scope, or [`Config::set`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.set) on an open repository when editing local/worktree config in place.

### Options structs instead of `_with_x` families

Optional behaviour is a single `#[non_exhaustive]` options struct with `Default` and `with_*` setters — not parallel function names.

```rust
// 0.5.x
checkout::checkout_between_trees_with_progress(
    &repo,
    old_tree,
    new_tree,
    &options,
    &mut progress,
)?;

// 0.6
repo.checkout().checkout(
    Some(&old_tree),
    new_tree,
    &mut progress,
    &grit_lib::progress::CancelToken::never(),
)?;
```

Pass [`SwitchOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/switch/struct.SwitchOptions.html) (and related checkout option structs) through [`repo.checkout()`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.checkout) methods; long-running paths take progress and cancel as **trailing** parameters (see below).

### One `CancelToken` and one `ProgressSink`

Cancellation and progress are always the last parameters, in that order: `progress`, then `cancel`. Use [`NullProgress`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.NullProgress.html) and [`CancelToken::never()`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html#method.never) when you do not need them.

```rust
// 0.5.x
worktree::add_linked_worktree_with_cancel(&repo, &opts, &cancel)?;

// 0.6 — one method, trailing progress and cancel
repo.worktrees().add(&opts, &mut NullProgress, &cancel)?;
```

There are no separate `_with_progress` / `_with_cancel` variants: every long-running operation takes both trailing parameters, including the ones that took neither in 0.5 (maintenance steps such as `prune_loose_objects`, `write_commit_graph`, `write_midx`, `offload_blobs` and `drop_promised_blobs`; `ingest_received_pack`, `ingest_pack_into`, `PackObjects::write_to` and `UploadPackStream::write`, whose `out` argument now comes before `progress`; `Diff::{index_to_worktree, tree_to_worktree}`; linked worktree `add`, `remove` and `move_linked`; and `Checkout::{remove_paths, move_path, move_paths, preview_reset}`). Pass `&mut NullProgress` and `&CancelToken::never()` to keep the 0.5 behaviour. `Maintenance::pack_refs` and the ref-listing remote calls (`ls_remote`, `inspect`, `prune`, `set_head`) take neither; `grit-lib/API.md` says why.

The fetch-only `remote::fetch::Progress` subtrait is gone: its methods (`message`, `remote_sideband_progress`, `wants_received_objects`, `received_objects`, `resumable_transfer`, `milestone`) are provided no-op methods on [`ProgressSink`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html), so implement `ProgressSink` and override what you need. `remote::fetch::NoProgress` is replaced by [`NullProgress`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.NullProgress.html), and `FetchMilestone` moved to [`grit_lib::progress::FetchMilestone`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.FetchMilestone.html). `pull` and `RepositorySnapshotCheckouts::refresh` take `&mut dyn ProgressSink` instead of a generic sink.

### `RefName` and `Pathspec` instead of bare strings

Ref and path selection use newtypes and [`Pathspec`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html) rather than `&str` / `&[String]` deep in library calls. Parse at your CLI or UI boundary; inside the library, use [`References::resolve`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.resolve) and [`Diff::resolve_pathspec`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.resolve_pathspec).

### Ref names are validated, and strings no longer convert to `RefNameRef`

`str` and `String` no longer implement `AsRef<RefNameRef>`, so [`References`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html) methods (`resolve`, `symbolic`, `update`, `update_direct`, `update_symbolic`, `compare_and_swap`, `delete`, `compare_and_delete`, `reflog`), [`RepositoryReflogs::exists`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryReflogs.html#method.exists) and `append`, [`PackedRefs::get`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.PackedRefs.html#method.get), `ref_matches_glob` and the other `impl AsRef<RefNameRef>` parameters take only validated names. Build one with [`RefName::new`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefName.html#method.new) (also `TryFrom<&str>`, `TryFrom<String>` and `str::parse`), [`RefNameRef::new`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefNameRef.html#method.new) for a borrowed name, or [`RefName::branch`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefName.html#method.branch) / [`RefName::tag`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefName.html#method.tag) from a short name. They accept full names under `refs/`, `HEAD` and upper-case pseudo-refs such as `ORIG_HEAD`; the inherent `RefName::try_from`, which rejected pseudo-refs, is now the `TryFrom<&str>` impl with that wider rule. A failed check converts into [`RefError::InvalidName`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.RefError.html#variant.InvalidName), so `?` works. Use `RefNameRef::HEAD` for `HEAD`. `RefName::from_trusted` and `RefNameRef::from_trusted`, which wrapped a string without checking it, are no longer public: use `RefName::new` / `TryFrom` (or `RefNameRef::new`) instead, including in a custom [`RefStore`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/trait.RefStore.html) that rebuilds names it stored when it lists them. `Tags::delete` now rejects a name that is not a valid tag name (`TagError::InvalidName`) instead of reading `refs/tags/<name>` unchecked.

```rust
// 0.5.x
repo.references().update("refs/heads/backup", &tip)?;
let head = repo.references().symbolic("HEAD")?;

// 0.6
use grit_lib::refs::store::{RefName, RefNameRef};
repo.references().update(&RefName::new("refs/heads/backup")?, &tip)?;
let head = repo.references().symbolic(RefNameRef::HEAD)?;
```

### `ObjectError::NotFound` names an object id

`ObjectError::NotFound { name: String }` was used for missing objects, revision expressions that matched nothing and assorted prose. It is now `NotFound { oid: ObjectId }` and means only that the object store lacks `oid`. A revision expression that names nothing (an unknown name, an abbreviated id with no match, `:/<text>` with no match, a missing `FETCH_HEAD`) is [`RevisionError::NotFound { spec }`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.RevisionError.html#variant.NotFound); `~`/`^` past a root commit is `RevParseError::RevisionOutOfRange`; `A...B` with no common ancestor is [`RevisionError::NoMergeBase`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.RevisionError.html#variant.NoMergeBase); an object that cannot be peeled to the kind asked for is [`ObjectError::UnexpectedKind`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.UnexpectedKind). `BundleError::ObjectNotFound` carries an `oid: ObjectId` too. Two writes that used to fold context into the name have their own variants: an index entry whose object is missing when a tree is written from the index is [`ObjectError::MissingTreeMember { path, mode, oid }`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.MissingTreeMember), and a push whose source object is missing locally is [`RemoteError::PushSourceMissing { dst, oid }`](https://docs.rs/grit-lib/latest/grit_lib/remote/enum.RemoteError.html#variant.PushSourceMissing).

```rust
// 0.5.x
Err(Error::Object(ObjectError::NotFound { name })) => println!("not found: {name}"),

// 0.6
Err(Error::Object(ObjectError::NotFound { oid })) => println!("object {oid} is missing"),
Err(Error::Revision(RevisionError::NotFound { spec })) => println!("no revision {spec}"),
```

### Typed errors per area

Stop matching `Error::Message` or `Result<_, String>`. Each area returns its own `#[non_exhaustive]` enum that converts into [`Error`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html). Match on variants (see [Errors](https://grit-scm.com/docs/library/migrating-to-0.6/errors.md/index.md)):

```rust
// 0.5.x — do not use string matching on Error::Message or Result<_, String>

// 0.6
use grit_lib::error::{Error, RevisionError};
match err {
    Error::Revision(RevisionError::NotFound { .. }) => { /* … */ }
    other => return Err(other.into()),
}
```

### Kind, status and outcome enums are `#[non_exhaustive]`

Enums that will gain variants as Git grows (outcomes such as [`PullResult`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/enum.PullResult.html) and [`IntegrateBranchOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/enum.IntegrateBranchOutcome.html), statuses, reasons, modes, kinds, events) are now `#[non_exhaustive]`, so a `match` on them needs a trailing `_` arm. Multi-field variants of outcome enums (for example `IntegrateBranchOutcome::Merged` or `RebaseOutcome::Done`) are `#[non_exhaustive]` too: bind the fields you need and end the pattern with `..`.

```rust
use grit_lib::porcelain::pull::PullResult;

let label = match result {
    PullResult::UpToDate => "up to date",
    PullResult::FastForward => "fast-forwarded",
    _ => "updated",
};
```

Sets closed by a Git format or by definition (`ObjectKind`, `HashAlgo`, `HeadState`, `ResetMode`, `TagMode`, …) stay exhaustive; `grit-lib/API.md` lists them.

### Outcome, report and model structs are `#[non_exhaustive]`

Structs the library returns for you to read (`*Outcome`, `*Report`, `*Stats`, `*Summary`, listing rows, status, diff, blame and log models, error payloads such as `LockHeldError`) are `#[non_exhaustive]`, so they can gain fields in a minor release. Read their public fields as before; a destructuring pattern ends in `..`. Where you also need to build one, use its constructor and assign optional fields afterwards: a custom object store returns [`Object::new`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Object.html#method.new), [`ObjectInfo::new`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectInfo.html#method.new) and [`ObjectStream::new`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.ObjectStream.html#method.new); [`CommitData::new`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.CommitData.html#method.new) and [`TagData::new`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TagData.html#method.new) feed `serialize_commit` / `serialize_tag`; [`DiffEntry::new`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffEntry.html#method.new) builds rename-detection input.

```rust
use grit_lib::objects::{serialize_commit, CommitData, ObjectId};

let tree = ObjectId::from_hex("4b825dc642cb6eb9a060e54bf8d69288fbee4904")?;
let mut commit = CommitData::new(tree, Vec::new(), "A <a@example.com> 0 +0000", "A <a@example.com> 0 +0000", "initial\n");
commit.encoding = Some("ISO-8859-1".into());
let bytes = serialize_commit(&commit);
```

Records fixed by a Git format (`ReflogEntry`, `ObjectKindCounts`, `LeftRightCounts`, …) stay exhaustive.

### `TreeEntry` and `IndexEntry` are built with `new`

[`TreeEntry`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeEntry.html) and [`IndexEntry`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexEntry.html) are `#[non_exhaustive]`; build them with [`TreeEntry::new(name, mode, oid)`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeEntry.html#method.new) and [`IndexEntry::new(path, oid, mode)`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexEntry.html#method.new). `TreeEntry::mode` is a [`FileMode`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.FileMode.html) instead of a `u32` (it still holds any mode a stored tree contains; `FileMode::bits()` gives the raw value), and so is `TreeEntryError::InvalidMode::mode`. `IndexEntry::new` zeroes the stat data and fills the flag word itself; set a conflict stage with [`with_stage`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexEntry.html#method.with_stage) or [`set_stage`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexEntry.html#method.set_stage), and stat data with `with_size`, `with_mtime`, `with_ctime` or by assigning the public fields. The raw `flags`, `flags_extended` and `base_index_pos` fields are no longer public: read them through `stage()`, `assume_unchanged()`, `skip_worktree()`, `intent_to_add()` and `fsmonitor_valid()`. `IndexEntry` equality now ignores the name-length and extended bits the index writer recomputes. `Index::dump_cache_tree` and `Index::format_cache_tree_dump` (Git test-tool output) are no longer public.

```rust
use grit_lib::index::IndexEntry;
use grit_lib::objects::{FileMode, ObjectId, TreeEntry};

let blob = ObjectId::from_hex("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391")?;
// 0.5.x: TreeEntry { mode: 0o100644, name: b"README".to_vec(), oid: blob }
let entry = TreeEntry::new("README", FileMode::REGULAR, blob);
// 0.5.x: IndexEntry { ctime_sec: 0, …, flags: 6 | (2 << 12), …, base_index_pos: 0 }
let ours = IndexEntry::new("README", blob, FileMode::REGULAR).with_stage(2);
```

### Options and request structs are `#[non_exhaustive]`

Input structs that grow with new flags are `#[non_exhaustive]`, so struct literals and `..Default::default()` no longer compile outside grit-lib. Start from `default()`, or from `new(…)` when a field has no sensible default, and chain one `with_<field>` setter per field you change:

| Struct | Start from |
| --- | --- |
| [`RevWalkListOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkListOptions.html), [`RefQuery`](https://docs.rs/grit-lib/latest/grit_lib/refs/listing/struct.RefQuery.html), [`RefUpdateFlags`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefUpdateFlags.html) | `default()` |
| [`RefUpdate`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefUpdate.html) | `new(name, new_value)` |
| [`CreateTagRequest`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/struct.CreateTagRequest.html) | `new(name, target)` |
| [`ExpireOptions`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.ExpireOptions.html) | `new(now)` |
| [`RewriteOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewriteOptions.html) | `new(committer)` |
| [`ApplyOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.ApplyOptions.html) | `new(identity, reflog_message)` |
| [`RebaseOntoOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RebaseOntoOptions.html) | `new(rewrite)` |
| [`PushOptions`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PushOptions.html), [`PushRefSpec`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PushRefSpec.html), [`PullOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/struct.PullOptions.html) | `default()` |
| [`CloneOptions`](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/struct.CloneOptions.html) | `new(url, dest)` |
| [`CloneIntoOptions`](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/struct.CloneIntoOptions.html) | `new(url)` |
| [`ServeOptions`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ServeOptions.html), [`ReceivePolicy`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePolicy.html) | `default()` |
| [`SwitchOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/switch/struct.SwitchOptions.html) | `new(mode)` |
| [`RestoreOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/restore/struct.RestoreOptions.html) | `new(pathspecs)` |
| [`MergeOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergeOptions.html), [`StatusOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.StatusOptions.html), [`OwnershipContext`](https://docs.rs/grit-lib/latest/grit_lib/ownership_check/struct.OwnershipContext.html) | `default()` |
| [`CommandEnvironment`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.CommandEnvironment.html), [`CommitHookEnv`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/struct.CommitHookEnv.html), [`ProtocolPolicyInputs`](https://docs.rs/grit-lib/latest/grit_lib/remote/protocol/struct.ProtocolPolicyInputs.html), [`GitDaemonTransport`](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/struct.GitDaemonTransport.html) | `default()` |
| [`Credential`](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/struct.Credential.html) | `default()` (its `Debug` output redacts the password, including one embedded in `url`) |
| [`RefSort`](https://docs.rs/grit-lib/latest/grit_lib/refs/listing/struct.RefSort.html), [`RefQueryOptions`](https://docs.rs/grit-lib/latest/grit_lib/refs/listing/struct.RefQueryOptions.html), [`IgnoreRevsSources`](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.IgnoreRevsSources.html), [`ReachableWalkCommitterCutoffs`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/merge_base/struct.ReachableWalkCommitterCutoffs.html) | `default()` |
| [`TreeMergeConflictPresentation`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/struct.TreeMergeConflictPresentation.html), [`RenameDetection`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.RenameDetection.html) (status) | `default()` |
| [`DateMode`](https://docs.rs/grit-lib/latest/grit_lib/config/git_date/struct.DateMode.html) | `from_type(ty)` or `parse_date_format(format, output_is_terminal)` (the caller now says whether output is a terminal for `auto:` formats) |
| [`GraphCharset`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.GraphCharset.html) | `GraphCharset::ASCII` or `GraphCharset::UNICODE` |
| [`PathspecFile`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.PathspecFile.html) | `new(data, nul_terminated)` |
| [`StartPoint`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.StartPoint.html) | `new(oid, label)` |
| [`NewTrailerArg`](https://docs.rs/grit-lib/latest/grit_lib/commit/trailers/interpret/struct.NewTrailerArg.html) | `new(text)` |
| [`ReftableTransactionUpdate`](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/struct.ReftableTransactionUpdate.html) | `new(refname)` |
| [`RefTransactionItem`](https://docs.rs/grit-lib/latest/grit_lib/refs/gc/struct.RefTransactionItem.html) | `new(name, new_oid)` |
| [`ReflogUpdate`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.ReflogUpdate.html) | `new(identity, message, time)` or `from_signature(signature, message)` |
| [`BranchCommitRefUpdate`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.BranchCommitRefUpdate.html) | `new(branch_ref, expected_old, new_oid, identity, reflog_message)` |
| [`NewCommit`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.NewCommit.html) (history) | `new(tree, author, message)` |
| [`LineRange`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/hunk_select/struct.LineRange.html) | `new(path, start, end)` |
| [`PatchResolvedSide`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.PatchResolvedSide.html) | `new(entry, old, new)` |
| [`CloneReflog`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.CloneReflog.html) | `new(identity, message)` |
| [`PrePushRef`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/struct.PrePushRef.html) | `new(local_ref, local_oid, remote_ref, remote_oid)` |
| [`ReflogSelector`](https://docs.rs/grit-lib/latest/grit_lib/refs/reflog/struct.ReflogSelector.html) | `new(ref_name, index)` or `str::parse` |
| [`MergeSource`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergeSource.html) | `new(oid, kind)` |
| [`ApplyOptions`](https://docs.rs/grit-lib/latest/grit_lib/apply/struct.ApplyOptions.html) (apply), [`IndexApplyOptions`](https://docs.rs/grit-lib/latest/grit_lib/apply/struct.IndexApplyOptions.html), [`BlameOptions`](https://docs.rs/grit-lib/latest/grit_lib/blame/struct.BlameOptions.html), [`BundleSpec`](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.BundleSpec.html), [`BundleCreateOptions`](https://docs.rs/grit-lib/latest/grit_lib/bundle/bundle_remote/struct.BundleCreateOptions.html), [`RunHookOptions`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/struct.RunHookOptions.html), [`ProcessTrailerOptions`](https://docs.rs/grit-lib/latest/grit_lib/commit/trailers/interpret/struct.ProcessTrailerOptions.html), [`IncludeContext`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.IncludeContext.html), [`LoadConfigOptions`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.LoadConfigOptions.html), [`InitFilesystemConfigOptions`](https://docs.rs/grit-lib/latest/grit_lib/config/init_filesystem/struct.InitFilesystemConfigOptions.html), [`CommitFilesManyOptions`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.CommitFilesManyOptions.html), [`DiffRequest`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.DiffRequest.html), [`CombinedDiffWsOptions`](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_diff_patch/struct.CombinedDiffWsOptions.html), [`CombinedTreeDiffOptions`](https://docs.rs/grit-lib/latest/grit_lib/diff/combined_tree_diff/struct.CombinedTreeDiffOptions.html), [`FmtMergeMsgOptions`](https://docs.rs/grit-lib/latest/grit_lib/diff/fmt_merge_msg/struct.FmtMergeMsgOptions.html), [`IndexParseContext`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexParseContext.html), [`StatMatchPolicy`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.StatMatchPolicy.html), [`WorktreeModePolicy`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.WorktreeModePolicy.html), [`FsckObjectOptions`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/struct.FsckObjectOptions.html), [`IngestPackOptions`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/struct.IngestPackOptions.html), [`BranchListQuery`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.BranchListQuery.html), [`ExecSpec`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.ExecSpec.html), [`SplitOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.SplitOptions.html), [`LogWalkQuery`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/log_walk/struct.LogWalkQuery.html), [`ConvertToGitOpts`](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/struct.ConvertToGitOpts.html), [`FileAttrs`](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/struct.FileAttrs.html) | `default()` |
| [`CommandSpec`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.CommandSpec.html) | `new(program)` |
| [`CommitFilesManyInput`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.CommitFilesManyInput.html) | `new(oid, parents, tree)` |
| [`LogPatchOptions`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.LogPatchOptions.html) | `new(diff)` or `git_default(config)` |
| [`PatchTextOptions`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.PatchTextOptions.html) | `new(diff, abbrev_len)` or `from_repo(repo, diff)` |
| [`ReachabilityQuery`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.ReachabilityQuery.html) | `new(wants, haves)` |
| [`StandingOptions`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.StandingOptions.html) | `new(newest_ahead_limit)` |
| [`TargetComparisonOptions`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.TargetComparisonOptions.html) | `new(list_limit)` |
| [`FetchInvocation`](https://docs.rs/grit-lib/latest/grit_lib/remote/fetch_request/struct.FetchInvocation.html) | `new(remote)` |
| [`AbsorbOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.AbsorbOptions.html) | `new(rewrite)` |
| [`FixupOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.FixupOptions.html) | `new(rewrite)` |
| [`HunkRange`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.HunkRange.html) | `new(old_start, old_lines, new_start, new_lines)` |
| [`RebaseRequest`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RebaseRequest.html) | `new(upstream, branch_tip)` |
| [`SquashOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.SquashOptions.html) | `new(message, rewrite)` |
| [`StartRebaseOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.StartRebaseOptions.html) | `new(request, rebase, apply)` |
| [`ConversionConfig`](https://docs.rs/grit-lib/latest/grit_lib/worktree/crlf/struct.ConversionConfig.html) | `from_config(config)` (`from_config_with_runner` is gone: chain `with_command_runner`) |
| [`WhitespaceMergeOptions`](https://docs.rs/grit-lib/latest/grit_lib/merge/merge_trees/struct.WhitespaceMergeOptions.html), [`WriteSplitIndexRequest`](https://docs.rs/grit-lib/latest/grit_lib/index/split_index/struct.WriteSplitIndexRequest.html), [`WriteTreeFlags`](https://docs.rs/grit-lib/latest/grit_lib/index/write_tree/struct.WriteTreeFlags.html), [`ContinueOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.ContinueOptions.html), [`IntegrateBranchOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.IntegrateBranchOptions.html), [`MergePredictionOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.MergePredictionOptions.html), [`ReplayOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/struct.ReplayOptions.html), [`WriteTreeOptions`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.WriteTreeOptions.html), [`PackBitmapWriteOptions`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.PackBitmapWriteOptions.html), [`WriteMultiPackIndexOptions`](https://docs.rs/grit-lib/latest/grit_lib/objects/midx/struct.WriteMultiPackIndexOptions.html), [`PackFilter`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/struct.PackFilter.html), [`PromisorAcceptPolicy`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/struct.PromisorAcceptPolicy.html), [`UnpackOptions`](https://docs.rs/grit-lib/latest/grit_lib/objects/unpack_objects/struct.UnpackOptions.html), [`ThreadPolicy`](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ThreadPolicy.html), [`ProtectOptions`](https://docs.rs/grit-lib/latest/grit_lib/path_validate/struct.ProtectOptions.html), [`BranchDeleteOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.BranchDeleteOptions.html), [`CleanOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/clean/struct.CleanOptions.html), [`HunkSelection`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/hunk_select/struct.HunkSelection.html), [`DecorationFilter`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/log/struct.DecorationFilter.html), [`RemoveOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/paths/struct.RemoveOptions.html) (paths), [`IndexStagingThresholds`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/stage_tracked/struct.IndexStagingThresholds.html), [`WorkspaceCaptureOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/workspace_snapshot/struct.WorkspaceCaptureOptions.html), [`PhaseRates`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.PhaseRates.html), [`RefBatchState`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/backend/struct.RefBatchState.html), [`WriteOptions`](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/struct.WriteOptions.html) (reftable), [`InspectOptions`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.InspectOptions.html), [`ListRefsOptions`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.ListRefsOptions.html), [`PushInvocation`](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/struct.PushInvocation.html), [`PushPlanContext`](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/struct.PushPlanContext.html), [`PushRequest`](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/struct.PushRequest.html), [`ReceiveHookContext`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceiveHookContext.html), [`PackBuildOptions`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PackBuildOptions.html), [`PackObjectsOptions`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PackObjectsOptions.html), [`ReflogQuery`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.ReflogQuery.html), [`RemoveOptions`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RemoveOptions.html) (remote), [`DescribeOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.DescribeOptions.html), [`GroupByAuthorOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/group_by/struct.GroupByAuthorOptions.html), [`RevWalkCommitIterOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkCommitIterOptions.html), [`ReachableCountFilter`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/merge_base/struct.ReachableCountFilter.html), [`RevListOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListOptions.html), [`StashApplyOptions`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashApplyOptions.html), [`StashDiffOptions`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashDiffOptions.html), [`LockWorktreeOptions`](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.LockWorktreeOptions.html), [`PruneWorktreesOptions`](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.PruneWorktreesOptions.html), [`MoveWorktreeOptions`](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.MoveWorktreeOptions.html), [`PathspecGlobalFlags`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.PathspecGlobalFlags.html) | `default()` |
| [`GpgConfig`](https://docs.rs/grit-lib/latest/grit_lib/commit/signing/struct.GpgConfig.html) | `from_config(config)` |
| [`MergeInput`](https://docs.rs/grit-lib/latest/grit_lib/diff/merge_file/struct.MergeInput.html) | `new(base, ours, theirs)` |
| [`BranchIntegrateRequest`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.BranchIntegrateRequest.html) | `new(into_ref, into_oid, source, label)` |
| [`ReplaySequenceRequest`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/struct.ReplaySequenceRequest.html) | `new(commits, direction, committer)` |
| [`ReplayRequest`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay/struct.ReplayRequest.html) | `new(commit, direction, committer)` |
| [`PackEnumerateOptions`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_object_select/struct.PackEnumerateOptions.html) | `new(shallow_grafts)` |
| [`ParallelOptions`](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ParallelOptions.html) | `new(threads)` (or `ThreadPolicy::resolve`) |
| [`BranchCreateOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.BranchCreateOptions.html) | `at_head(name)` |
| [`BranchRenameOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.BranchRenameOptions.html) | `new(old, new)` |
| [`MoveOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/paths/struct.MoveOptions.html) | `new(sources, destination)` |
| [`ResetOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/reset/struct.ResetOptions.html) | `new(target, mode, identity, message)` |
| [`RefBatchItem`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.RefBatchItem.html) | `new(name, new_oid)` |
| [`FilesRefStoreConfig`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.FilesRefStoreConfig.html) | `new(git_dir, common_dir)` |
| [`RefCaseOnlyRename`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefCaseOnlyRename.html) | `new(from, to)` |
| [`RefReflogRename`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefReflogRename.html) | `new(from, to, append)` |
| [`NotesWriteOptions`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.NotesWriteOptions.html) | `new(message, committer)` |
| [`GraphCommitInput`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.GraphCommitInput.html) | `new(id, parents)` |
| [`StashPushOptions`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashPushOptions.html) | `new(identity)` |
| [`TagVerifyOptions`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TagVerifyOptions.html) | `new(gpg)` |
| [`AddLinkedWorktreeOptions`](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.AddLinkedWorktreeOptions.html) | `new(path)` |
| [`HttpRequest`](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/http/struct.HttpRequest.html) | `new(method, url)` |
| [`ThreadPolicy`](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ThreadPolicy.html) setters | `with_threads_override`, `with_min_items_override` and `with_min_total_bytes_override` now take `self`: write `ThreadPolicy::default().with_threads_override(Some(4))` (the `min_items_override` and `min_total_bytes_override` methods are gone) |

`OwnershipContext` is no longer `Copy`; clone it where you need a second copy.

The struct-like variants of [`CommitEdit`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.CommitEdit.html) are `#[non_exhaustive]` too. Build them with [`CommitEdit::rewrite`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.CommitEdit.html#method.rewrite), [`CommitEdit::split_before`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.CommitEdit.html#method.split_before), [`CommitEdit::reparent`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.CommitEdit.html#method.reparent) and [`CommitEdit::reuse`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.CommitEdit.html#method.reuse), and end patterns on them with `..`.

```rust
// 0.5.x
let update = RefUpdate {
    name: RefName::from_trusted("refs/heads/topic"),
    new_value: Some(RawRef::Direct(oid)),
    expected: Expected::Missing,
    reflog: None,
    flags: RefUpdateFlags::default(),
};

// 0.6
let update = RefUpdate::new(RefName::new("refs/heads/topic")?, Some(RawRef::Direct(oid)))
    .with_expected(Expected::Missing);
```

### Custom object store via `RepositoryOptions`

Injection moved into [`RepositoryOptions`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html): use [`with_object_store`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_object_store) and [`with_ref_store`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_ref_store) on open/discover/init, not ad hoc parameters on individual calls.

```rust
let opts = RepositoryOptions::empty()
    .with_object_store(Arc::new(my_store));
let repo = Repository::open(git_dir, opts)?;
```

### `test-support` feature for helpers

Benchmark fixtures, probe hooks, and test-only dump helpers are behind the **`test-support`** cargo feature and are **not** part of the semver public API. Depend on `grit-lib` with `features = ["test-support"]` only in tests or internal tools.

### `unstable-hosting` feature for grit hosting services

The snapshot-checkout client and server engine (`remote::snapshot_checkout`, `Repository::snapshot_checkouts`, `RemoteError::Snapshot`), the grit-server login, share, space and sync clients (`remote::grit_server_*`) and GitHub device-flow sign-in (`remote::github_auth`) are no longer in the default build. Enable the off-by-default **`unstable-hosting`** feature to use them. They are **outside semver** and may change in any release, so pin an exact `grit-lib` version when you enable it. To store a user name and token for any host, build the credential with [`Credential::from_url`](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/struct.Credential.html#method.from_url) instead of `ServerUrl::credential`.

### One public path per item

Flat root re-exports and compatibility type aliases (`CreateBranchOptions`, `TagInfo`, `DeleteMode`, …) are removed. Import the canonical path (for example [`BranchCreateOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.BranchCreateOptions.html), [`TagSummary`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/struct.TagSummary.html), [`BranchDeleteMode`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/enum.BranchDeleteMode.html)). The [canonical module map](https://grit-scm.com/docs/library/migrating-to-0.6/api-layout.md/index.md) lists flat → domain paths.

## 2. Removed public paths (v0.5.31 → 0.6)

The table below is generated from `grit-lib/public-api.txt` at **v0.5.31** vs the current tree. Regenerate with `python3 scripts/api_migration.py` (CI runs `python3 scripts/api_migration.py --check` in the public-api job).

<!-- api-migration:begin -->

| Removed path (v0.5.31) | Replacement (0.6) | Notes |
| --- | --- | --- |
| `grit_lib::apply::BlobApplyOptions` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::apply::BlobApplyOptions::allow_binary_marker_only` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::apply::BlobApplyOptions::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::apply::BlobApplyOptions::default` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::apply::BlobApplyOptions::eq` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::apply::BlobApplyOptions::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::apply::BlobApplyOptions::reverse` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::apply::FilePatch::new_mode_line` | `removed (patch-parser state, crate-internal in 0.6)` |  |
| `grit_lib::apply::FilePatch::old_mode_line` | `removed (patch-parser state, crate-internal in 0.6)` |  |
| `grit_lib::apply::FilePatch::saw_new_header` | `removed (patch-parser state, crate-internal in 0.6)` |  |
| `grit_lib::apply::FilePatch::saw_old_header` | `removed (patch-parser state, crate-internal in 0.6)` |  |
| `grit_lib::apply::FilePatch::ws_rule` | `removed (never set; always 0)` |  |
| `grit_lib::apply::apply_patch_to_blob` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::blame::blame_file` | `grit_lib::diff::Diff::blame` |  |
| `grit_lib::blame::resolve_blame_line_range` | `grit_lib::diff::Diff::resolve_blame_line_range` |  |
| `grit_lib::blame::resolve_blame_line_range_with_options` | `grit_lib::diff::Diff::resolve_blame_line_range_with_options` |  |
| `grit_lib::bundle::BundleError::ObjectNotFound::name` | `grit_lib::bundle::BundleError::ObjectNotFound::oid (an ObjectId instead of a hex string)` |  |
| `grit_lib::bundle::write_bundle_header` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::change_id::OsChangeIdGenerator` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::change_id::OsChangeIdGenerator::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::change_id::OsChangeIdGenerator::default` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::change_id::OsChangeIdGenerator::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::change_id::OsChangeIdGenerator::random_bytes` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::command_runner::hooks::RefHookContext` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::command_runner::hooks::RefHookContext::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::command_runner::hooks::post_rewrite_stdin` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::command_runner::hooks::resolve_hooks_dir` | `grit_lib::repo_handles::RepositoryHooks::hooks_dir` |  |
| `grit_lib::command_runner::hooks::run_commit_hook` | `grit_lib::repo_handles::RepositoryHooks::run_commit` |  |
| `grit_lib::command_runner::hooks::run_commit_hook_checked` | `grit_lib::repo_handles::RepositoryHooks::run_commit_checked` |  |
| `grit_lib::command_runner::hooks::run_hook` | `grit_lib::repo_handles::RepositoryHooks::run` |  |
| `grit_lib::command_runner::hooks::run_hook_in_git_dir` | `grit_lib::repo_handles::RepositoryHooks::run_in_git_dir` |  |
| `grit_lib::command_runner::hooks::run_hook_opts` | `grit_lib::repo_handles::RepositoryHooks::run` |  |
| `grit_lib::command_runner::hooks::run_post_checkout` | `grit_lib::repo_handles::RepositoryHooks::run_post_checkout` |  |
| `grit_lib::command_runner::hooks::run_post_merge` | `grit_lib::repo_handles::RepositoryHooks::run_post_merge` |  |
| `grit_lib::command_runner::hooks::run_post_rewrite` | `grit_lib::repo_handles::RepositoryHooks::run_post_rewrite` |  |
| `grit_lib::command_runner::hooks::run_pre_push_hook` | `grit_lib::repo_handles::RepositoryHooks::run_pre_push` |  |
| `grit_lib::command_runner::hooks::run_pre_rebase` | `grit_lib::repo_handles::RepositoryHooks::run_pre_rebase` |  |
| `grit_lib::command_runner::run_sh_dash_c` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::encoding::decode_bytes` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::encoding::encode_header_text` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::encoding::encode_unicode` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::encoding::ensure_body_trailing_newline` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::encoding::find_invalid_utf8` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::encoding::is_strict_utf8` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::signing::GPG_SIG_HEADER_SHA1` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::signing::GPG_SIG_HEADER_SHA256` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::signing::add_header_signature` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::signing::append_tag_signature` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::signing::commit_gpg_sig_header` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::signing::committer_signing_default` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::signing::extra_headers_without_commit_signatures` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::signing::extract_signed_payload` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::signing::parse_signed_buffer` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::signing::should_sign_commit` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::signing::sign_buffer` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::signing::sign_serialized_commit` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::signing::sign_serialized_tag` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::commit::trailers::append_cherry_picked_from_line` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::add_config_value` | `grit_lib::config::ConfigEditor::add_value` | use ConfigEditor on a repository config snapshot |
| `grit_lib::config::config_entry_origin_line` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::environment::Environment::capture_process` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::clone` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::config_fingerprint` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::default_xdg_config_git_file` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::discovery_cwd` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::empty` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::fmt` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::from_vars` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::git_now_date_override` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::home_dir` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::is_fetch_options_default` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::push_config_override` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::subprocess_environment` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::var` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::var_os` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::with_git_dir` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::with_var` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::Environment::with_work_tree` | `grit_lib::config::environment::Environment (unchanged; the snapshot lists this member under grit_lib::prelude::Environment)` |  |
| `grit_lib::config::environment::RepositoryOptions::clone` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::default` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::empty` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::fmt` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::for_serving` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::from_process` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::ownership_check` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::uses_default_ownership_check` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::with_change_id_generator` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::with_command_runner` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::with_diagnostics` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::with_environment` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` | use `InitOptions::with_repository_options(RepositoryOptions::with_environment(env))` |
| `grit_lib::config::environment::RepositoryOptions::with_hook_stdio` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::with_initial_branch` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::with_network_trace` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::with_object_store` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::with_odb_builder` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::with_ownership_check` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::with_promisor_fetcher` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::with_ref_store` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::with_reftable_write` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::with_work_tree` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::environment::RepositoryOptions::without_format_validation` | `grit_lib::config::environment::RepositoryOptions (unchanged; the snapshot lists this member under grit_lib::prelude::RepositoryOptions)` |  |
| `grit_lib::config::git_date::TzHhmm` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::git_date::approx::approxidate_careful` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::git_date::local_tzoffset` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::git_date::show_date_relative` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::gitmodules::ATTR_MAX_FILE_SIZE` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::gitmodules::ATTR_MAX_LINE_LENGTH` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::gitmodules::gitdir::registered_submodule_paths` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::ident_resolve::GitIdentityNameEnv` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::ident_resolve::GitIdentityNameEnv::Set` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::ident_resolve::GitIdentityNameEnv::Unset` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::ident_resolve::GitIdentityNameEnv::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::ident_resolve::GitIdentityNameEnv::eq` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::ident_resolve::GitIdentityNameEnv::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::parse_git_signed_config` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::config::remove_config_section` | `grit_lib::config::ConfigEditor::remove_section` | use ConfigEditor on a repository config snapshot |
| `grit_lib::config::rename_config_section` | `grit_lib::config::ConfigEditor::rename_section` | use ConfigEditor on a repository config snapshot |
| `grit_lib::config::set_config_value` | `grit_lib::config::ConfigEditor::set` | use ConfigEditor on a repository config snapshot |
| `grit_lib::config::unset_all_config_values` | `grit_lib::config::ConfigEditor::unset_all` | use ConfigEditor on a repository config snapshot |
| `grit_lib::config::unset_config_value` | `grit_lib::config::ConfigEditor::unset` | use ConfigEditor on a repository config snapshot |
| `grit_lib::diagnostics::fatal_line` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::diff::DiffAlgorithm::similar_algorithm` | `core::str::FromStr::from_str (DiffAlgorithm)` |  |
| `grit_lib::diff::anchored_unified_diff` | `grit_lib::diff::unified_diff` |  |
| `grit_lib::diff::annotate_unified_diff_no_newline_at_eof` | `grit_lib::diff::structured (hunk metadata)` |  |
| `grit_lib::diff::bytes_for_diff` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::diff::combined_structured_patch_body` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::diff::combined_tree_diff::combined_diff_paths_trees` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::diff::combined_tree_diff::combined_parent_status_char` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::diff::combined_tree_diff::combined_raw_meta` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::diff::count_changes_with_algorithm` | `grit_lib::diff::Diff::files` |  |
| `grit_lib::diff::line_diff_unified_hunk_body` | `grit_lib::diff::unified_diff` |  |
| `grit_lib::diff::load_odb_blob_side_for_diff` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::diff::normalize_ignore_space_change_line` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::diff::peer_scope_includes_path` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::diff::rerere::RerereAutoupdate::clone` | `grit_lib::diff::rerere::RerereAutoupdate (unchanged; the snapshot lists this member under grit_lib::merge::RerereAutoupdate)` |  |
| `grit_lib::diff::rerere::RerereAutoupdate::default` | `grit_lib::diff::rerere::RerereAutoupdate (unchanged; the snapshot lists this member under grit_lib::merge::RerereAutoupdate)` |  |
| `grit_lib::diff::rerere::RerereAutoupdate::eq` | `grit_lib::diff::rerere::RerereAutoupdate (unchanged; the snapshot lists this member under grit_lib::merge::RerereAutoupdate)` |  |
| `grit_lib::diff::rerere::RerereAutoupdate::fmt` | `grit_lib::diff::rerere::RerereAutoupdate (unchanged; the snapshot lists this member under grit_lib::merge::RerereAutoupdate)` |  |
| `grit_lib::diff::rerere::RerereEvent::clone` | `grit_lib::diff::rerere::RerereEvent (unchanged; the snapshot lists this member under grit_lib::merge::RerereEvent)` |  |
| `grit_lib::diff::rerere::RerereEvent::eq` | `grit_lib::diff::rerere::RerereEvent (unchanged; the snapshot lists this member under grit_lib::merge::RerereEvent)` |  |
| `grit_lib::diff::rerere::RerereEvent::fmt` | `grit_lib::diff::rerere::RerereEvent (unchanged; the snapshot lists this member under grit_lib::merge::RerereEvent)` |  |
| `grit_lib::diff::rerere::RerereEventKind::clone` | `grit_lib::diff::rerere::RerereEventKind (unchanged; the snapshot lists this member under grit_lib::merge::RerereEventKind)` |  |
| `grit_lib::diff::rerere::RerereEventKind::eq` | `grit_lib::diff::rerere::RerereEventKind (unchanged; the snapshot lists this member under grit_lib::merge::RerereEventKind)` |  |
| `grit_lib::diff::rerere::RerereEventKind::fmt` | `grit_lib::diff::rerere::RerereEventKind (unchanged; the snapshot lists this member under grit_lib::merge::RerereEventKind)` |  |
| `grit_lib::diff::rerere::rerere_clear` | `grit_lib::merge::Merge::abort (rerere state)` |  |
| `grit_lib::diff::resolve_indent_heuristic` | `grit_lib::diff::DiffOptions::resolve_indent_heuristic` |  |
| `grit_lib::diff::text_sides_differ` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::diff::tree_diff_structured_entry` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::diff::unified_diff_histogram_hunks_only` | `grit_lib::diff::unified_diff` |  |
| `grit_lib::diff::unified_diff_with_prefix_and_funcname` | `grit_lib::diff::unified_diff` |  |
| `grit_lib::diff::unified_diff_with_prefix_and_funcname_and_algorithm` | `grit_lib::diff::unified_diff` |  |
| `grit_lib::error::ObjectError::NotFound::name` | `grit_lib::error::ObjectError::NotFound::oid (an ObjectId; an unresolved revision spec is grit_lib::error::RevisionError::NotFound)` |  |
| `grit_lib::error::SparseCheckoutWarning` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::error::SparseCheckoutWarning::DisablingConePatternMatching` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::error::SparseCheckoutWarning::RepeatedPattern` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::error::SparseCheckoutWarning::RepeatedPattern::pattern` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::error::SparseCheckoutWarning::UnrecognizedNegativePattern` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::error::SparseCheckoutWarning::UnrecognizedNegativePattern::pattern` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::error::SparseCheckoutWarning::UnrecognizedPattern` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::error::SparseCheckoutWarning::UnrecognizedPattern::pattern` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::error::SparseCheckoutWarning::body` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::error::SparseCheckoutWarning::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::error::SparseCheckoutWarning::eq` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::error::SparseCheckoutWarning::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::error::SparseCheckoutWarning::format_line` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::ParsedSignatureTimes` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::ParsedSignatureTimes::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::ParsedSignatureTimes::eq` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::ParsedSignatureTimes::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::ParsedSignatureTimes::tz_hhmm_range` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::ParsedSignatureTimes::tz_offset_secs` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::ParsedSignatureTimes::unix_seconds` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::SignatureTail` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::SignatureTail::NonNumeric` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::SignatureTail::Overflow` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::SignatureTail::Valid` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::SignatureTail::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::SignatureTail::eq` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::SignatureTail::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::author_identity_line` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::committer_timestamp_for_until_filter` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::committer_timestamp_for_until_filter_bytes` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::committer_unix_seconds_for_ordering_bytes` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::parse_signature_tail` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::parse_signature_times` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::prepare_commit_identity_line` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::replace_identity_date_suffix` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::ident::signature_timestamp_for_pretty` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::index::Index::dump_cache_tree` | `removed (Git test-tool output; crate-internal and test-only in 0.6)` |  |
| `grit_lib::index::Index::format_cache_tree_dump` | `removed (Git test-tool output; crate-internal and test-only in 0.6)` |  |
| `grit_lib::index::IndexEntry::base_index_pos` | `removed (split-index bookkeeping, crate-internal in 0.6)` |  |
| `grit_lib::index::IndexEntry::flags` | `removed (raw on-disk flag word, crate-internal in 0.6: use IndexEntry::new, stage, with_stage, set_stage and assume_unchanged)` |  |
| `grit_lib::index::IndexEntry::flags_extended` | `removed (raw extended flags, crate-internal in 0.6: use skip_worktree, intent_to_add, fsmonitor_valid and their setters)` |  |
| `grit_lib::index::IndexStatFields` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::index::IndexStatFields::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::index::IndexStatFields::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::index::IndexStatFields::from` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::index::IndexStatFields::from_metadata` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::index::IndexStatFields::index_entry` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::lockfile::SystemLockClock` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::lockfile::SystemLockClock::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::lockfile::SystemLockClock::default` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::lockfile::SystemLockClock::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::lockfile::SystemLockClock::now` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::lockfile::SystemLockClock::sleep` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::notes::apply_prepared_notes_rewrite` | `grit_lib::repo_handles::RepositoryNotes::apply_rewrite_plan` |  |
| `grit_lib::notes::copy_notes_for_rewrite` | `grit_lib::repo_handles::RepositoryNotes::copy_for_rewrite` |  |
| `grit_lib::notes::notes_merge_inner` | `grit_lib::repo_handles::RepositoryNotes::merge_refs` |  |
| `grit_lib::notes::prepare_notes_for_rewrite` | `grit_lib::repo_handles::RepositoryNotes::prepare_rewrite` |  |
| `grit_lib::notes::read_notes_tree` | `grit_lib::repo_handles::RepositoryNotes::read_tree` |  |
| `grit_lib::notes::read_notes_tree_limited` | `grit_lib::repo_handles::RepositoryNotes::read_tree_limited` |  |
| `grit_lib::notes::write_notes_commit` | `grit_lib::repo_handles::RepositoryNotes::write_tree_commit` |  |
| `grit_lib::objects::bitmap::BitmapIndexCache` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::bitmap::BitmapIndexCache::default` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::bitmap::MidxBitmapWriter` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::bitmap::MidxBitmapWriter::write` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::bitmap::MidxBitmapWriter::write_for_midx_layer` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::commit_subject_pretty` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::empty_object_id_hash_set` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::empty_oid_byte_filter_map` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::empty_oid_set` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::hash::ChecksumHasher::Sha1` | `removed (ChecksumHasher is an opaque struct in 0.6; build it with ChecksumHasher::new or HashAlgo::checksum_hasher)` |  |
| `grit_lib::objects::hash::ChecksumHasher::Sha256` | `removed (ChecksumHasher is an opaque struct in 0.6; build it with ChecksumHasher::new or HashAlgo::checksum_hasher)` |  |
| `grit_lib::objects::hash::ObjectHasher::Sha1` | `removed (ObjectHasher is an opaque struct in 0.6; build it with ObjectHasher::new or HashAlgo::hasher)` |  |
| `grit_lib::objects::hash::ObjectHasher::Sha256` | `removed (ObjectHasher is an opaque struct in 0.6; build it with ObjectHasher::new or HashAlgo::hasher)` |  |
| `grit_lib::objects::insert_header_before_signature` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::iter_extra_headers` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::next_header_block` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::odb::BULK_TRACKED_RESTAGE_LOOSE_WRITE` | `removed (crate-internal in 0.6: build WriteOptions with its with_* setters)` |  |
| `grit_lib::objects::oid_hash_set_from` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::pack::ReuseWriteStats` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::pack::ReuseWriteStats::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::pack::ReuseWriteStats::default` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::pack::ReuseWriteStats::eq` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::pack::ReuseWriteStats::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::pack::ReuseWriteStats::pack_ofs_fixup_objects` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::pack::ReuseWriteStats::pack_ref_from_ofs_objects` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::pack::ReuseWriteStats::verbatim_reuse_bytes` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::pack::ReuseWriteStats::verbatim_reuse_objects` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::pack::StreamingReuse` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::promisor_remote::PromisorReplyError` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::promisor_remote::PromisorReplyError::Empty` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::promisor_remote::PromisorReplyError::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::promisor_remote::PromisorReplyError::eq` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::promisor_remote::PromisorReplyError::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::read_commit_subject_pretty` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::remove_header_lines` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::objects::tag_header_field` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::parallel::parallel_worthwhile` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::path_validate::component_is_dotgit_alias` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::add::stage` | `grit_lib::index::IndexFile::stage` |  |
| `grit_lib::porcelain::add::stage_for_commit` | `grit_lib::index::IndexFile::stage_for_commit` |  |
| `grit_lib::porcelain::add::stage_on_index` | `grit_lib::index::IndexFile::stage` |  |
| `grit_lib::porcelain::branch::CreateBranchOptions` | `grit_lib::porcelain::branch::BranchCreateOptions` |  |
| `grit_lib::porcelain::branch::CreateBranchOptions::at_head` | `grit_lib::porcelain::branch::BranchCreateOptions::at_head` |  |
| `grit_lib::porcelain::branch::CreateBranchOptions::clone` | `grit_lib::porcelain::branch::BranchCreateOptions::clone` |  |
| `grit_lib::porcelain::branch::CreateBranchOptions::dry_run` | `grit_lib::porcelain::branch::BranchCreateOptions::dry_run` |  |
| `grit_lib::porcelain::branch::CreateBranchOptions::eq` | `grit_lib::porcelain::branch::BranchCreateOptions::eq` |  |
| `grit_lib::porcelain::branch::CreateBranchOptions::fmt` | `grit_lib::porcelain::branch::BranchCreateOptions::fmt` |  |
| `grit_lib::porcelain::branch::CreateBranchOptions::force` | `grit_lib::porcelain::branch::BranchCreateOptions::force` |  |
| `grit_lib::porcelain::branch::CreateBranchOptions::name` | `grit_lib::porcelain::branch::BranchCreateOptions::name` |  |
| `grit_lib::porcelain::branch::CreateBranchOptions::start` | `grit_lib::porcelain::branch::BranchCreateOptions::start` |  |
| `grit_lib::porcelain::branch::CreateBranchOptions::track` | `grit_lib::porcelain::branch::BranchCreateOptions::track` |  |
| `grit_lib::porcelain::branch::DeleteMode` | `grit_lib::porcelain::branch::BranchDeleteMode` |  |
| `grit_lib::porcelain::branch::DeleteMode::Force` | `grit_lib::porcelain::branch::BranchDeleteMode::Force` |  |
| `grit_lib::porcelain::branch::DeleteMode::Safe` | `grit_lib::porcelain::branch::BranchDeleteMode::Safe` |  |
| `grit_lib::porcelain::branch::DeleteMode::clone` | `grit_lib::porcelain::branch::BranchDeleteMode::clone` |  |
| `grit_lib::porcelain::branch::DeleteMode::eq` | `grit_lib::porcelain::branch::BranchDeleteMode::eq` |  |
| `grit_lib::porcelain::branch::DeleteMode::fmt` | `grit_lib::porcelain::branch::BranchDeleteMode::fmt` |  |
| `grit_lib::porcelain::branch::RenameBranchOptions` | `grit_lib::porcelain::branch::BranchRenameOptions` |  |
| `grit_lib::porcelain::branch::RenameBranchOptions::clone` | `grit_lib::porcelain::branch::BranchRenameOptions::clone` |  |
| `grit_lib::porcelain::branch::RenameBranchOptions::dry_run` | `grit_lib::porcelain::branch::BranchRenameOptions::dry_run` |  |
| `grit_lib::porcelain::branch::RenameBranchOptions::eq` | `grit_lib::porcelain::branch::BranchRenameOptions::eq` |  |
| `grit_lib::porcelain::branch::RenameBranchOptions::fmt` | `grit_lib::porcelain::branch::BranchRenameOptions::fmt` |  |
| `grit_lib::porcelain::branch::RenameBranchOptions::force` | `grit_lib::porcelain::branch::BranchRenameOptions::force` |  |
| `grit_lib::porcelain::branch::RenameBranchOptions::new` | `grit_lib::porcelain::branch::BranchRenameOptions::new` |  |
| `grit_lib::porcelain::branch::RenameBranchOptions::old` | `grit_lib::porcelain::branch::BranchRenameOptions::old` |  |
| `grit_lib::porcelain::branch::create_branch` | `grit_lib::repo_handles::Branches::create` |  |
| `grit_lib::porcelain::branch::delete_branch` | `grit_lib::repo_handles::Branches::delete` |  |
| `grit_lib::porcelain::branch::list_branches` | `grit_lib::repo_handles::Branches::list_simple` |  |
| `grit_lib::porcelain::branch::preview_unset_upstream` | `grit_lib::repo_handles::Branches::preview_unset_upstream` |  |
| `grit_lib::porcelain::branch::rename_branch` | `grit_lib::repo_handles::Branches::rename` |  |
| `grit_lib::porcelain::branch::resolve_create_tracking` | `grit_lib::repo_handles::Branches::resolve_create_tracking` |  |
| `grit_lib::porcelain::branch::set_upstream` | `grit_lib::repo_handles::Branches::set_upstream` |  |
| `grit_lib::porcelain::branch::unset_upstream` | `grit_lib::repo_handles::Branches::unset_upstream` |  |
| `grit_lib::porcelain::branch::validate_set_upstream` | `grit_lib::repo_handles::Branches::validate_set_upstream` |  |
| `grit_lib::porcelain::checkout::checkout_between_trees` | `grit_lib::repo_handles::Checkout::checkout` |  |
| `grit_lib::porcelain::checkout::checkout_between_trees_with_progress` | `grit_lib::repo_handles::Checkout::checkout` |  |
| `grit_lib::porcelain::checkout::checkout_hard_to_tree_from_head_tree` | `grit_lib::repo_handles::Checkout::checkout_hard_to_tree` |  |
| `grit_lib::porcelain::checkout::checkout_tree_changes` | `grit_lib::repo_handles::Checkout::checkout_tree_changes` |  |
| `grit_lib::porcelain::checkout::remove_empty_parent_dirs` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::checkout_reflog::append_head_checkout_reflog` | `removed (used by Checkout::switch)` |  |
| `grit_lib::porcelain::checkout_reflog::branch_create_reflog_source_label` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::checkout_reflog::checkout_reflog_from_label` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::checkout_reflog::checkout_reflog_identity` | `removed (used by Checkout::switch)` |  |
| `grit_lib::porcelain::checkout_reflog::create_branch_ref_with_reflog` | `removed (used by Checkout::switch)` |  |
| `grit_lib::porcelain::checkout_reflog::finish_switch_ref_updates` | `removed (used by Checkout::switch)` |  |
| `grit_lib::porcelain::checkout_reflog::is_already_detached_at` | `removed (used by Checkout::switch)` |  |
| `grit_lib::porcelain::checkout_reflog::is_already_on_branch` | `removed (used by Checkout::switch)` |  |
| `grit_lib::porcelain::checkout_reflog::switch_create_reflog_source_label` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::cherry_pick::directory_renames_from_file_renames` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::clean::clean_untracked` | `grit_lib::repo_handles::Checkout::clean` |  |
| `grit_lib::porcelain::clean::clean_untracked_with_cancel` | `grit_lib::repo_handles::Checkout::clean` |  |
| `grit_lib::porcelain::commit::commit_with_patch` | `grit_lib::commits::Commits::create` |  |
| `grit_lib::porcelain::commit::commit_with_scope` | `grit_lib::commits::Commits::create` |  |
| `grit_lib::porcelain::commit::commit_worktree` | `grit_lib::commits::Commits::create` |  |
| `grit_lib::porcelain::commit::create_commit` | `grit_lib::commits::Commits::create` |  |
| `grit_lib::porcelain::commit::default_commit_scope` | `grit_lib::commits::Commits::default_scope` |  |
| `grit_lib::porcelain::commit::default_commit_scope_from_config` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::commit::pending_commit_message` | `grit_lib::commits::Commits::pending_message` |  |
| `grit_lib::porcelain::commit::plan_commit` | `grit_lib::commits::Commits::plan` |  |
| `grit_lib::porcelain::commit::prepare_commit_bytes` | `grit_lib::commits::Commits::prepare_bytes` |  |
| `grit_lib::porcelain::commit::write_commit_object` | `grit_lib::commits::Commits::write_object` |  |
| `grit_lib::porcelain::hunk_select::WorktreeReverseApplyOptions` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::hunk_select::WorktreeReverseApplyOptions::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::hunk_select::WorktreeReverseApplyOptions::default` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::hunk_select::WorktreeReverseApplyOptions::dry_run` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::hunk_select::WorktreeReverseApplyOptions::eq` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::hunk_select::WorktreeReverseApplyOptions::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::hunk_select::diff_options_for_hunk_select` | `removed (use DiffOptions)` |  |
| `grit_lib::porcelain::hunk_select::list_unstaged_hunk_ids` | `grit_lib::index::IndexFile::list_unstaged_hunk_ids` |  |
| `grit_lib::porcelain::hunk_select::resolve_selection` | `grit_lib::index::IndexFile::resolve_hunk_selection` |  |
| `grit_lib::porcelain::hunk_select::restore_hunks` | `grit_lib::index::IndexFile::restore_hunks` |  |
| `grit_lib::porcelain::hunk_select::reverse_apply_patches_to_worktree` | `removed (use IndexFile::restore_hunks)` |  |
| `grit_lib::porcelain::hunk_select::stage_hunks` | `grit_lib::index::IndexFile::stage_hunks` |  |
| `grit_lib::porcelain::hunk_select::unstaged_file_diffs` | `grit_lib::index::IndexFile::unstaged_file_diffs` |  |
| `grit_lib::porcelain::index_mode::set_stage0_file_mode` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::paths::move_path` | `grit_lib::repo_handles::Checkout::move_path` |  |
| `grit_lib::porcelain::paths::move_paths` | `grit_lib::repo_handles::Checkout::move_paths` |  |
| `grit_lib::porcelain::paths::remove_paths` | `grit_lib::repo_handles::Checkout::remove_paths` |  |
| `grit_lib::porcelain::pathspec_match::ensure_pathspec_matches_known_in_repository` | `grit_lib::index::IndexFile::ensure_pathspec_matches_known` |  |
| `grit_lib::porcelain::pathspec_match::pathspec_matches_known_in_repository` | `grit_lib::index::IndexFile::pathspec_matches_known` |  |
| `grit_lib::porcelain::quote_path::quote_c_style_bytes` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::reset::preview_reset` | `grit_lib::repo_handles::Checkout::preview_reset` |  |
| `grit_lib::porcelain::reset::reset_to_commit` | `grit_lib::repo_handles::Checkout::reset` |  |
| `grit_lib::porcelain::restore::conflict_style_from_config` | `grit_lib::repo_handles::Checkout::conflict_style` |  |
| `grit_lib::porcelain::restore::restore_paths` | `grit_lib::repo_handles::Checkout::restore` |  |
| `grit_lib::porcelain::revert::merge_commit_message_for_revert` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::revert::revert_mainline_extra_body` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::stage_tracked::replay_deferred_untracked_invalidations` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::stage_tracked::stage_tracked_modifications` | `grit_lib::index::IndexFile::stage_tracked_modifications` |  |
| `grit_lib::porcelain::stage_tracked::stage_tracked_modifications_in_index` | `grit_lib::index::IndexFile::stage_tracked_modifications_on` |  |
| `grit_lib::porcelain::stage_tracked::stage_tracked_modifications_in_index_with_thresholds` | `grit_lib::index::IndexFile::stage_tracked_modifications_on` |  |
| `grit_lib::porcelain::stage_tracked::stage_tracked_modifications_with_thresholds` | `grit_lib::index::IndexFile::stage_tracked_modifications` |  |
| `grit_lib::porcelain::staging::stage_worktree_changes` | `grit_lib::index::IndexFile::stage_worktree_paths` |  |
| `grit_lib::porcelain::status::StatusModel::index_sparse_on_disk` | `removed (never read; inspect the index for sparse-directory entries)` |  |
| `grit_lib::porcelain::status::StatusModel::sparse_directory_prefixes` | `removed (never read; inspect the index for sparse-directory entries)` |  |
| `grit_lib::porcelain::status::collect_untracked_and_ignored` | `grit_lib::status::Status::untracked` |  |
| `grit_lib::porcelain::status::collect_untracked_and_ignored_with_cache` | `grit_lib::status::Status::untracked` |  |
| `grit_lib::porcelain::status::collect_untracked_and_ignored_with_rules_and_cancel` | `grit_lib::status::Status::untracked_with_meta` |  |
| `grit_lib::porcelain::status::dir_is_nested_submodule_worktree` | `removed (status internals)` |  |
| `grit_lib::porcelain::status::expand_untracked_for_staging` | `grit_lib::status::Status::expand_untracked_for_staging` |  |
| `grit_lib::porcelain::status::expand_untracked_for_staging_with_rules` | `grit_lib::status::Status::expand_untracked_for_staging` |  |
| `grit_lib::porcelain::status::normalize_status_conflicts` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::status::status` | `grit_lib::status::Status::run` |  |
| `grit_lib::porcelain::status::status_diff_entry_matches_pathspec` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::status::status_diff_entry_matches_pathspec_typed` | `grit_lib::status::Status::diff_entry_matches_pathspec` |  |
| `grit_lib::porcelain::status::status_renames_from_config` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::status::untracked_mode_from_config` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::switch::resolve_create_branch` | `grit_lib::repo_handles::Checkout::resolve_create_branch` |  |
| `grit_lib::porcelain::switch::resolve_revision_spec` | `grit_lib::repo_handles::Checkout::resolve_revision_spec` |  |
| `grit_lib::porcelain::switch::resolve_switch_target` | `grit_lib::repo_handles::Checkout::resolve_switch_target` |  |
| `grit_lib::porcelain::switch::switch_repository` | `grit_lib::repo_handles::Checkout::switch` |  |
| `grit_lib::porcelain::tag::TagInfo` | `grit_lib::porcelain::tag::TagSummary` | use TagSummary instead |
| `grit_lib::porcelain::tag::create_tag` | `grit_lib::repo_handles::Tags::create` |  |
| `grit_lib::porcelain::tag::creator_date` | `grit_lib::repo_handles::Tags::creator_date` |  |
| `grit_lib::porcelain::tag::delete_tag` | `grit_lib::repo_handles::Tags::delete` |  |
| `grit_lib::porcelain::tag::list_tags` | `grit_lib::repo_handles::Tags::list` |  |
| `grit_lib::porcelain::tag::list_tags_with_detail` | `grit_lib::repo_handles::Tags::list` |  |
| `grit_lib::porcelain::tag::normalize_tag_message` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::tag::strip_comments` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::tag::tag_ref_metadata` | `grit_lib::repo_handles::Tags::ref_metadata` |  |
| `grit_lib::porcelain::tag::verify_tag_by_name` | `grit_lib::repo_handles::Tags::verify` |  |
| `grit_lib::porcelain::workspace_snapshot::capture_workspace_snapshot` | `grit_lib::repo_handles::RepositoryWorkspaceSnapshot::capture` |  |
| `grit_lib::porcelain::workspace_snapshot::pin_workspace_snapshot` | `grit_lib::repo_handles::RepositoryWorkspaceSnapshot::pin` |  |
| `grit_lib::porcelain::workspace_snapshot::restore_workspace_snapshot` | `grit_lib::repo_handles::RepositoryWorkspaceSnapshot::restore` |  |
| `grit_lib::porcelain::workspace_snapshot::unpin_workspace_snapshot` | `grit_lib::repo_handles::RepositoryWorkspaceSnapshot::unpin` |  |
| `grit_lib::porcelain::workspace_snapshot::workspace_snapshot_pin_ref_name` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::worktree_guard::TreeSwitchPlan` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::worktree_guard::TreeSwitchPlan::tree_changes` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::worktree_guard::TreeSwitchPlan::untracked` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::worktree_guard::WorktreeSnapshot` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::worktree_guard::WorktreeSnapshot::head_tree` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::porcelain::worktree_guard::WorktreeSnapshot::index` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::prelude::InitOptions::environment` | `grit_lib::config::environment::RepositoryOptions::environment` |  |
| `grit_lib::prelude::MidxError::clone` | `grit_lib::prelude::MidxError (unchanged; the snapshot lists this member under grit_lib::error::MidxError)` |  |
| `grit_lib::prelude::MidxError::eq` | `grit_lib::prelude::MidxError (unchanged; the snapshot lists this member under grit_lib::error::MidxError)` |  |
| `grit_lib::prelude::MidxError::fmt` | `grit_lib::prelude::MidxError (unchanged; the snapshot lists this member under grit_lib::error::MidxError)` |  |
| `grit_lib::prelude::Odb::bulk_stage_write_options` | `removed (crate-internal in 0.6: staging-only policy; build WriteOptions with its with_* setters)` |  |
| `grit_lib::progress::Cancelled` | `removed (crate-internal in 0.6: cancellation surfaces as grit_lib::error::Error::Cancelled)` |  |
| `grit_lib::progress::Cancelled::clone` | `removed (crate-internal in 0.6: cancellation surfaces as grit_lib::error::Error::Cancelled)` |  |
| `grit_lib::progress::Cancelled::eq` | `removed (crate-internal in 0.6: cancellation surfaces as grit_lib::error::Error::Cancelled)` |  |
| `grit_lib::progress::Cancelled::fmt` | `removed (crate-internal in 0.6: cancellation surfaces as grit_lib::error::Error::Cancelled)` |  |
| `grit_lib::refs::branch_tracking::apply_push_remote_tracking_updates` | `grit_lib::repo_handles::Branches::apply_push_remote_tracking_updates` |  |
| `grit_lib::refs::branch_tracking::compare_with_target_optional` | `grit_lib::repo_handles::Branches::compare_with_target` |  |
| `grit_lib::refs::branch_tracking::list_branches` | `grit_lib::repo_handles::Branches::list` |  |
| `grit_lib::refs::branch_tracking::status_integration_hint` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::refs::branch_tracking::upstream_status` | `grit_lib::repo_handles::Branches::upstream_status` |  |
| `grit_lib::refs::branch_tracking::upstream_tracking_full_ref` | `grit_lib::repo_handles::Branches::upstream_tracking_full_ref` |  |
| `grit_lib::refs::check_ref_format::collapse_slashes` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::refs::listing::pattern_matches_ls_remote_pattern` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::refs::listing::patterns_match_ls_remote` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::refs::query_reachability::ref_points_at_any` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::refs::reflog::MessageMatcher::clone` | `grit_lib::refs::reflog::MessageMatcher (unchanged; the snapshot lists this member under grit_lib::repo_handles::MessageMatcher)` |  |
| `grit_lib::refs::reflog::MessageMatcher::eq` | `grit_lib::refs::reflog::MessageMatcher (unchanged; the snapshot lists this member under grit_lib::repo_handles::MessageMatcher)` |  |
| `grit_lib::refs::reflog::MessageMatcher::fmt` | `grit_lib::refs::reflog::MessageMatcher (unchanged; the snapshot lists this member under grit_lib::repo_handles::MessageMatcher)` |  |
| `grit_lib::refs::reflog::MessageMatcher::matches` | `grit_lib::refs::reflog::MessageMatcher (unchanged; the snapshot lists this member under grit_lib::repo_handles::MessageMatcher)` |  |
| `grit_lib::refs::reflog::MessageMatcher::new` | `grit_lib::refs::reflog::MessageMatcher (unchanged; the snapshot lists this member under grit_lib::repo_handles::MessageMatcher)` |  |
| `grit_lib::refs::store::FilesRefStore::create_reflog_str` | `grit_lib::refs::store::FilesRefStore::create_reflog` |  |
| `grit_lib::refs::store::FilesRefStore::delete_reflog_str` | `grit_lib::refs::store::FilesRefStore::delete_reflog` |  |
| `grit_lib::refs::store::FilesRefStore::for_each_reflog_entry_str` | `grit_lib::refs::store::FilesRefStore::for_each_reflog_entry` |  |
| `grit_lib::refs::store::FilesRefStore::read_raw_str` | `grit_lib::refs::store::FilesRefStore::read_raw` |  |
| `grit_lib::refs::store::FilesRefStore::reflog_exists_str` | `grit_lib::refs::store::FilesRefStore::reflog_exists` |  |
| `grit_lib::refs::store::FilesRefStore::replace_reflog_str` | `grit_lib::refs::store::FilesRefStore::replace_reflog` |  |
| `grit_lib::refs::store::FilesRefStore::resolve_str` | `grit_lib::refs::store::FilesRefStore::resolve` |  |
| `grit_lib::refs::store::FilesRefStore::rewrite_reflog_str` | `grit_lib::refs::store::FilesRefStore::rewrite_reflog` |  |
| `grit_lib::refs::store::MemoryRefStore::create_reflog_str` | `grit_lib::refs::store::MemoryRefStore::create_reflog` |  |
| `grit_lib::refs::store::MemoryRefStore::delete_reflog_str` | `grit_lib::refs::store::MemoryRefStore::delete_reflog` |  |
| `grit_lib::refs::store::MemoryRefStore::for_each_reflog_entry_str` | `grit_lib::refs::store::MemoryRefStore::for_each_reflog_entry` |  |
| `grit_lib::refs::store::MemoryRefStore::read_raw_str` | `grit_lib::refs::store::MemoryRefStore::read_raw` |  |
| `grit_lib::refs::store::MemoryRefStore::reflog_exists_str` | `grit_lib::refs::store::MemoryRefStore::reflog_exists` |  |
| `grit_lib::refs::store::MemoryRefStore::replace_reflog_str` | `grit_lib::refs::store::MemoryRefStore::replace_reflog` |  |
| `grit_lib::refs::store::MemoryRefStore::resolve_str` | `grit_lib::refs::store::MemoryRefStore::resolve` |  |
| `grit_lib::refs::store::MemoryRefStore::rewrite_reflog_str` | `grit_lib::refs::store::MemoryRefStore::rewrite_reflog` |  |
| `grit_lib::refs::store::RefName::from_trusted` | `grit_lib::refs::store::RefName::new` |  |
| `grit_lib::refs::store::RefNameRef::from_trusted` | `grit_lib::refs::store::RefNameRef::new` |  |
| `grit_lib::refs::store::RefStore::create_reflog_str` | `grit_lib::refs::store::RefStore::create_reflog` |  |
| `grit_lib::refs::store::RefStore::delete_reflog_str` | `grit_lib::refs::store::RefStore::delete_reflog` |  |
| `grit_lib::refs::store::RefStore::for_each_reflog_entry_str` | `grit_lib::refs::store::RefStore::for_each_reflog_entry` |  |
| `grit_lib::refs::store::RefStore::read_raw_str` | `grit_lib::refs::store::RefStore::read_raw` |  |
| `grit_lib::refs::store::RefStore::reflog_exists_str` | `grit_lib::refs::store::RefStore::reflog_exists` |  |
| `grit_lib::refs::store::RefStore::replace_reflog_str` | `grit_lib::refs::store::RefStore::replace_reflog` |  |
| `grit_lib::refs::store::RefStore::resolve_str` | `grit_lib::refs::store::RefStore::resolve` |  |
| `grit_lib::refs::store::RefStore::rewrite_reflog_str` | `grit_lib::refs::store::RefStore::rewrite_reflog` |  |
| `grit_lib::refs::store::ReftableRefStore::create_reflog_str` | `grit_lib::refs::store::ReftableRefStore::create_reflog` |  |
| `grit_lib::refs::store::ReftableRefStore::delete_reflog_str` | `grit_lib::refs::store::ReftableRefStore::delete_reflog` |  |
| `grit_lib::refs::store::ReftableRefStore::for_each_reflog_entry_str` | `grit_lib::refs::store::ReftableRefStore::for_each_reflog_entry` |  |
| `grit_lib::refs::store::ReftableRefStore::read_raw_str` | `grit_lib::refs::store::ReftableRefStore::read_raw` |  |
| `grit_lib::refs::store::ReftableRefStore::reflog_exists_str` | `grit_lib::refs::store::ReftableRefStore::reflog_exists` |  |
| `grit_lib::refs::store::ReftableRefStore::replace_reflog_str` | `grit_lib::refs::store::ReftableRefStore::replace_reflog` |  |
| `grit_lib::refs::store::ReftableRefStore::resolve_str` | `grit_lib::refs::store::ReftableRefStore::resolve` |  |
| `grit_lib::refs::store::ReftableRefStore::rewrite_reflog_str` | `grit_lib::refs::store::ReftableRefStore::rewrite_reflog` |  |
| `grit_lib::refs::store::backend::expected_matches` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::refs::store::backend::verify_create_casefold_against_existing` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::refs::store::backend::verify_create_casefold_conflicts` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::refs::store::backend::verify_create_casefold_same_batch` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::refs::store::backend::verify_create_conflicts` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::refs::store::paths::packed_refs_rel` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::remote::RemoteError::Snapshot` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::fetch` | `grit_lib::progress (the progress types moved there)` |  |
| `grit_lib::remote::fetch::FetchMilestone` | `grit_lib::progress::FetchMilestone` |  |
| `grit_lib::remote::fetch::FetchMilestone::Connected` | `grit_lib::progress::FetchMilestone::Connected` |  |
| `grit_lib::remote::fetch::FetchMilestone::PackRequested` | `grit_lib::progress::FetchMilestone::PackRequested` |  |
| `grit_lib::remote::fetch::FetchMilestone::clone` | `grit_lib::progress::FetchMilestone::clone` |  |
| `grit_lib::remote::fetch::FetchMilestone::eq` | `grit_lib::progress::FetchMilestone::eq` |  |
| `grit_lib::remote::fetch::FetchMilestone::fmt` | `grit_lib::progress::FetchMilestone::fmt` |  |
| `grit_lib::remote::fetch::NoProgress` | `grit_lib::progress::NullProgress` |  |
| `grit_lib::remote::fetch::NoProgress::finish` | `grit_lib::progress::ProgressSink::finish (NullProgress uses the provided no-op)` |  |
| `grit_lib::remote::fetch::NoProgress::inc` | `grit_lib::progress::ProgressSink::inc (NullProgress uses the provided no-op)` |  |
| `grit_lib::remote::fetch::NoProgress::message` | `grit_lib::progress::ProgressSink::message (NullProgress uses the provided no-op)` |  |
| `grit_lib::remote::fetch::NoProgress::milestone` | `grit_lib::progress::ProgressSink::milestone (NullProgress uses the provided no-op)` |  |
| `grit_lib::remote::fetch::NoProgress::received_objects` | `grit_lib::progress::ProgressSink::received_objects (NullProgress uses the provided no-op)` |  |
| `grit_lib::remote::fetch::NoProgress::remote_sideband_progress` | `grit_lib::progress::ProgressSink::remote_sideband_progress (NullProgress uses the provided no-op)` |  |
| `grit_lib::remote::fetch::NoProgress::resumable_transfer` | `grit_lib::progress::ProgressSink::resumable_transfer (NullProgress uses the provided no-op)` |  |
| `grit_lib::remote::fetch::NoProgress::set` | `grit_lib::progress::ProgressSink::set (NullProgress uses the provided no-op)` |  |
| `grit_lib::remote::fetch::NoProgress::start` | `grit_lib::progress::ProgressSink::start (NullProgress uses the provided no-op)` |  |
| `grit_lib::remote::fetch::NoProgress::start_with_unit` | `grit_lib::progress::ProgressSink::start_with_unit (NullProgress uses the provided no-op)` |  |
| `grit_lib::remote::fetch::NoProgress::wants_received_objects` | `grit_lib::progress::ProgressSink::wants_received_objects (NullProgress uses the provided no-op)` |  |
| `grit_lib::remote::fetch::Progress` | `grit_lib::progress::ProgressSink` |  |
| `grit_lib::remote::fetch::Progress::message` | `grit_lib::progress::ProgressSink::message` |  |
| `grit_lib::remote::fetch::Progress::milestone` | `grit_lib::progress::ProgressSink::milestone` |  |
| `grit_lib::remote::fetch::Progress::received_objects` | `grit_lib::progress::ProgressSink::received_objects` |  |
| `grit_lib::remote::fetch::Progress::remote_sideband_progress` | `grit_lib::progress::ProgressSink::remote_sideband_progress` |  |
| `grit_lib::remote::fetch::Progress::resumable_transfer` | `grit_lib::progress::ProgressSink::resumable_transfer` |  |
| `grit_lib::remote::fetch::Progress::wants_received_objects` | `grit_lib::progress::ProgressSink::wants_received_objects` |  |
| `grit_lib::remote::github_auth` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceAuthorization` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceAuthorization::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceAuthorization::device_code` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceAuthorization::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceAuthorization::expires_in` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceAuthorization::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceAuthorization::interval` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceAuthorization::user_code` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceAuthorization::verification_uri` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::AccessDenied` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::DeviceCodeRejected` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::DeviceCodeRejected::code` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::Expired` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::Http` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::Http::source` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::Http::step` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::MissingField` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::TimedOut` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::TokenRejected` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::TokenRejected::code` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::UnexpectedResponse` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowError::source` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowStep` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowStep::PollToken` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowStep::RequestDeviceCode` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowStep::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowStep::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::DeviceFlowStep::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::GITHUB_HOST` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::PollClock` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::PollClock::now` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::PollClock::sleep` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::PollStatus` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::PollStatus::Authorized` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::PollStatus::Pending` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::PollStatus::SlowDown` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::PollStatus::SlowDown::interval` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::PollStatus::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::PollStatus::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::PollStatus::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::SystemPollClock` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::SystemPollClock::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::SystemPollClock::default` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::SystemPollClock::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::SystemPollClock::now` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::SystemPollClock::sleep` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::TOKEN_USERNAME` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::github_token_credential` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::github_auth::is_github_https_url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::AUTHORIZE_PATH` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::IDENTITY_PATH` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LOGIN_PATH` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LOGIN_POLL_PATH` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginGrant` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginGrant::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginGrant::email` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginGrant::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginGrant::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginGrant::token` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginPoll` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginPoll::Authorized` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginPoll::Denied` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginPoll::Expired` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginPoll::Pending` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginPoll::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginPoll::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginPoll::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginPollRequest` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginPollRequest::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginPollRequest::device_code` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginPollRequest::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginPollRequest::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginStart` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginStart::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginStart::device_code` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginStart::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginStart::expires_in` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginStart::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginStart::interval` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::LoginStart::user_code` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerAuthError` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerAuthError::Http` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerAuthError::InvalidUrl` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerAuthError::InvalidUrl::url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerAuthError::LoginDenied` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerAuthError::LoginExpired` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerAuthError::NotGritServer` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerAuthError::NotGritServer::url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerAuthError::TokenRejected` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerAuthError::UnsupportedScheme` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerAuthError::UnsupportedScheme::scheme` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerAuthError::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerIdentity` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerIdentity::admin` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerIdentity::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerIdentity::email` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerIdentity::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerIdentity::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerUrl` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerUrl::authorize_url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerUrl::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerUrl::credential` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerUrl::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerUrl::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerUrl::host` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerUrl::identity_url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerUrl::parse` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerUrl::protocol` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::ServerUrl::root_url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::TokenCredentialProvider` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::TokenCredentialProvider::approve` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::TokenCredentialProvider::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::TokenCredentialProvider::fill` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::TokenCredentialProvider::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::TokenCredentialProvider::new` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::TokenCredentialProvider::reject` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::credential_for_url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_auth::fetch_identity` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::DEFAULT_LINK_DAYS` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkOptions` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkOptions::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkOptions::default` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkOptions::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkOptions::expires_days` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkOptions::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkOptions::uses` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkUses` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkUses::Count` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkUses::Unlimited` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkUses::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkUses::default` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkUses::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::LinkUses::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::MAX_LINK_DAYS` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::NewShareLink` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::NewShareLink::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::NewShareLink::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::NewShareLink::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::NewShareLink::info` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::NewShareLink::url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SHARED_REFS` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptReply` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptReply::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptReply::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptReply::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptReply::message` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptReply::project` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptReply::share` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptReply::status` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptReply::url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptRequest` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptRequest::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptRequest::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptRequest::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptRequest::link` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptStatus` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptStatus::Accepted` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptStatus::AlreadyMember` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptStatus::Refused` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptStatus::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptStatus::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareAcceptStatus::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareIntegration` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareIntegration::at` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareIntegration::by` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareIntegration::changes` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareIntegration::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareIntegration::commit` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareIntegration::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareIntegration::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareIntegration::into` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareIntegration::pull` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareIntegration::target_branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareIntegration::url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareLinkInfo` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareLinkInfo::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareLinkInfo::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareLinkInfo::expires_at` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareLinkInfo::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareLinkInfo::for_user` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareLinkInfo::id` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareLinkInfo::uses_left` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareLinkInfo::view` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMember` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMember::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMember::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMember::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMember::head` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMember::project` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMember::sharer` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMember::user` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMember::view` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMember::you` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMode` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMode::Full` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMode::Snapshot` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMode::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMode::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareMode::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareReply` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareReply::added` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareReply::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareReply::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareReply::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareReply::link` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareReply::project` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareReply::refused` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareReply::removed` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareReply::shares` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::Leave` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::Leave::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::List` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::List::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::Reshare` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::Reshare::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::RevokeLink` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::RevokeLink::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::RevokeLink::link` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::Share` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::Share::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::Share::link` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::Share::users` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::Share::view` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::Unshare` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::Unshare::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::Unshare::users` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareRequest::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareState` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareState::Active` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareState::Ended` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareState::Integrated` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareState::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareState::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareState::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareView` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareView::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareView::default` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareView::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareView::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::ShareView::paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::base_branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::integrated` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::invited` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::links` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::members` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::mode` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::origin` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::sharer` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::state` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::SharedBranch::url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::accept` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::share` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_share::share_link` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply::head` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply::message` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply::previous` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply::project` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply::pull` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply::status` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply::target_branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply::unshared` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply::url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchReply::waiting` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchRequest` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchRequest::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchRequest::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchRequest::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchRequest::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchRequest::without` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchStatus` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchStatus::AlreadyIntegrated` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchStatus::Merged` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchStatus::Refused` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchStatus::Started` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchStatus::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchStatus::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::IntegrateBranchStatus::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::Space` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::Space::can_integrate` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::Space::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::Space::created` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::Space::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::Space::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::Space::followed` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::Space::project` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::Space::shared` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::Space::target_branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::Space::upstream` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::Space::upstream_url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::Space::url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::WaitingHead` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::WaitingHead::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::WaitingHead::commits` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::WaitingHead::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::WaitingHead::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::WaitingHead::head` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::WaitingHead::user` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::fetch_space` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::hosted_project` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::grit_server_space::integrate_branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::partial_clone::ObjectFilterSpec::from_blobs_cli` | `grit_lib::remote::partial_clone::ObjectFilterSpec::parse (pass blob:none or blob:limit=<size>; the --blobs grammar moved to grit-cli)` |  |
| `grit_lib::remote::snapshot_checkout` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchInfo` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchInfo::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchInfo::commits` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchInfo::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchInfo::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchInfo::made` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchInfo::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchInfo::projected` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchInfo::reused` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchInfo::tip` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::ahead_behind` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::check` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::gave_change_ids` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::previous` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::projected` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::result` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::switched` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::tip` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::upstream_ref` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefresh::was_on` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult::AutostashConflict` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult::Conflicts` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult::Conflicts::conflicts` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult::Created` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult::FastForwarded` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult::Rebased` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult::Rebased::own` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult::Stopped` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult::Stopped::conflicts` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult::UpToDate` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRefreshResult::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRequest` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRequest::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRequest::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRequest::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchRequest::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchSet` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchSet::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchSet::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchSet::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchSet::previous` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchSet::rule` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::BranchSet::status` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CHECKOUT_API` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinBranch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinBranch::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinBranch::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinBranch::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinBranch::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinBranch::raw` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::CaseConflict` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::CaseConflict::existing` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::Conflict` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::Conflict::commit` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::Conflict::outside_paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::Conflict::path` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::Diverged` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::Diverged::tip` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::InvalidName` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::InvalidTip` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::MergeConflict` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::MergeConflict::commit` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::MergeConflict::paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::NotOnSnapshot` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::NotOnSnapshot::commit` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::NotPushed` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::NotPushed::out_ref` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::TargetBranch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::TargetBranch::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRefusal::kind` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRequest` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRequest::branches` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRequest::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRequest::default` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRequest::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRequest::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRequest::force` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResponse` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResponse::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResponse::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResponse::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResponse::results` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResult` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResult::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResult::commits` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResult::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResult::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResult::grafted` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResult::message` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResult::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResult::previous` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResult::reason` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResult::rule` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinResult::status` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRule` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRule::FastForward` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRule::Forced` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRule::KeepsEveryCommit` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRule::OwnLastSet` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRule::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRule::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRule::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinRule::kind` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinStatus` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinStatus::Created` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinStatus::Refused` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinStatus::Unchanged` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinStatus::Updated` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinStatus::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinStatus::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinStatus::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinUpdate::force` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinUpdate::grafted` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinUpdate::message` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinUpdate::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinUpdate::paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinUpdate::set_last` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinUpdate::targets` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckinUpdate::who` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::BranchMoved` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::BranchMoved::expected` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::BranchMoved::got` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::BranchMoved::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::DamagedRecord` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::DamagedRecord::detail` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::DamagedRecord::id` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::DamagedRecord::path` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::DestinationNotEmpty` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::InvalidBranchName` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::InvalidBranchName::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::InvalidPath` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::InvalidPath::path` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::InvalidPath::reason` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::InvalidUrl` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::InvalidUrl::url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::Io` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::Mismatch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::Mismatch::expected` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::Mismatch::got` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::MissingPath` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::MissingPath::base` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::MissingPath::path` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::NotOffered` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::NotOffered::endpoint` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::NotOffered::url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::OperationInProgress` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::PromisedBlobs` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::PromisedBlobs::count` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::PromisedBlobs::oid` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::PromisedBlobsNotFetched` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::PromisedBlobsNotFetched::count` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::PromisedBlobsNotFetched::oid` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::PromisedBlobsNotFetched::source` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::Protocol` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::Protocol::detail` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::Protocol::url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::RefKeptMoving` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::RefKeptMoving::refname` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::Server` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::Server::message` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::Server::status` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::Server::url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::SnapshotMoved` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::SnapshotMoved::expected` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::SnapshotMoved::got` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::StillSwitched` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::StillSwitched::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::StillSwitched::failed` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::UnrelatedBranch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::UnrelatedBranch::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::WorkBranchTaken` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::WorkBranchTaken::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::from` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutError::source` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutErrorBody` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutErrorBody::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutErrorBody::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutErrorBody::error` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutErrorBody::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::base` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::bundle_bytes` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::bytes` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::files` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::id` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::root` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::root_object` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::roots` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::tree` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutInfo::work` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::id` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::landed` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::last` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::read` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::remote` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::roots` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::upstream_ref` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutMarker::write` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRecord` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRecord::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRecord::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRecord::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRecord::id` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRecord::load` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRecord::path` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRecord::save` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRequest` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRequest::client` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRequest::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRequest::default` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRequest::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRequest::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRequest::paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutRequest::work` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutServerInfo` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutServerInfo::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutServerInfo::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutServerInfo::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutServerInfo::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutServerInfo::head` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutServerInfo::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutState` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutState::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutState::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutState::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutState::info` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutState::tip` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutStore` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutStore::at` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutStore::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutStore::dir` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutStore::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutStore::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutStore::for_repository` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutStore::graft_log` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutStore::has_checkouts` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutStore::record` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutStore::reserve_work_branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutUrl` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutUrl::api` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutUrl::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutUrl::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutUrl::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutUrl::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutUrl::parse` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::CheckoutUrl::repo_url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::GraftLog` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::GraftLog::at` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::GraftLog::dir` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::GraftLog::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::GraftLog::grafted` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::GraftLog::raws` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::GraftLog::record` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Grafted` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Grafted::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Grafted::commits` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Grafted::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Grafted::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Grafted::tip` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Ident` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Ident::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Ident::email` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Ident::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Ident::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Ident::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Ident::signature` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateRequest` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateRequest::author` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateRequest::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateRequest::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateRequest::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateRequest::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateResponse` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateResponse::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateResponse::commits` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateResponse::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateResponse::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateResponse::head` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateResponse::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateResponse::previous` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateResponse::status` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateResponse::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateStatus` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateStatus::AlreadyIntegrated` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateStatus::Merged` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateStatus::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateStatus::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::IntegrateStatus::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Integration` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Integration::change` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Integration::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Integration::commits` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Integration::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Integration::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Integration::status` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Landing` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Landing::Elsewhere` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Landing::Elsewhere::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Landing::Here` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Landing::Here::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Landing::Here::tip` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Landing::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Landing::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Landing::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Landing::move_off` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::MaterializeRequest::bundle` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::MaterializeRequest::dest` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::MaterializeRequest::info` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::MaterializeRequest::repo_url` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::MaterializeRequest::work` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Materialized` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Materialized::files` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Materialized::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Materialized::repo` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Materialized::work` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ProjectError` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ProjectError::BeforeFirstSnapshot` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ProjectError::BeforeFirstSnapshot::commit` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ProjectError::InvalidName` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ProjectError::NoSuchBranch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ProjectError::OnTarget` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ProjectError::TargetBranch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ProjectError::TargetBranch::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ProjectError::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ProjectError::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ProjectError::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ProjectError::kind` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::behind` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::changes` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::current` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::followed` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::gave_change_ids` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::head` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::moved` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::previous` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::transfer` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshOutcome::upstream_ref` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshedHead` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshedHead::Branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshedHead::Branch::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshedHead::Branch::pull` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshedHead::Detached` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshedHead::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshedHead::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::RefreshedHead::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ReservedName` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ReservedName::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ReservedName::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ReservedName::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ReservedName::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::ReservedName::next` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SLICES_PATH` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Slice` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Slice::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Slice::description` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Slice::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Slice::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Slice::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Slice::paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceChange` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceChange::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceChange::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceChange::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceChange::head` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceChange::previous` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceChange::slice` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceChange::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceDeleteRequest` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceDeleteRequest::author` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceDeleteRequest::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceDeleteRequest::default` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceDeleteRequest::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceDeleteRequest::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceEdit` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceEdit::Change` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceEdit::Create` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceEdit::Delete` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceEdit::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceEdit::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceEdit::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceRequest` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceRequest::author` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceRequest::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceRequest::create` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceRequest::default` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceRequest::description` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceRequest::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceRequest::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SliceRequest::paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesEdited` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesEdited::change` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesEdited::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesEdited::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesEdited::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesEdited::message` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesEdited::slice` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesResponse` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesResponse::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesResponse::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesResponse::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesResponse::head` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesResponse::slices` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SlicesResponse::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Snapshot` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Snapshot::base` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Snapshot::bytes` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Snapshot::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Snapshot::commit` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Snapshot::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Snapshot::files` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Snapshot::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Snapshot::object` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::Snapshot::tree` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SnapshotRoot` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SnapshotRoot::base` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SnapshotRoot::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SnapshotRoot::commit` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SnapshotRoot::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::SnapshotRoot::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::StoredCheckout` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::StoredCheckout::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::StoredCheckout::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::StoredCheckout::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::StoredCheckout::info` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::StoredCheckout::last_set` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::StoredCheckout::new` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::StoredCheckout::record_set` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::StoredCheckout::set_last` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetChange` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetChange::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetChange::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetChange::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetChange::head` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetChange::previous` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetChange::worktree_moved` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::for_repository` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::guards` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::message` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::new` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::post_receive` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::post_update` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::pre_receive` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::pre_receive_ctx` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::update` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetGuard::update_ctx` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::Conflict` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::Conflict::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::Conflict::paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::Conflict::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::InvalidName` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::InvalidName::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::InvalidSliceName` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::InvalidSliceName::slice` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::IsTarget` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::IsTarget::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::MissingPaths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::MissingPaths::paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::MissingPaths::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::Moved` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::Moved::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::NoSuchBranch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::NoSuchBranch::name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::NoSuchSlice` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::NoSuchSlice::slice` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::SliceExists` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::SliceExists::slice` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::SliceWithoutPaths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::SliceWithoutPaths::slice` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::Unborn` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::Unborn::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::Unrelated` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::Unrelated::branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::Unrelated::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::WorktreeBlocked` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::WorktreeBlocked::paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::WorktreeBlocked::target` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::TargetRefusal::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::WorkBranchRequest` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::WorkBranchRequest::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::WorkBranchRequest::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::WorkBranchRequest::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::WorkBranchRequest::work` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::WorkBranchResponse` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::WorkBranchResponse::clone` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::WorkBranchResponse::eq` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::WorkBranchResponse::fmt` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::WorkBranchResponse::work` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::materialize` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::normalize_paths` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::out_ref` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::same_branch_name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::suggest_work_branch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::target_ref` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::upstream_ref` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::valid_branch_name` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::snapshot_checkout::valid_checkout_id` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::default` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::from_config` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::get` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::get_following_redirects` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::git_protocol_header` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::low_speed_stall_window` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::new` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::post` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::post_into_reader` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::post_streaming` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::reset_auth_after_redirect_rebase` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::send` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::set_operation_cancel` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::smart_http_enabled` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::with_credential_provider` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::with_credentials` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::with_git_protocol` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::remote::transport::http::ureq_client::UreqHttpClient::with_user_agent` | `grit_lib::remote::transport::http::ureq_client::UreqHttpClient (unchanged; the snapshot lists this member under grit_lib::remote::http_client::UreqHttpClient)` |  |
| `grit_lib::repo::InitOptions::environment` | `grit_lib::config::environment::RepositoryOptions::environment` |  |
| `grit_lib::repo::InitOptions::with_environment` | `grit_lib::repo::InitOptions::with_repository_options` | use `InitOptions::with_repository_options(RepositoryOptions::with_environment(env))` |
| `grit_lib::repo::Repository::snapshot_checkouts` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::repo::early_config_ignore_repo_reason_for_text` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::repo::worktree_config_enabled_for_text` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::repo_handles::configured_remote_names` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::repo_handles::configured_remote_names_in_config_order` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::repo_handles::configured_remotes` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::repo_handles::remote_skip_fetch_all` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::revwalk::history::DEFAULT_ABSORB_STACK_LIMIT` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::revwalk::history::commit_message_subject_line` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::revwalk::history::resolve_rebase_use_fork_point` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::revwalk::rev_list::CommitExtent::clone` | `grit_lib::revwalk::rev_list::CommitExtent (unchanged; the snapshot lists this member under grit_lib::revwalk::CommitExtent)` |  |
| `grit_lib::revwalk::rev_list::CommitExtent::default` | `grit_lib::revwalk::rev_list::CommitExtent (unchanged; the snapshot lists this member under grit_lib::revwalk::CommitExtent)` |  |
| `grit_lib::revwalk::rev_list::CommitExtent::eq` | `grit_lib::revwalk::rev_list::CommitExtent (unchanged; the snapshot lists this member under grit_lib::revwalk::CommitExtent)` |  |
| `grit_lib::revwalk::rev_list::CommitExtent::fmt` | `grit_lib::revwalk::rev_list::CommitExtent (unchanged; the snapshot lists this member under grit_lib::revwalk::CommitExtent)` |  |
| `grit_lib::revwalk::rev_list::shallow_boundary_oids` | `grit_lib::revwalk::handle::RevWalk::shallow_boundary_oids` |  |
| `grit_lib::revwalk::rev_list::url_encode_object_filter_subspec` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::revwalk::rev_parse::IndexPathEntry` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::revwalk::rev_parse::IndexPathEntry::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::revwalk::rev_parse::IndexPathEntry::eq` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::revwalk::rev_parse::IndexPathEntry::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::revwalk::rev_parse::IndexPathEntry::mode` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::revwalk::rev_parse::IndexPathEntry::oid` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::revwalk::rev_parse::IndexPathEntry::path` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::revwalk::rev_parse::load_graft_parents` | `removed (crate-internal graft helpers)` |  |
| `grit_lib::revwalk::rev_parse::superproject_work_tree_from_nested_git_modules` | `removed (crate-internal submodule helper)` |  |
| `grit_lib::snapshot_checkout::refresh::BranchOnOldSnapshot` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::snapshot_checkout::refresh::FollowedBranch` | `removed from the default build (unstable-hosting feature only, outside semver)` |  |
| `grit_lib::stash::FlatTreeEntry]` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::stash::add_stage_entry` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::stash::remove_empty_dirs` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::stash::write_regular_file_replacing_symlink` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::tree_sha256::path_matches_glob_bytes` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::BranchWorktreeCheckout` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::BranchWorktreeCheckout::admin_dir` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::BranchWorktreeCheckout::branch` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::BranchWorktreeCheckout::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::BranchWorktreeCheckout::eq` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::BranchWorktreeCheckout::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::BranchWorktreeCheckout::worktree_path` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::LockWorktreeOptions::clone` | `grit_lib::worktree::LockWorktreeOptions (unchanged; the snapshot lists this member under grit_lib::repo_handles::LockWorktreeOptions)` |  |
| `grit_lib::worktree::LockWorktreeOptions::default` | `grit_lib::worktree::LockWorktreeOptions (unchanged; the snapshot lists this member under grit_lib::repo_handles::LockWorktreeOptions)` |  |
| `grit_lib::worktree::LockWorktreeOptions::fmt` | `grit_lib::worktree::LockWorktreeOptions (unchanged; the snapshot lists this member under grit_lib::repo_handles::LockWorktreeOptions)` |  |
| `grit_lib::worktree::add_linked_worktree` | `grit_lib::repo_handles::RepositoryWorktrees::add` |  |
| `grit_lib::worktree::add_linked_worktree_with_cancel` | `grit_lib::repo_handles::RepositoryWorktrees::add` |  |
| `grit_lib::worktree::allocate_worktree_admin_dir` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::common_git_dir` | `grit_lib::repo::Repository::common_git_dir` |  |
| `grit_lib::worktree::copy_filtered_worktree_config` | `removed (crate-internal worktree setup)` |  |
| `grit_lib::worktree::crlf::AttrRule` | `grit_lib::worktree::attributes::AttrRule` |  |
| `grit_lib::worktree::crlf::AttrRule::attr_base` | `grit_lib::worktree::attributes::AttrRule::attr_base` |  |
| `grit_lib::worktree::crlf::AttrRule::attrs` | `grit_lib::worktree::attributes::AttrRule::attrs` |  |
| `grit_lib::worktree::crlf::AttrRule::line` | `grit_lib::worktree::attributes::AttrRule::line` |  |
| `grit_lib::worktree::crlf::AttrRule::nowildcardlen` | `grit_lib::worktree::attributes::AttrRule::nowildcardlen` |  |
| `grit_lib::worktree::crlf::AttrRule::pattern` | `grit_lib::worktree::attributes::AttrRule::pattern` |  |
| `grit_lib::worktree::crlf::AttrRule::pattern_flags` | `grit_lib::worktree::attributes::AttrRule::pattern_flags` |  |
| `grit_lib::worktree::crlf::AttrRule::skip` | `grit_lib::worktree::attributes::AttrRule::skip` |  |
| `grit_lib::worktree::crlf::ConversionConfig::from_config_with_runner` | `grit_lib::worktree::crlf::ConversionConfig::with_command_runner (chain it after from_config)` |  |
| `grit_lib::worktree::crlf::GitAttributes` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::crlf::WorkTreeEncodingError` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::crlf::WorkTreeEncodingError::UnsupportedEncoding` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::crlf::WorkTreeEncodingError::UnsupportedEncoding::label` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::crlf::WorkTreeEncodingError::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::crlf::WorkTreeEncodingError::eq` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::crlf::WorkTreeEncodingError::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::ensure_branch_not_checked_out_elsewhere` | `grit_lib::repo_handles::RepositoryWorktrees::ensure_branch_not_checked_out_elsewhere` |  |
| `grit_lib::worktree::ensure_branch_not_checked_out_in_any_worktree` | `grit_lib::repo_handles::RepositoryWorktrees::ensure_branch_not_checked_out_in_any_worktree` |  |
| `grit_lib::worktree::find_worktree_with_branch_checked_out` | `grit_lib::repo_handles::RepositoryWorktrees::find_with_branch_checked_out` |  |
| `grit_lib::worktree::fsmonitor::FsmonitorRefreshOptions` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::FsmonitorRefreshOptions::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::FsmonitorRefreshOptions::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::FsmonitorRefreshOptions::query_boundary` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::FsmonitorRefreshOptions::with_query_boundary` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::FsmonitorRefreshResult` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::FsmonitorRefreshResult::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::FsmonitorRefreshResult::eq` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::FsmonitorRefreshResult::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::FsmonitorRefreshResult::honor_valid_bits` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::FsmonitorRefreshResult::index_changed` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::entry_skips_worktree_stat` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::fsmonitor_enabled` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::git_style_windows_pipe_name_from_absolute_ipc` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::refresh_index` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::fsmonitor::v1_hook_token` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::is_bare_repository` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::list_worktrees` | `grit_lib::repo_handles::RepositoryWorktrees::list` |  |
| `grit_lib::worktree::move_linked_worktree` | `grit_lib::repo_handles::RepositoryWorktrees::move_linked` |  |
| `grit_lib::worktree::pathspec::PathspecMatchContext` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::pathspec::PathspecMatchContext::clone` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::pathspec::PathspecMatchContext::default` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::pathspec::PathspecMatchContext::eq` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::pathspec::PathspecMatchContext::fmt` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::pathspec::PathspecMatchContext::globals` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::pathspec::PathspecMatchContext::is_directory` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::pathspec::PathspecMatchContext::is_git_submodule` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::pathspec::PathspecMatchContext::precompose_paths` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::pathspec::pathspecs_allow_bloom` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::prune_linked_worktrees` | `grit_lib::repo_handles::RepositoryWorktrees::prune` |  |
| `grit_lib::worktree::read_worktree_path` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::registered_worktree_count` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::remove_linked_worktree` | `grit_lib::repo_handles::RepositoryWorktrees::remove` |  |
| `grit_lib::worktree::repair_worktrees` | `grit_lib::repo_handles::RepositoryWorktrees::repair` |  |
| `grit_lib::worktree::sanitize_worktree_id_component` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |
| `grit_lib::worktree::worktree_admin_dir` | `grit_lib::repo_handles::RepositoryWorktrees::admin_dir` |  |
| `grit_lib::worktree::worktree_path_basename` | `removed (crate-internal in 0.6: no callers outside grit-lib)` |  |

<!-- api-migration:end -->

# https://grit-scm.com/docs/library/network/index.md

# Network

> Remote dispatch, fetch, push, and ls-remote over every transport.

Network operations in grit-lib center on `Remote`: a typed URL (`RemoteUrl`), configured fetch refspecs, and one dispatcher for **fetch**, **push**, and **list refs**. Wire bytes still flow through the same fetch/push engines as before; `Remote` picks the transport from the URL scheme.

## Remote URL and config

| Scheme / form | `RemoteUrl` variant | Transport |
| --- | --- | --- |
| Path or `file://` | `Local` / `File` | in-process object copy ([`TransferEndpoint::Local`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/enum.TransferEndpoint.html#variant.Local)) |
| `git://` | `Git` | [`GitDaemonTransport`](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/struct.GitDaemonTransport.html) |
| `ssh://`, scp-style | `Ssh` | [`SshTransport`](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/struct.SshTransport.html) (repo [`CommandRunner`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/trait.CommandRunner.html)) |
| `http(s)://` | `Http` / `Https` | [`SmartHttpTransport`](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/http/struct.SmartHttpTransport.html) ([`TransferEndpoint::Http`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/enum.TransferEndpoint.html#variant.Http)) |

When you already hold the transport — a repository path on this machine, an open [`Connection`](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/trait.Connection.html), or a smart-HTTP URL with your own [`HttpClient`](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/http/trait.HttpClient.html) — fetch and push through [`RepositoryRemotes::fetch_from`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.fetch_from) and [`RepositoryRemotes::push_to`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.push_to) with a [`TransferEndpoint`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/enum.TransferEndpoint.html). They run the same engines as `fetch` and `push` (refspecs, tags, prune, shallow, the same outcomes) but skip URL resolution and the client-side `pre-push` hook.

Parse a literal URL with [`RemoteUrl::try_from`](https://docs.rs/grit-lib/latest/grit_lib/remote/enum.RemoteUrl.html). Load `remote.<name>.url`, optional `pushurl`, and `fetch` refspecs (default `+refs/heads/*:refs/remotes/<name>/*`) via [`Remote::from_config`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.Remote.html). Config applies `url.*.insteadOf` and `url.*.pushInsteadOf` rewrite rules the same way Git does.

Local paths resolve through [`resolve_local_remote_git_dir`](https://docs.rs/grit-lib/latest/grit_lib/remote/transport_path/fn.resolve_local_remote_git_dir.html) from the repository root, not the process cwd.

A local or `file://` fetch or push copies the same objects the wire protocol would: those reachable from the requested refs that the receiver lacks. Other branches, hidden refs, excluded tags and unreachable leftovers stay behind even when they share a pack with what was asked for. When a source pack holds only objects the transfer must send, grit hard-links it instead of rebuilding it, and it builds a pack for the rest. The send set comes from the source's reachability bitmap when it has one. The one exception is a clone from a plain path (not a `file://` URL): like `git clone --local`, it links the source's packfiles as they are, unreachable objects included ([`FetchOptions::link_source_objects`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOptions.html#structfield.link_source_objects)).

To turn a user's repository argument (a configured name, a URL, an scp-style `host:path`, or a path) into a `Remote`, call [`resolve_remote_argument`](https://docs.rs/grit-lib/latest/grit_lib/remote/fetch_request/fn.resolve_remote_argument.html). A configured name wins. A name with a config section but no URL fails with `RemoteError::NoUrl`, and anything else fails with [`RemoteError::UnknownRemote`](https://docs.rs/grit-lib/latest/grit_lib/remote/enum.RemoteError.html). `grit fetch`, `grit pull` and `grit remote refs` all resolve their argument this way.

## Managing remotes

[`repo.remotes().configured()`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.configured) lists every remote with a `remote.<name>.*` section, sorted by name, the same set `git remote` prints. Each [`ConfiguredRemote`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.ConfiguredRemote.html) carries its URL, or `None` when the section has no URL, plus raw `push_urls`, `fetch_refspecs`, and effective fetch/push URLs after `url.*.insteadOf` / `pushInsteadOf`. [`list()`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.list) returns only the names that have a URL.

[`repo.remotes().add(name, url)`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.add) writes `remote.<name>.url` and the default fetch refspec to the shared repository config (also from a linked worktree), then reloads the repository's config. Like `git remote add`, it refuses an existing remote (`RemoteError::RemoteExists`) and a name whose tracking refs `refs/remotes/<name>/…` would be invalid (`RemoteError::InvalidRemoteName`), and it stores the URL as given.

[`repo.remotes().set_url(name, url, kind, dry_run)`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.set_url) updates fetch or push URLs on an existing remote (`RemoteUrlKind::Fetch` or `Push`), returning [`UrlChange`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.UrlChange.html). Push replaces every `pushurl` with one value. Returns [`RemoteError::UnknownRemote`](https://docs.rs/grit-lib/latest/grit_lib/remote/enum.RemoteError.html#variant.UnknownRemote) when the section is missing.

[`repo.remotes().prune(name, dry_run, http_factory)`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.prune) deletes stale remote-tracking refs without fetching, using the same stale-ref rules as fetch prune. Returns the full ref names removed (or that would be removed when `dry_run` is true).

[`repo.remotes().set_head(name, mode, dry_run, http_factory)`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.set_head) sets or deletes `refs/remotes/<name>/HEAD` via [`SetHead`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/enum.SetHead.html) (`Auto`, `Branch`, or `Delete`).

[`repo.remotes().inspect(name, options, http_factory)`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.inspect) returns a [`RemoteSummary`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.RemoteSummary.html): fetch and push URLs, optional [`head_branch`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.RemoteSummary.html#structfield.head_branch), [`RemoteBranchState`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.RemoteBranchState.html) rows (`tracked`, `new`, or `stale`), and [`RemotePullBranch`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.RemotePullBranch.html) entries from `branch.*` config. With [`InspectOptions::query`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.InspectOptions.html#structfield.query) it lists refs on the remote (symrefs included) and compares them to local tracking refs; stale detection uses the same rules as fetch prune. Without a query, branch names come from `refs/remotes/<name>/…` and are all reported as tracked.

## list refs

`Remote::list_refs` takes `ListRefsOptions` (prefixes, heads, tags, symrefs, peel) and returns `RemoteRef` entries in `git ls-remote` order. On disk it scans the repository's refs directly; [`repo.remotes().ls_remote(remote, options, http_factory)`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.ls_remote) does the same with relative paths resolved from this repository. Over the wire it uses protocol v2 `ls-refs` when available, otherwise the v0/v1 ref advertisement.

With `peel` set, annotated tags come back as two entries, the tag and a `<tag>^{}` line holding the object it peels to: the first non-tag object, through any chain of tags of tags, as `git ls-remote` reports it. [`RemoteRef::peeled_tag`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.RemoteRef.html#method.peeled_tag) identifies those lines, and [`fold_peeled_refs`](https://docs.rs/grit-lib/latest/grit_lib/remote/fn.fold_peeled_refs.html) folds them into one [`PeeledRemoteRef`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.PeeledRemoteRef.html) per ref, with `peeled` set, keeping the listing order.

## Fetch and push

[`Remote::fetch`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.Remote.html) accepts [`FetchOptions`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOptions.html) and a [`ProgressSink`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html); fetch negotiates protocol v2 when the server supports it. Negotiation offers every local branch, remote-tracking ref, tag and `HEAD` as a starting point and walks local history only as far as each round needs: 16 `have`s first, then twice as many per round, stopping as soon as the server is ready to send the pack. An incremental fetch whose new commits build on local history reads only the newest local commits, not the whole history. Its [`FetchOutcome`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOutcome.html) holds one `RefUpdate` per matched ref, including the ones that were already up to date. For a report, [`reported_updates`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOutcome.html#method.reported_updates) keeps the refs that changed or were refused, [`changed_ref_count`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOutcome.html#method.changed_ref_count) counts the changed ones, and [`has_rejections`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOutcome.html#method.has_rejections) says whether any update was refused (`UpdateMode::is_rejected`). [`UpdateMode::kind`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/enum.UpdateMode.html#method.kind) folds each update's detailed mode into an [`UpdateKind`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/enum.UpdateKind.html) (new, fast-forward, forced, pruned, rejected or up to date) for display. `grit fetch` builds its output and exit code from these. [`Remote::push`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.Remote.html) uses [`PushRefSpec`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PushRefSpec.html) and returns [`PushOutcome`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PushOutcome.html); [`has_updates`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PushOutcome.html#method.has_updates) says whether any remote ref changed (or would, on a dry run) and [`has_rejections`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PushOutcome.html#method.has_rejections) whether any update was refused, which is how `grit push` decides its exit code. Before it sends anything, on every transport and for dry runs too, `Remote::push` runs the repository's `pre-push` hook through [`RepositoryHooks::run_pre_push`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryHooks.html#method.run_pre_push) with one [`PrePushRef`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/struct.PrePushRef.html) per update it would make; a hook that exits non-zero fails the push with `Error::Hook` and leaves the remote untouched. Set [`PushOptions::no_verify`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PushOptions.html#structfield.no_verify) to skip it. The lower-level [`RepositoryRemotes::push_to`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.push_to) never runs `pre-push`. A local or `file://` push (including `push_to` with [`TransferEndpoint::Local`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/enum.TransferEndpoint.html#variant.Local)) runs the remote repository's receive hooks (`pre-receive`, `update`, `post-receive`, `post-update`) the way [`ReceivePack`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePack.html) does, puts their output in [`PushOutcome::remote_messages`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.PushOutcome.html#structfield.remote_messages) and reports a declined update as `PushRefStatus::RemoteRejected`.

A push never holds its packfile in memory. [`write_pack_for_push`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_objects/fn.write_pack_for_push.html) streams the pack into the connection (ssh, `git://`) or, when the server advertises a resumable `pushBundle` endpoint, into the bundle file on disk. Over plain smart HTTP a receive-pack body larger than 1 MiB (Git's default `http.postBuffer`) is sent with chunked transfer encoding while the pack is still being written. A small probe request goes first so any authentication challenge is answered before the large body, as Git does. A custom [`HttpClient`](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/http/trait.HttpClient.html) should override [`post_streaming`](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/http/trait.HttpClient.html#method.post_streaming); the default buffers the body.

A local push applies the same ref-update checks as [`ReceivePack`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePack.html) (policy, hidden refs, fast-forward rules) before it copies objects or moves refs on a path remote.

To plan a push the way `grit push` does, start from its positionals: [`resolve_push_invocation`](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/fn.resolve_push_invocation.html) splits `[<remote>] [<refspec>...]` into a [`PushInvocation`](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/struct.PushInvocation.html) (configured remote, literal URL or path, or refspecs for the default remote). [`repo.remotes().push_plan_context`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.push_plan_context) reads the selected remote's refs ([`Remote::list_push_refs`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.Remote.html#method.list_push_refs), one scan of the push destination) into a [`PushPlanContext`](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/struct.PushPlanContext.html), [`repo.remotes().resolve_push`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.resolve_push) turns a [`PushRequest`](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/struct.PushRequest.html) into concrete ref updates, and [`open_push_destination`](https://docs.rs/grit-lib/latest/grit_lib/remote/push_plan/fn.open_push_destination.html) opens the `Remote` to send them to. Pass `PushPlanContext::remote_tips` on as `PushOptions::remote_ref_tips` so a local push does not scan the destination's refs a second time. The same handle turns `--force` / `--force-with-lease` into a `ForceMode` ([`force_mode`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.force_mode)), adds `--follow-tags` refspecs ([`follow_tag_push_specs`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.follow_tag_push_specs)), leases one ref against its tracking ref ([`apply_tracking_lease`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.apply_tracking_lease)), and writes `-u` upstream config after a push ([`set_upstream_after_push`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.set_upstream_after_push)).

[`pull`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/fn.pull.html) is the high-level fetch-and-integrate operation. Build [`PullOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/struct.PullOptions.html) (including shared [`FetchOptions`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOptions.html), explicit refspec/`FETCH_HEAD` integration, [`resolve_pull_autostash`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/fn.resolve_pull_autostash.html), and dry-run `--check` via [`PullCheck`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/struct.PullCheck.html)), pass a progress sink and HTTP client factory, and receive a typed [`PullOutcome`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/struct.PullOutcome.html). It maps `branch.<name>.merge` through the remote's fetch refspecs, uses `resolve_pull_integration_base` after explicit fetches, skips the fetch for a local `remote = .` upstream, and fast-forwards, merges, or adopts the upstream on an unborn branch. Failures are typed as [`PullError`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/enum.PullError.html); `grit pull` only builds options, invokes this API, and renders the outcome.

## Unreachable remotes

When the remote cannot be talked to at all, every operation (`list_refs`, `fetch`, `push`, [`clone`](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/fn.clone.html), [`pull`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/fn.pull.html)) and every transport fails with [`RemoteError::Unreadable`](https://docs.rs/grit-lib/latest/grit_lib/remote/enum.RemoteError.html#variant.Unreadable) (surfaced as [`Error::Remote`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Remote)). It carries the redacted URL or resolved path and a [`RemoteUnreadableReason`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.RemoteUnreadableReason.html):

| Reason | When |
| --- | --- |
| `RepositoryNotFound` | A local path or `file://` URL that is missing or not a Git directory (valid `HEAD`, `objects/` and `refs/`, as Git checks). Listing refs never treats it as an empty remote. A linked worktree or `--separate-git-dir` checkout is followed through its `.git` file and works as a remote. |
| `Transport { detail }` | DNS, refused or reset connection, TLS, or timeout (HTTP and `git://`). Usually worth a retry. |
| `HttpStatus { status }` | A smart-HTTP error status such as 403, 404 or 5xx. A `401` challenge is [`RemoteError::Auth`](https://docs.rs/grit-lib/latest/grit_lib/remote/enum.RemoteError.html#variant.Auth) instead. |
| `NotGitServer { status, content_type }` | HTTP succeeded but the body was not a Git advertisement (for example `200 text/html` from a mistyped or parked host). |
| `NoHandshake` | The transport ran but never spoke Git, for example `ssh` failed to connect, a `git://` peer hung up before any pkt-line, or the ref advertisement ended at EOF without a flush. An empty remote that sends only a flush pkt-line (`0000`) is a completed handshake with no refs. |

Both the umbrella and the area error answer the same question: [`Error::is_remote_unreadable`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#method.is_remote_unreadable) and [`RemoteError::is_remote_unreadable`](https://docs.rs/grit-lib/latest/grit_lib/remote/enum.RemoteError.html#method.is_remote_unreadable). The `grit` CLI maps all of them to exit code 128 and `kind: remote_unreadable` ([Exit codes](https://grit-scm.com/docs/library/exit-codes.md/index.md)).

A remote that was reached but aborts the conversation itself fails with [`RemoteError::Fatal`](https://docs.rs/grit-lib/latest/grit_lib/remote/enum.RemoteError.html#variant.Fatal) instead. Its `message` is the server's own text, from an `ERR` packet (for example `upload-pack: not our ref <oid>` when a fetch wants an object the server will not send) or from side-band channel 3. Every reader of upload-pack output reports it the same way, over every transport: the ref advertisement (including smart-HTTP `info/refs` discovery), `ls-refs`, negotiation, and the pack stream. Show the message to the user, but don't parse it, because each server words it differently.

HTTP remotes need an [`HttpClient`](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/http/trait.HttpClient.html). Implement [`HttpClientFactory`](https://docs.rs/grit-lib/latest/grit_lib/remote/trait.HttpClientFactory.html) or, with the `http-ureq` feature, pass `None` to use the default ureq-backed factory (`UreqHttpClient` + [`HelperCredentialProvider`](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/struct.HelperCredentialProvider.html)). The `grit` binary on macOS enables `http-ureq-native-tls` (Secure Transport) for HTTPS throughput; other platforms use rustls unless you opt into `http-ureq-native-tls` when depending on `grit-lib`.

## Credentials and progress

[`HelperCredentialProvider`](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/struct.HelperCredentialProvider.html) satisfies HTTP `401` responses from configured `credential.helper` programs, then from the askpass program set with [`with_askpass`](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/struct.HelperCredentialProvider.html#method.with_askpass), and never opens a TTY. Askpass resolution follows Git (`GIT_ASKPASS`, `core.askPass`, `SSH_ASKPASS`) from an [`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html) you pass in; the default factory reads only `core.askPass` unless you build it with `DefaultHttpClientFactory::with_environment` (with the `http-ureq` feature). [`helpers_for`](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/struct.HelperCredentialProvider.html#method.helpers_for) lists the helpers it would run for a credential, so you can tell up front whether storing one would be a no-op. When neither the helpers nor askpass can supply a credential, `fill` returns [`RemoteError::CredentialsUnavailable`](https://docs.rs/grit-lib/latest/grit_lib/remote/enum.RemoteError.html#variant.CredentialsUnavailable) with the helpers it asked, and the transport reports [`AuthFailure::CredentialsUnavailable`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.AuthFailure.html#variant.CredentialsUnavailable) carrying the same list, so a caller can tell "no helper configured" from "the helper has nothing for this host". To save a user name and token a person gives you for any host, build the credential with [`Credential::from_url`](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/struct.Credential.html#method.from_url) (described below), set its `username` and `password`, and `approve` it; `grit auth <url> --username … --token …` does exactly that.

Best-effort requests whose failure is ignored, such as the advertisement [`push_plan_context`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.push_plan_context) reads and the bundle a clone tries first, use [`HttpClientFactory::create_for_preflight`](https://docs.rs/grit-lib/latest/grit_lib/remote/trait.HttpClientFactory.html#tymethod.create_for_preflight): those clients never `reject` a refused credential, so the push or fetch that follows sends it, reports [`AuthFailure::Rejected`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.AuthFailure.html#variant.Rejected), and erases it as Git does. Every factory implements `create_for_preflight`; one whose clients never reject (or carry no credentials) can return the same client as `create`.

After an authenticated retry, [`HelperCredentialProvider`](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/struct.HelperCredentialProvider.html) (and any custom [`CredentialProvider`](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/trait.CredentialProvider.html), which must be `Send + Sync`) runs `reject` only when the server still answers `401`; a typo, missing repository, permission denial or server error (403, 404, 429, 5xx) leaves the stored credential untouched.

The HTTP client asks for credentials the way Git does: [`Credential::from_url`](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/struct.Credential.html#method.from_url) turns the repository URL into protocol and host, adding the repository path only when `credential.useHttpPath` applies, so a host-level entry from `git-credential-store` or a keychain helper serves every repository on the host. The full URL stays in [`Credential::url`](https://docs.rs/grit-lib/latest/grit_lib/remote/credentials/struct.Credential.html#structfield.url) for matching `credential.<url>.helper`, and `HelperCredentialProvider` never sends it to a helper. A `user:password@` in the URL fills the username and password (and is removed from `Credential::url`), so wrong URL credentials fail as [`AuthFailure::Rejected`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.AuthFailure.html#variant.Rejected). Complete URL credentials are also kept in the client's in-memory origin cache so later requests to the same scheme, host and port (such as a `bundle-uri` download with no userinfo) send the same `Authorization` header without writing secrets into a helper or resumable state files.

The GitHub OAuth device flow (`remote::github_auth::DeviceFlow`) that `grit auth` uses, and the grit-server login, share, space and snapshot-checkout clients (`remote::grit_server_*`, `remote::snapshot_checkout`), exist only with the off-by-default `unstable-hosting` feature. They are outside the semver promise and may change in any release, so pin an exact `grit-lib` version if you enable it.

Whenever you show a remote address, in errors or in success output, strip embedded userinfo with [`redact_url_for_display`](https://docs.rs/grit-lib/latest/grit_lib/remote/fn.redact_url_for_display.html) so passwords never reach logs or JSON; it leaves the rest of the URL, and local paths, exactly as given. Keep the original URL for the transport and for config. Pass [`NullProgress`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.NullProgress.html) to ignore sideband progress, or override [`ProgressSink::message`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html#method.message) for side-band channel 2. Set [`FetchOptions`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOptions.html) `remote_progress` to omit `no-progress` on the wire so the remote may emit channel 2; decode chunks with [`SidebandLines`](https://docs.rs/grit-lib/latest/grit_lib/remote/sideband_lines/struct.SidebandLines.html) into [`RemoteLine`](https://docs.rs/grit-lib/latest/grit_lib/remote/sideband_lines/enum.RemoteLine.html) updates and lines.

Fetch and clone spool the received pack to a temp file and index it in place with [`ingest_received_pack_path`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.ingest_received_pack_path.html), keeping the pack instead of exploding it into loose objects. Memory does not grow with the pack size. The sequential passes (trailer checksum and object scan) read through a memory map whose resident pages are dropped every few megabytes, and delta resolution reads each compressed object from the file. A thin pack (ref-deltas against objects the receiver already has, which Git servers send on incremental fetches) is completed the way `git index-pack --fix-thin` does it. The missing bases are appended to the file, the object count and trailing checksum are rewritten, and the pack and its `.idx` are named after the new checksum. On `git/git` (325 MB pack, 420k objects), indexing peaks at about 80 MB, against 63 MB for `git index-pack` on the same file.

A received pack's length in bytes is not known until it ends, so byte counts alone cannot say how far a transfer is. Return `true` from [`ProgressSink::wants_received_objects`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html#method.wants_received_objects) and the receive also counts the pack's objects on a background thread, reporting [`ReceivedObjects`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.ReceivedObjects.html) (received, total from the pack header, and deltas so far) through [`ProgressSink::received_objects`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html#method.received_objects). The counting never makes the receive wait; if it falls far behind a very fast transfer, it stops. The same object-counting logic also exists as a crate-internal pack stream scanner for other callers. To turn the phases of a fetch or clone into one percentage and time-left figure, feed the same events to an [`OverallEstimator`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.OverallEstimator.html); it takes elapsed time as an argument rather than reading the clock.

## Example

This example resolves `origin`, lists refs on a **local** bare remote, fetches, creates a commit reusing the fetched tip’s tree, and pushes — all over `file://`:

```rust
//! List refs on a local remote, fetch, create a commit, and push over `file://`.
//!
//! Source for the library guide "Network" page (included in the docs site).

use anyhow::Result;
use grit_examples::remote;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::config::ConfigSet;
use grit_lib::ident::parse_signature;
use grit_lib::objects::NewCommit;
use grit_lib::refs::store::RefName;
use grit_lib::remote::transfer::{FetchOptions, PushOptions, PushRefSpec, TagMode};
use grit_lib::remote::transport_path::resolve_local_remote_git_dir;
use grit_lib::remote::{ListRefsOptions, Remote};
use grit_lib::repo::Repository;
use std::path::Path;

fn main() -> Result<()> {
    let consumer = std::env::args()
        .nth(1)
        .ok_or_else(|| anyhow::anyhow!("usage: guide_network <consumer-repo>"))?;
    let consumer = Path::new(&consumer);
    let repo = Repository::discover(Some(consumer), &RepositoryOptions::from_process())?;
    let git_dir = repo.git_dir().to_path_buf();
    let work_tree = repo.work_tree().map(|p| p.to_path_buf());
    let env = grit_lib::config::environment::Environment::capture_process();
    let config = ConfigSet::load(
        &env,
        Some(&git_dir),
        &grit_lib::config::LoadConfigOptions::standard(&env, Some(&git_dir)),
    )?;

    let remote_info = remote::resolve_remote(&config, &repo, Some("origin"), false)?;

    let remote_git_dir =
        resolve_local_remote_git_dir(&remote_info.url, &git_dir, work_tree.as_deref());
    let refs_on_remote = repo.remotes().ls_remote(
        &Remote::from_url(&remote_git_dir.to_string_lossy())?,
        &ListRefsOptions::default(),
        None,
    )?;
    eprintln!(
        "ls-remote: {} ref(s) on {}",
        refs_on_remote.len(),
        remote_git_dir.display()
    );

    let mut fetch_opts = FetchOptions::new();
    fetch_opts.refspecs = remote_info.fetch_refspecs.clone();
    fetch_opts.tags = TagMode::Following;
    remote::fetch(&repo, &remote_info, &fetch_opts)?;

    let main = RefName::new("refs/heads/main")?;
    let tracking = repo
        .references()
        .resolve(&RefName::new("refs/remotes/origin/main")?)?;
    repo.references().update(&main, &tracking)?;

    let parent = repo.objects().read_commit(&tracking)?;
    let committer = parse_signature(&parent.committer)
        .ok_or_else(|| anyhow::anyhow!("parent committer is not a valid identity"))?;
    let new_oid = repo.objects().write_commit(
        &NewCommit::new(
            parent.tree,
            committer.clone(),
            committer,
            "library guide network example",
        )
        .with_parents([tracking]),
    )?;
    repo.references().update(&main, &new_oid)?;

    let spec = PushRefSpec::default()
        .with_src(Some(new_oid))
        .with_src_ref(Some("refs/heads/main".to_owned()))
        .with_dst("refs/heads/main".to_owned());
    remote::push(&repo, &remote_info, &[spec], &PushOptions::default())?;

    println!("{new_oid}");
    Ok(())
}
```

The `grit-examples` crate also ships `gritx-fetch` and `gritx-push`, which dispatch on URL scheme and print transport/auth discovery lines. Shared wiring lives in `grit-examples/src/remote.rs` (slated to thin over `Remote` in a follow-up step).

Integration test `guide_network` builds bare and consumer repos with system Git, runs the binary, then requires clean `git fsck --strict` on both sides and matching `git rev-parse` on the pushed ref.

## Serving fetches and pushes

The server side of the protocol lives in [`remote::serve`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/index.html). An [`UploadPack`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.UploadPack.html) session answers clones and fetches (protocol v0, v1 and v2) and returns an [`UploadOutcome`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.UploadOutcome.html) with bytes sent, object count, negotiation rounds, and optional [`PackStats`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_objects/struct.PackStats.html). A [`ReceivePack`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePack.html) session accepts pushes. Both are built from an opened `Repository` and [`ServeOptions`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ServeOptions.html) (plus a [`ReceivePolicy`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePolicy.html) for pushes) and `run` over a reader and a writer, so the same code serves a pipe or ssh channel (the defaults) and smart HTTP (`advertise_refs` for `GET info/refs`, `stateless_rpc` for the POST). The library never reads the environment: map `GIT_PROTOCOL` with [`ProtocolVersion::from_git_protocol`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/enum.ProtocolVersion.html#method.from_git_protocol) at your process boundary. Open the repository with `RepositoryOptions::for_serving()`.

To stop a long fetch or push (client disconnect, deadline, quota), pass a [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html) to [`UploadPack::with_cancel`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.UploadPack.html#method.with_cancel) or [`ReceivePack::with_cancel`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePack.html#method.with_cancel). A fired cancel returns [`Error::Cancelled`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Cancelled) and does not move refs on receive-pack.

A protocol v2 `ls-refs` request asks the ref store for its `ref-prefix` ranges only, and reads objects only when the client sent `peel`. Even then, a fully peeled `packed-refs` answers without opening the tags. So the `ls-refs` call that every `git fetch` and `git ls-remote` sends costs in proportion to the refs it returns, not the refs stored. The v0/v1 advertisement always peels tags, and the push advertisement never does. Like Git, every advertisement includes refs whose objects are missing; such a ref just has no peeled value.

A pushed pack is streamed into a temp file (under the repository's `objects/pack/` quarantine for a files primary, or the system temp directory for a custom primary), so memory use does not grow with the pack size, and only bytes up to the pack's trailing checksum are read (a push client keeps its side open until it has the status report). On a files backend, packs with fewer objects than `receive.unpackLimit` are stored as loose objects in the quarantine; larger ones are indexed and kept as a pack there. A custom primary always unpacks object-by-object into an in-memory overlay until pre-receive passes, then copies into the primary (see [Receiving packs into a custom store](https://grit-scm.com/docs/library/network/library/object-stores.md/index.md#receiving-packs-into-a-custom-store)). `receive.maxInputSize` caps the pack size.

A push from a shallow clone starts its command list with a `shallow <oid>` line for each of the client's boundaries, and `ReceivePack` accepts them anywhere before the flush. The parents of those commits are not required when the pushed objects are checked. When the repository's refs already reach the boundary (the usual case: a CI checkout cloned `--depth 1` from this server), the push is applied like any other. When accepting an update would make the repository shallow, it is refused with `RefUpdateRefusal::ShallowUpdateNotAllowed`, unless [`ReceivePolicy::shallow_update`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePolicy.html#structfield.shallow_update) (`receive.shallowUpdate`) is on. Then the new boundaries are added to the repository's `shallow` file before the ref is written, so `git fsck` accepts the result.

What a push may change is decided in three layers, in this order for each push:

1. [`ReceivePolicy`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePolicy.html), usually [`ReceivePolicy::from_config`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePolicy.html#method.from_config) (`receive.denyNonFastForwards`, `receive.denyDeletes`, `deny_current_branch` from `receive.denyCurrentBranch`, `receive.fsckObjects`, `receive.shallowUpdate`), plus the checks every server makes: valid ref names, hidden refs, the expected old value, and that the new objects exist. When `receive.denyCurrentBranch` is `updateInstead`, grit runs `push-to-checkout` (or the built-in deploy) after the `update` hook and before the ref moves, on every non-bare worktree that has the updated branch checked out.
2. An in-process [`ReceiveHook`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/trait.ReceiveHook.html) passed to [`ReceivePack::with_hook`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePack.html#method.with_hook). Its `pre_receive_ctx` and `update_ctx` methods take a [`ReceiveHookContext`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceiveHookContext.html) with the client's push options (the same values hook scripts see in `GIT_PUSH_OPTION_*`), so policy can refuse `-o` values before refs move. The default `pre_receive` / `update` methods ignore push options. `pre_receive_ctx` sees every accepted update and an object database that includes the still-quarantined pushed objects; refusing there refuses the whole push and nothing is moved into the repository. `update_ctx` checks one ref at a time after the objects are moved in. A closure `Fn(&RefCommand, &Odb) -> Result<(), RefUpdateRefusal> + Send + Sync` is a `ReceiveHook` that implements `update`. Hooks are `Send + Sync` so one hook can serve every connection thread; keep mutable state behind a `Mutex` or atomics.
3. The repository's hook scripts (`pre-receive`, `update`, `post-receive`, `post-update`), run through the repository's `CommandRunner` with Git's environment (`GIT_DIR=.`, the quarantine variables and `GIT_PUSH_OPTION_*`). Each in-process check runs just before the matching script.

The [`ReceiveOutcome`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceiveOutcome.html) is typed: each [`RefUpdateResult`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.RefUpdateResult.html) carries an `Option<RefUpdateRefusal>` ([`RefUpdateRefusal`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/enum.RefUpdateRefusal.html): `NonFastForward`, `StaleInfo`, `DeletionProhibited`, `PreReceiveHookDeclined`, `Policy(reason)` from your hook, ...), and `unpack_error` is an [`UnpackError`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/enum.UnpackError.html) (`Truncated`, `TooLarge`, `Malformed`, `Ingest`, `Rejected`, `FsckSkipList`, `Io`). It also reports `bytes_received` and `objects_received` from the pushed pack. Match on the variants; their `Display` text is what the client is sent on its `ng <ref> <reason>` and `unpack <reason>` status lines. Neither is an `Err`: `ReceivePack::run` returns [`ServeError`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/enum.ServeError.html) only when the session itself fails (a malformed command list, a broken stream, or a repository error while applying the push).

Hook scripts inherit the repository [`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html): set `REMOTE_USER` (or any other variable hooks should see) with [`Environment::with_var`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html#method.with_var) on the [`RepositoryOptions`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html) you pass when opening the repository for serve. [`ReceiveHook::post_receive`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/trait.ReceiveHook.html#method.post_receive) and [`ReceiveHook::post_update`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/trait.ReceiveHook.html#method.post_update) run after refs move and the matching scripts; refusals are recorded on [`ReceiveOutcome::post_receive_callback_error`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceiveOutcome.html#structfield.post_receive_callback_error) and [`ReceiveOutcome::post_update_callback_error`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceiveOutcome.html#structfield.post_update_callback_error) without changing the client status report or undoing ref updates.

[`grit_protocol::ServeSession`](https://docs.rs/grit-protocol/latest/grit_protocol/struct.ServeSession.html) threads an optional in-process [`ReceiveHook`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/trait.ReceiveHook.html) and [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html) through `grit-protocol` and `grit-http-server` smart HTTP handlers; every push still runs [`grit_protocol::PushGuard`](https://docs.rs/grit-protocol/latest/grit_protocol/struct.PushGuard.html) alongside your hook. [`stateless_rpc_with_session`](https://docs.rs/grit-protocol/latest/grit_protocol/receive_pack/fn.stateless_rpc_with_session.html) and [`stateless_rpc_to_reader_with_session`](https://docs.rs/grit-protocol/latest/grit_protocol/upload_pack/fn.stateless_rpc_to_reader_with_session.html) return typed outcomes instead of discarding them.

Setting [`ReceivePolicy::fsck_objects`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePolicy.html#structfield.fsck_objects) to an [`ObjectFsckPolicy`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/struct.ObjectFsckPolicy.html) (what `receive.fsckObjects` does) checks every pushed commit, tree and tag while it is still in quarantine. A malformed object refuses the whole push with [`UnpackError::Rejected`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/enum.UnpackError.html#variant.Rejected), which names the object and its fsck message id; every update fails with `unpacker error` and the quarantine is deleted. Transfer checks are strict like Git's (warnings are errors); [`ObjectFsckPolicy::set_level`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/struct.ObjectFsckPolicy.html#method.set_level) changes single messages, as `receive.fsck.<msg-id>` does in config.

```rust
use grit_lib::maintenance::fsck::{FsckMsgLevel, ObjectFsckPolicy};
use grit_lib::remote::serve::ReceivePolicy;

let mut fsck = ObjectFsckPolicy::default();
fsck.set_level("missingEmail", FsckMsgLevel::Warn);
let policy = ReceivePolicy::default().with_fsck_objects(Some(fsck));
assert!(policy.fsck_objects.is_some());
```

To check objects from some other source with the same rules, call [`ObjectFsckPolicy::checker`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/struct.ObjectFsckPolicy.html#method.checker) once and [`ObjectFsckChecker::check`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/fsck/struct.ObjectFsckChecker.html#method.check) per object.

This server serves fetches, and refuses pushes to `refs/heads/protected/*` with a closure. Git runs it as `git push --receive-pack='guide_serve receive-pack' <path>` (and `--upload-pack='guide_serve upload-pack'` for clone and fetch):

```rust
//! A minimal Git server on stdin/stdout: serve fetches with `UploadPack` and
//! pushes with `ReceivePack::with_hook`, refusing pushes to protected branches
//! from Rust code instead of a hook script.
//!
//! Git starts it with the repository path as the last argument:
//!
//! ```text
//! git clone --upload-pack='guide_serve upload-pack' /srv/repo.git
//! git push --receive-pack='guide_serve receive-pack' /srv/repo.git main
//! ```
//!
//! Source for the library guide "Network" page (included in the docs site).

use std::io::{BufWriter, Write};
use std::path::Path;

use grit_lib::config::environment::RepositoryOptions;
use grit_lib::objects::odb::Odb;
use grit_lib::remote::serve::{
    self, ProtocolVersion, ReceiveHook, ReceiveHookContext, ReceivePolicy, RefCommand,
    RefUpdateRefusal, ServeOptions,
};
use grit_lib::repo::Repository;

/// Refuse every update to `refs/heads/protected/*`; the reason is shown to the
/// pushing user next to the rejected ref.
fn protect_branches(cmd: &RefCommand, _odb: &Odb) -> Result<(), RefUpdateRefusal> {
    if cmd.refname.starts_with("refs/heads/protected/") {
        return Err(RefUpdateRefusal::Policy("protected branch".to_owned()));
    }
    Ok(())
}

struct ServerHook;

impl ReceiveHook for ServerHook {
    fn pre_receive_ctx(
        &self,
        _commands: &[RefCommand],
        _odb: &Odb,
        ctx: &ReceiveHookContext<'_>,
    ) -> Result<(), RefUpdateRefusal> {
        if ctx.push_options.iter().any(|o| o == "ci.skip") {
            return Err(RefUpdateRefusal::Policy("ci.skip".to_owned()));
        }
        Ok(())
    }

    fn update(&self, command: &RefCommand, odb: &Odb) -> Result<(), RefUpdateRefusal> {
        protect_branches(command, odb)
    }
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut args = std::env::args().skip(1);
    let (Some(service), Some(path)) = (args.next(), args.next()) else {
        return Err("usage: guide_serve <upload-pack|receive-pack> <repository>".into());
    };
    let repo = Repository::open(
        Path::new(&path),
        &RepositoryOptions::from_process().for_serving(),
    )?;

    // The process boundary owns the environment: the library never reads it.
    let protocol = std::env::var("GIT_PROTOCOL")
        .map(|v| ProtocolVersion::from_git_protocol(&v))
        .unwrap_or_default();
    let mut opts = ServeOptions::default()
        .with_protocol(protocol)
        .with_agent("guide-serve/1".to_owned());

    let mut input = std::io::stdin().lock();
    let mut output = BufWriter::new(std::io::stdout().lock());
    match service.as_str() {
        "upload-pack" => {
            let summary = serve::UploadPack::new(&repo, &mut opts).run(&mut input, &mut output)?;
            eprintln!(
                "upload-pack: {} bytes, {} objects, {} negotiation rounds",
                summary.bytes_written, summary.objects_sent, summary.negotiation_rounds
            );
        }
        "receive-pack" => {
            let policy = ReceivePolicy::from_config(&*repo.config().snapshot()?);
            let outcome = serve::ReceivePack::new(&repo, &opts, &policy)
                .with_hook(&ServerHook)
                .run(&mut input, &mut output)?;
            // Typed results: match on the refusal, never on its text.
            for update in &outcome.updates {
                if let Some(RefUpdateRefusal::Policy(reason)) = &update.error {
                    eprintln!("refused {}: {reason}", update.refname);
                }
            }
        }
        other => return Err(format!("unknown service '{other}'").into()),
    }
    output.flush()?;
    Ok(())
}
```

Integration test `guide_serve` clones through it over protocol v0 and v2, pushes a commit, checks `git fsck --strict` on the server, and checks that a push to a protected branch is reported as `[remote rejected] (protected branch)`. The `grit upload-pack` / `grit receive-pack` commands and `grit-http-server` are built on the same sessions.

## Partial clone and promisor fetch

Filtered fetch and clone record a promisor remote (`remote.<name>.promisor`, `extensions.partialclone`, and `remote.<name>.partialclonefilter`). Blobs omitted from the initial pack are **promised**: they appear in the object database as missing until fetched on demand.

Install a [`PromisorFetcher`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor/trait.PromisorFetcher.html) on [`RepositoryOptions::with_promisor_fetcher`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_promisor_fetcher) (no global state). The default [`DefaultPromisorFetcher`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor/struct.DefaultPromisorFetcher.html) sends `want` lines for the missing object ids with `filter blob:none` (as Git does), does not update refs, and ingests the reply as a promisor pack. It asks the promisor remotes one after another in [`lazy_fetch_order`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/fn.lazy_fetch_order.html): config order with the `extensions.partialClone` remote last, each for what is still missing, moving on when one fails. A server refuses a whole request when it lacks one of the objects, so when a remote failed and several objects are still missing, the rest is split in halves that go through the remotes again: a large-object promisor that holds only the large blobs and `origin` holding the small ones serve one checkout between them. A remote that cannot be used at all (unreachable, no usable URL, authentication failed) is not asked again. When objects stay missing, the error is [`ObjectError::PromisorFetchFailed`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.PromisorFetchFailed), naming each remote that failed with a summary of its first error, or [`ObjectError::PromisedMissing`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.PromisedMissing) when every remote answered without the object. The `grit` CLI installs this fetcher for every opened repository.

When a fetcher is installed and [`fetch.promisorLazy`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor/constant.PROMISOR_LAZY_FETCH_CONFIG.html) is true (the default), an ODB read miss in a partial-clone repository triggers an isolated fetch (with recursion protection) and retries the read. With no fetcher, or when lazy fetch is disabled, reads return [`ObjectError::PromisedMissing`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.PromisedMissing). Set `fetch.promisorLazy=false` in config, or `GRIT_NO_LAZY_FETCH=1` / `GIT_NO_LAZY_FETCH=1` in the environment, to opt out.

[`Repository::prefetch_promised`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.prefetch_promised) batch-fetches object ids before bulk reads. Tree-to-tree checkout (including clone checkout and [`grit switch`](https://grit-scm.com/docs/library/commands/switch.md/index.md)) collects missing blob oids from the diff and prefetches them in a single request when a fetcher is present. Hard reset also batches materialization and repair of unchanged paths, including an empty worktree/index after a metadata-only clone. Its batch includes required attribute blobs before attribute resolution, deduplicates shared blob ids, and excludes gitlinks and sparse-skipped paths that need no content. Files proven up to date by index stat data require no blob download. Repeating a reset after materialization uses the local objects and makes no data fetch.

[`CloneOptions::promisor_fetcher`](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/struct.CloneOptions.html) carries the fetcher through to the opened repository so blobless clone checkout can prefetch without a separate reopen.

On the serving side, pass the client's [`ObjectFilter`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/enum.ObjectFilter.html) to [`UploadPackStream::with_filter`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_objects/struct.UploadPackStream.html#method.with_filter) (or build it in memory with [`UploadPackStream::build`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_objects/struct.UploadPackStream.html#method.build)). The filtered pack streams like an unfiltered one and holds the objects `git pack-objects --filter` selects: wanted objects and tag targets always, then the commits, trees and blobs the filter keeps.

### Large-object promisors

A server can point clients at the remotes that hold some of its objects, such as a large-object promisor (LOP) with the big blobs, through the protocol v2 `promisor-remote` capability. [`PromisorAdvertisement`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/struct.PromisorAdvertisement.html) models it: [`from_server_config`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/struct.PromisorAdvertisement.html#method.from_server_config) builds it from `promisor.advertise` and `promisor.sendFields`, and [`UploadPack`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.UploadPack.html) advertises it and collects the names a client accepts in [`ServeOptions::accepted_promisor_remotes`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ServeOptions.html#structfield.accepted_promisor_remotes). `uploadpack.allowAnySHA1InWant` lets a LOP served by grit hand out blobs no ref points at.

On the client, a v2 fetch reads the advertisement and runs [`PromisorHandshake::evaluate`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/struct.PromisorHandshake.html#method.evaluate) ([`PromisorHandshakeOptions`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/struct.PromisorHandshakeOptions.html) says whether the fetch is partial and whether to pick the filter automatically): [`PromisorAcceptPolicy`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/struct.PromisorAcceptPolicy.html) (`promisor.acceptFromServer`, `checkFields`, `storeFields`) decides, against the promisor remotes already in config ([`configured_promisor_remotes`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/fn.configured_promisor_remotes.html)), which advertised remotes to accept, and each verdict is a [`PromisorRejection`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/enum.PromisorRejection.html) or acceptance. Only a partial fetch accepts anything: one with a filter, or one from a remote configured as a promisor remote. The accepted names go back to the server with both the `ls-refs` and the `fetch` request, so a stateless smart-HTTP server sees them where it builds the pack. With [`FetchOptions::auto_filter`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOptions.html#structfield.auto_filter) the filter comes from the accepted remotes ([`PromisorDecision::combined_filter`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor_remote/struct.PromisorDecision.html#method.combined_filter)). The result is in [`FetchOutcome::promisor`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOutcome.html#structfield.promisor) and [`CloneOutcome::promisor`](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/struct.CloneOutcome.html#structfield.promisor).

```rust
use grit_lib::remote::clone::{clone, CloneOptions};

let opts = CloneOptions::new("https://git.example.com/project.git", "project".into())
    .with_auto_filter(true)
    .with_config(vec![
        ("remote.lop.url".into(), "https://lop.example.com/project.git".into()),
        ("remote.lop.promisor".into(), "true".into()),
        ("promisor.acceptFromServer".into(), "knownUrl".into()),
    ]);
let outcome = clone(opts, &mut progress, &cancel, None)?;
for remote in outcome.promisor.iter().flat_map(|h| h.decision.accepted()) {
    println!("accepted {}", remote.name);
}
```

Accepting never creates a remote, and lazy fetches use the URL configured locally, not the advertised one.

### Serving a repository whose large blobs live on a LOP

After [`repo.maintenance().offload_blobs`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.offload_blobs) (see [Maintenance](https://grit-scm.com/docs/library/network/maintenance.md/index.md)), a server's large blobs live only on its LOP, and the rest of the repository sits in a `.promisor` pack. [`UploadPack`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.UploadPack.html) serves such a repository by Git's rule. A client that accepted an advertised promisor remote gets packs without the promised blobs it lacks, and fetches those from the LOP. For any other client, the server either fetches them first or refuses with [`ServeError::ObjectMissing`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/enum.ServeError.html#variant.ObjectMissing). That error carries a structured reason and reaches the client as an `ERR` line before any pack data. Fetching first needs [`ServeOptions::lazy_fetch`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ServeOptions.html#structfield.lazy_fetch), or `uploadpack.lazyFetch` when it is `None`, plus a [`PromisorFetcher`](https://docs.rs/grit-lib/latest/grit_lib/objects/promisor/trait.PromisorFetcher.html) on the served repository. The library reads no environment: [`ServeOptions::lazy_fetch_from_environment`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ServeOptions.html#method.lazy_fetch_from_environment) maps `GIT_NO_LAZY_FETCH`, and [`ServeOptions::attach_promisor_fetcher`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ServeOptions.html#method.attach_promisor_fetcher) gives the opened repository a fetcher only when [`ServeOptions::lazy_fetch_enabled`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ServeOptions.html#method.lazy_fetch_enabled), and takes away any it was opened with otherwise, so a server without lazy fetch never fetches. Each fetch is planned again after a lazy fetch, so the client's filter still applies to the fetched blobs. [`ReceivePack`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePack.html) into such a repository accepts pushed trees that name promised blobs, as Git's connectivity check does. Repositories without promisor remotes keep the bitmap and pack-reuse fast path. Only these partial repositories plan their packs with the object walk, checking each blob is stored.

A local clone or fetch from a repository with promisor remotes of its own goes through the same in-process upload-pack instead of copying its object store, which would come up short.

## Bundles

Offline bundle files are documented on the [Bundle](https://grit-scm.com/docs/library/bundle/index.md) guide (`Bundles`). Smart HTTP and local remotes above cover online fetch/push.

# https://grit-scm.com/docs/library/notes/index.md

# Notes

> Attach annotated notes to commits via RepositoryNotes and NotesRef.

Git notes are auxiliary commits under `refs/notes/*`. The [`notes`](https://docs.rs/grit-lib/latest/grit_lib/notes/index.html) module defines [`NotesRef`](https://docs.rs/grit-lib/latest/grit_lib/notes/struct.NotesRef.html) (for example [`NotesRef::commits`](https://docs.rs/grit-lib/latest/grit_lib/notes/struct.NotesRef.html), or [`NotesRef::parse`](https://docs.rs/grit-lib/latest/grit_lib/notes/struct.NotesRef.html) for a short name like `review`), tree helpers, and [`resolve_configured_notes_ref`](https://docs.rs/grit-lib/latest/grit_lib/notes/fn.resolve_configured_notes_ref.html) for `GIT_NOTES_REF` / `core.notesRef`.

[`Repository::notes`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) exposes [`RepositoryNotes`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryNotes.html):

- `add` attaches a note and returns a [`NoteAddOutcome`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/enum.NoteAddOutcome.html) (`Added` or `Replaced`). Without `force`, an existing note is [`Error::NoteAlreadyExists`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html). The content bytes are stored as given.
- `read` returns one note's bytes, `list` returns `(object, note blob)` pairs as [`NoteListing`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.NoteListing.html), and `list_with_bodies` returns every [`Note`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Note.html) with its contents, sorted by object. A missing or non-blob note object is an error, never an empty note.
- [`remove_many`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryNotes.html) removes several notes in one notes commit.
- `plan_add` and `plan_remove_many` preview a write without touching objects, refs, or reflogs. [`NoteAddPlan`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.NoteAddPlan.html) and [`NoteRemoveManyPlan`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.NoteRemoveManyPlan.html) report the notes ref tip before the write and the notes commit the write would create. A batch plan applies every removal to one tree, so its predicted tip is the commit `remove_many` writes for the same objects and options.

Writes take an explicit committer and optional author ([`Signature`](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.Signature.html) values, usually from `repo.identity`) and a commit message through [`NotesWriteOptions`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.NotesWriteOptions.html). Each write is one notes commit on top of the tip the existing notes were read from. The ref moves through the repository's ref store as a compare-and-swap update from that same tip, so it works the same on loose/packed refs, reftable, or an injected [`MemoryRefStore`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.MemoryRefStore.html), and an `add` or `remove_many` that races another notes writer fails instead of dropping the other writer's note. The lower-level [`write_notes_commit`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryNotes.html#method.write_tree_commit) replaces the whole tree with the entries you pass, so callers that read entries themselves own that race. The reflog line (`notes: <message>`) is written in the same transaction whenever the ref already has a reflog or `core.logAllRefUpdates` allows creating one.

A notes ref that points at something other than a notes commit or tree fails with `Error::NotesRefNotCommit`, and a malformed notes tree fails with `Error::NotesObjectKind`.

When `notes.rewriteRef` (or `GIT_NOTES_REWRITE_REF`) lists one or more refs under `refs/notes/`, grit copies notes from old commits to their replacements after a rebase or other history rewrite, and after amend when post-rewrite hooks run. Enable or disable each command with `notes.rewrite.rebase` and `notes.rewrite.amend` (both default to true). Combine colliding notes with `notes.rewriteMode` (`concatenate`, `cat_sort_uniq`, `overwrite`, or `ignore`; default `concatenate`). Planning validates refs and mode before history refs move ([`prepare_notes_for_rewrite`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryNotes.html)); [`apply_prepared_notes_rewrite`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryNotes.html#method.write_tree_commit) performs the copy using the snapshot tip for compare-and-swap. [`copy_notes_for_rewrite`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryNotes.html#method.write_tree_commit) runs both steps.

## Example

```rust
//! Attach a note to a commit and list notes with [`RepositoryNotes`](https://grit-scm.com/docs/library/notes/grit_lib::repo_handles::RepositoryNotes/index.md).
//!
//! Source for the library guide "Notes" page (included in the docs site).

use anyhow::Result;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::notes::NotesRef;
use grit_lib::objects::ObjectId;
use grit_lib::repo::Repository;
use grit_lib::repo_handles::{NoteAddOutcome, NotesWriteOptions};

use std::path::{Path, PathBuf};

const IDENT: &str = "Library Guide <guide@grit-scm.com> 1735689600 +0000";

fn open_repo(root: &Path) -> Result<Repository> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::from_process();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Ok(Repository::open(&git_dir, &opts)?)
}

fn main() -> Result<()> {
    let root = std::env::args()
        .nth(1)
        .map(PathBuf::from)
        .or_else(|| std::env::current_dir().ok())
        .ok_or_else(|| anyhow::anyhow!("missing repository path"))?;
    let repo = open_repo(&root)?;

    let head = repo.references().head()?;
    let commit: ObjectId = head
        .oid()
        .cloned()
        .ok_or_else(|| anyhow::anyhow!("HEAD has no commit"))?;

    let notes_ref = NotesRef::commits();
    let outcome = repo.notes().add(
        &notes_ref,
        &commit,
        b"library guide note\n",
        &NotesWriteOptions::new("add note", IDENT.parse()?),
        false,
    )?;
    println!("added={}", outcome == NoteAddOutcome::Added);

    let body = repo.notes().read(&notes_ref, &commit)?.unwrap_or_default();
    let text = String::from_utf8_lossy(&body);
    println!("note={text}");

    for note in repo.notes().list_with_bodies(&notes_ref, None)?.items {
        println!(
            "{} {}",
            note.object.to_hex(),
            String::from_utf8_lossy(&note.body).trim_end()
        );
    }

    Ok(())
}
```

```bash
cargo run --bin guide_notes /path/to/repo
git notes show HEAD
```

The integration test compares the printed note body to `git notes show`.

# https://grit-scm.com/docs/library/object-stores/index.md

# Object stores

> Pluggable ObjectStore backends, RepositoryOptions::with_object_store, OdbBuilder layers, and the odb_conformance test suite.

**Implementing a backend?** Start with [Writing storage backends](https://grit-scm.com/docs/library/object-stores/storage-backends.md/index.md) for traits, init, capabilities, conformance testing, and the SQLite walkthrough.

By default [`Repository`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) opens a files-backed [`Odb`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) (loose objects, packs, and optional MIDX). Embedders swap the **primary** store with [`RepositoryOptions::with_object_store`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_object_store), and add read-only layers, an attached commit-graph or an alternates override with an [`OdbBuilder`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.OdbBuilder.html) passed to [`RepositoryOptions::with_odb_builder`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_odb_builder). Neither takes a path: [`Repository::open`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.open) resolves the `objects/` directory itself.

## Traits

| Trait | Role |
| ----- | ---- |
| [`ObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.ObjectStore.html) | Read, metadata, streaming, enumeration |
| [`WritableObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.WritableObjectStore.html) | Insert objects (idempotent writes) |
| [`PrunableObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.PrunableObjectStore.html) | Optional: delete objects, so `gc` and `prune` work on the store (see [Garbage collection on a custom store](#garbage-collection-on-a-custom-store)) |

Built-in backends live under [`grit_lib::objects::odb::store`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/index.html) (`LooseStore`, `FilesSource`, `MemoryStore`, `CompositeStore`, and others).

## Lookup order

For a given [`Odb`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) handle:

1. In-memory overlay (when enabled for merge-tree-style operations)
2. **Primary** store — files source by default, or your custom [`WritableObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.WritableObjectStore.html)
3. Extra read sources from `OdbBuilder::push_read_source`
4. Alternate object directories (`info/alternates`, environment alternates, submodule object dirs). They are on for the files primary and off for a custom primary unless `OdbBuilder::alternates(true)` turns them on; `OdbBuilder::alternates(false)` turns them off for the files primary.

[`Odb::read_store`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.read_store) returns that whole chain as one `Arc<dyn ObjectStore>`, whatever the primary is. Hand it to another repository's `push_read_source` to layer one repository under another (a read-through cache or a mirror), or pass it as the `bases` of `ingest_pack_into`. A missing object is `Ok(None)` and never starts a promisor fetch. Its `open_stream` buffers the payload; for a large blob call [`Odb::with_stream`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.with_stream) on the `Odb` itself.

The narrower accessors keep their meaning: [`Odb::sources`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.sources) is the alternates alone (step 4), and [`Odb::primary`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.primary) returns the files-backed primary and fails with `UnsupportedObjectStore` (`files_source`) on a custom one. Use [`Odb::primary_writable`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.primary_writable) for the primary of any kind.

```rust
use std::path::Path;
use std::sync::Arc;

use grit_lib::config::environment::RepositoryOptions;
use grit_lib::objects::odb::store::MemoryStore;
use grit_lib::objects::odb::OdbBuilder;
use grit_lib::objects::{HashAlgo, ObjectKind};
use grit_lib::refs::store::MemoryRefStore;
use grit_lib::repo::Repository;

let in_memory = || {
    RepositoryOptions::empty()
        .with_object_store(Arc::new(MemoryStore::new(HashAlgo::Sha1)))
        .with_ref_store(Arc::new(MemoryRefStore::new()))
};
let upstream = Repository::open(Path::new("/nowhere/upstream.git"), &in_memory())?;
let mirror = Repository::open(
    Path::new("/nowhere/mirror.git"),
    &in_memory().with_odb_builder(OdbBuilder::new().push_read_source(upstream.odb().read_store())),
)?;
let oid = upstream.odb().write(ObjectKind::Blob, b"shared")?;
assert!(mirror.odb().contains(&oid)?);
# Ok::<(), grit_lib::error::Error>(())
```

`Arc<T>`, `Box<T>` and `&T` implement `ObjectStore` (and `WritableObjectStore` and `PrunableObjectStore`) whenever `T` does, `dyn` included, by forwarding every method, `as_prunable` among them. A decorator written as `struct Counted<S: ObjectStore>(S)` can therefore wrap a shared `Arc<dyn ObjectStore>` and still be passed on as `Arc<dyn ObjectStore>`, with no hand-written forwarding newtype.

## Where the primary store lives

A files-backed primary is `<git_dir>/objects` (the common directory's `objects/` for a linked worktree). When the [`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html) passed in [`RepositoryOptions`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html) sets [`git_object_directory`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html#structfield.git_object_directory) (`GIT_OBJECT_DIRECTORY`), that directory is the primary instead: reads and writes go there, and a relative path resolves against the environment's current directory. The directory must exist, and an empty value fails to open, as in Git. Also as in Git, `<git_dir>/objects` is then reachable only as an alternate, through [`git_alternate_object_directories`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html#structfield.git_alternate_object_directories) or the new directory's `info/alternates`. This is how hooks and quarantines keep new objects out of the shared store. Fetch, pull and push through [`Repository::remotes`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.remotes) read and write through the repository's own store, and the git-dir based fetch functions open the repository with `FetchOptions::environment`.

## Backend failures

An error from your store's `read`, `read_info` or `contains` (a dropped connection, a locked database) reaches the caller as that error, not as a missing object. To test for an object, call [`Odb::contains`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.contains): it walks the lookup order like a read does and returns the first source failure, so it never reports an object as present that `Odb::read` cannot return. Fetch and push negotiation, write-tree, ref checks and rev-parse all use it, so an outage stops the operation with a retryable error instead of re-sending objects or reporting broken refs. [`Odb::exists`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.exists) is the infallible form: it treats a failing source as not having the object, so keep it for hints where a wrong answer is harmless.

A damaged copy ([`ObjectError::Zlib`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.Zlib) or [`ObjectError::Corrupt`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.Corrupt)) inside a [`CompositeStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/struct.CompositeStore.html), including the alternates chain, is treated differently from an outage: the read moves on to the next child and returns its good copy if it has one. When no child can return the object, the caller gets the first corruption error rather than a missing object, so bit rot in one replica is never mistaken for an absent object.

## Building a custom repository

Pass your store to [`RepositoryOptions::with_object_store`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_object_store) when calling [`Repository::open`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.open), or when creating the repository with [`Repository::init`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.init) (see [Creating a repository on your stores](#creating-a-repository-on-your-stores)). That is the only way to replace the files primary. The repository still resolves its `objects/` directory (`GIT_OBJECT_DIRECTORY` included) and the opened [`Odb`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) reports its canonical path, but no object is read from or written to it and it need not exist. With `GIT_OBJECT_DIRECTORY` set, the custom store still wins and the environment's directory is left untouched. Add read sources, a commit-graph or an alternates override with an [`OdbBuilder`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.OdbBuilder.html) through [`RepositoryOptions::with_odb_builder`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_odb_builder); it works with the files primary as well.

The custom primary and every read source must hash with the repository's object format: the `extensions.objectformat` value in `<git_dir>/config`, or SHA-1 when that key or the config file is missing. Create the store with the same [`HashAlgo`](https://docs.rs/grit-lib/latest/grit_lib/objects/enum.HashAlgo.html) the repository was initialized with (`MemoryStore::new(HashAlgo::Sha256)` for a SHA-256 repository). A store that reports another algorithm through `ObjectStore::hash_algo` fails to open with [`RepositoryError::ObjectFormatMismatch`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html#variant.ObjectFormatMismatch), whose `repository` and `store` fields name the two algorithms, instead of writing object ids the repository's refs, index and config disagree with.

## Creating a repository on your stores

[`Repository::init`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.init) through [`InitOptions::with_repository_options`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.InitOptions.html#method.with_repository_options) seeds `HEAD` in an injected ref store and writes only the git-directory pieces your backends do not own (see the init table in [Writing storage backends](https://grit-scm.com/docs/library/object-stores/storage-backends.md/index.md#what-repositoryinit-writes)).

```rust
//! Create a repository whose primary object store is an in-memory [`MemoryStore`].
//!
//! Writes go to memory; [`Repository::init`] creates no `objects/` directory on disk.

use std::sync::Arc;

use grit_lib::config::environment::RepositoryOptions;
use grit_lib::objects::odb::store::{MemoryStore, ObjectStore};
use grit_lib::objects::{HashAlgo, ObjectKind};
use grit_lib::repo::{InitOptions, Repository};

fn main() -> grit_lib::error::Result<()> {
    let dir = tempfile::tempdir()?;
    let store = Arc::new(MemoryStore::new(HashAlgo::Sha1));
    let (repo, _) = Repository::init(
        dir.path(),
        &InitOptions::new()
            .with_repository_options(RepositoryOptions::empty().with_object_store(store.clone())),
    )?;

    let blob = repo.odb().write(ObjectKind::Blob, b"hello")?;
    println!("blob={blob}");
    println!("in_memory={}", store.contains(&blob)?);
    println!("objects_dir={}", repo.git_dir().join("objects").exists());
    Ok(())
}
```

```bash
cargo run -p grit-examples --bin memory_primary
```

## No git directory at all

When both the object store and the ref store are injected, [`Repository::open`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.open) reads nothing from the git directory's layout: it may be empty or missing. Repository config is still read from `<git_dir>/config` when that file exists; to keep config in memory instead, set it on the [`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html) with [`Environment::push_config_override`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html#method.push_config_override) (the `-c key=value` mechanism) and set [`git_config_nosystem`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html#structfield.git_config_nosystem) so `/etc/gitconfig` stays out. Seed `HEAD` with [`RepositoryOptions::with_initial_branch`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_initial_branch), or create the repository with `Repository::init` as above, which seeds it for you:

```rust
use std::sync::Arc;

use grit_lib::config::environment::{ConfigOverride, Environment, RepositoryOptions};
use grit_lib::objects::HashAlgo;
use grit_lib::objects::odb::store::MemoryStore;
use grit_lib::refs::store::MemoryRefStore;

let mut env = Environment::empty();
env.git_config_nosystem = Some("1".to_owned());
env.push_config_override(&ConfigOverride::new("user.name", Some("Ada".to_owned()))?);
let git_dir = std::path::Path::new("/nowhere/in-memory.git");
let repo = Repository::open(
    git_dir,
    &RepositoryOptions::with_environment(env)
        .with_object_store(Arc::new(MemoryStore::new(HashAlgo::Sha1)))
        .with_ref_store(Arc::new(MemoryRefStore::new()))
        .with_initial_branch("main"),
)?;
# Ok::<(), grit_lib::error::Error>(())
```

A bare repository opened this way never creates its git directory. [`grit-lib/tests/repository_no_filesystem.rs`](https://github.com/gitbutlerapp/grit/blob/main/grit-lib/tests/repository_no_filesystem.rs) builds commits, moves refs, walks and diffs history, merges trees, blames, adds notes, writes a bundle into a `Vec`, rewrites history and fetches from a files repository, then checks that nothing was created on disk. What works and what still needs a `.git` directory on disk:

| Area | Without a git directory |
| ---- | ----------------------- |
| Objects, trees and commits (`repo.objects()`) | Work through the store. |
| Refs, reflogs, `HEAD` and ref transactions (`repo.references()`) | Work through the ref store. |
| Config (`repo.config()`) | Comes from the `Environment`. |
| Rev-parse, revwalk and log | Work. |
| Tree diff, [`write_merge_tree`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/merge/struct.WrittenMergeTree.html) and blame at a commit | Work. |
| Notes, and bundles written to any `Write` ([`RepositoryBundles::write_to`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryBundles.html#method.write_to)) | Work. |
| History edits ([`History::reword`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.reword), [`History::apply`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.apply)) | Work. |
| Fetch from a path or URL | Works. The pack is spooled in the system temp directory and removed after ingest, and `FETCH_HEAD` is not written. |
| Hooks | A missing hooks directory means no hooks. |
| The index, staging and worktree commits | Need the git directory: the index, `COMMIT_EDITMSG` and merge, revert and rebase state live there, and staging creates it. |
| Work-tree operations (checkout, switch, status, reset, stash) | Need a work tree and an index. |
| Linked worktrees | Need their admin directories under `worktrees/`. |
| rerere and sparse-checkout | Need their state files in the git directory. |
| Hooks that expect `GIT_DIR` on disk | Not supported: objects and refs held by the stores are invisible to other programs. |
| gc and prune | Work when the store implements `PrunableObjectStore` (see [Garbage collection on a custom store](#garbage-collection-on-a-custom-store)); refused with `UnsupportedObjectStore` otherwise. |
| Repack, commit-graph and multi-pack-index files | Refused with `UnsupportedObjectStore` (see below). |

The same table is on [`RepositoryOptions::with_object_store`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_object_store). With only the object store injected, refs, reflogs and `HEAD` stay in the git directory as usual.

Hooks still run, but there is nothing on disk for another program to open. They start in the work tree (the git directory when there is none), and `GIT_DIR` is exported only when the [`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html) you passed sets [`git_dir`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html#structfield.git_dir); opening a path through [`Repository::open`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.open) does not set it. Even when it is set, objects and refs held in memory are invisible to the system `git`, so a `pre-commit` hook that runs `git status` or `git rev-parse` fails with "not a git repository". Keep hooks for such repositories to work that only needs the work tree and the hook's arguments.

## What works with a custom primary

Object reads and writes go through your store, so commits, staging (`porcelain::add::stage` and auto-staging commits), log, diff, merge (including cherry-pick and revert), stash, notes, bundle creation and unbundling all work.

[`Maintenance::fsck`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.fsck) works too: it lists the store's objects with `ObjectStore::for_each_object`, re-hashes each one against its id and runs the usual object and connectivity checks. Read or hash failures are reported as `FsckIssue::BadObject`, since there is no loose file path to name.

[`Remote::fetch`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.Remote.html#method.fetch), [`Remote::push`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.Remote.html#method.push), pull, bundle fetch, [`clone_into`](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/fn.clone_into.html), and smart HTTP serving ([`UploadPack`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.UploadPack.html) / [`ReceivePack`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePack.html)) read and write objects through the custom primary (pack bytes are resolved into the store with [`ingest_received_pack`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.ingest_received_pack.html) or the receive-pack overlay described below). Partial-clone filters are not supported yet.

An operation that needs the on-disk `objects/` layout refuses a custom primary with [`RepositoryError::UnsupportedObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html#variant.UnsupportedObjectStore). Its `operation` field is a [`FilesOnlyOperation`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html), so match the variant rather than the message; `FilesOnlyOperation::as_str` gives the name below, which `grit --json` reports as `operation` with `kind` `unsupported_object_store` (see [Exit codes](https://grit-scm.com/docs/exit-codes/index.md)). The table is generated from the enum's rustdoc:

| Name | Variant | Description |
| --- | --- | --- |
| `gc` | [`Gc`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.Gc) | Garbage collection without a repository: [`Odb::gc`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.gc) on an `Odb` built standalone, with no git directory to find reachability roots in. |
| `prune` | [`Prune`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.Prune) | Deleting unreachable objects from a custom primary that cannot delete ([`WritableObjectStore::as_prunable`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/trait.WritableObjectStore.html#method.as_prunable) is `None`): [`Maintenance::prune_loose_objects`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.prune_loose_objects), [`refs::gc::prune_loose_unreachable`](https://docs.rs/grit-lib/latest/grit_lib/refs/gc/fn.prune_loose_unreachable.html), [`Odb::gc`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.gc), [`Maintenance::gc`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.gc). Implement [`PrunableObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.PrunableObjectStore.html) to support them. |
| `repack` | [`Repack`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.Repack) | Repacking into `objects/pack/`: [`Maintenance::repack`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.repack) and [`Maintenance::repack_all`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.repack_all). |
| `commit_graph_write` | [`CommitGraphWrite`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.CommitGraphWrite) | Writing `objects/info/commit-graph`: [`Odb::write_commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.write_commit_graph) and [`Maintenance::write_commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.write_commit_graph). A custom store builds its graph in memory with [`Maintenance::build_commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.build_commit_graph) instead. |
| `midx_write` | [`MidxWrite`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.MidxWrite) | Writing `objects/pack/multi-pack-index`: [`Maintenance::write_midx`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.write_midx). |
| `pack_store` | [`PackStore`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.PackStore) | The files backend’s pack and MIDX read cache: [`Odb::pack_store`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.pack_store). |
| `pack_install` | [`PackInstall`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.PackInstall) | Installing a pack file and its `.idx` under `objects/pack/`: [`index_pack::install_pack_bytes`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.install_pack_bytes.html) and [`index_pack::install_pack_path`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.install_pack_path.html). Use [`index_pack::ingest_received_pack`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.ingest_received_pack.html) to write a pack into any primary. |
| `largest_pack_index` | [`LargestPackIndex`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.LargestPackIndex) | Finding the largest pack index in `objects/pack/`: [`Odb::largest_pack_index_path`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.largest_pack_index_path). |
| `loose_write` | [`LooseWrite`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.LooseWrite) | Writing loose object files into `objects/`: [`Odb::write_local`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.write_local), [`Odb::write_raw_local`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.write_raw_local) and [`Odb::write_loose_materialize`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.write_loose_materialize). [`Odb::write`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.write) works with any primary. |
| `files_source` | [`FilesSource`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.FilesSource) | The files-backed primary source itself: [`Odb::primary`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.primary). Use [`Odb::primary_writable`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.primary_writable) for the primary of any kind. |
| `offload` | [`Offload`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.Offload) | Moving blobs to a large-object promisor: [`Maintenance::offload_blobs`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.offload_blobs), for the main repository and for the promisor repository. |
| `promisor_rewrite` | [`PromisorRewrite`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.PromisorRewrite) | Rewriting packs to leave out promised objects, as offload and dropping promised blobs do. |
| `partial_fetch` | [`PartialFetch`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.PartialFetch) | Fetching or cloning with an object filter (a partial clone) into a custom primary. |
| `receive_quarantine` | [`ReceiveQuarantine`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.ReceiveQuarantine) | The receive-pack quarantine directory under `objects/`. A custom primary receives pushes through an in-memory overlay instead. |
| `drop_large_blobs` | [`DropLargeBlobs`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.DropLargeBlobs) | Dropping promised blobs from promisor packs: [`Maintenance::drop_promised_blobs`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.drop_promised_blobs). |


Repack, multi-pack-index and commit-graph writes stay files-only by design: packs, `.idx`, multi-pack-index and commit-graph files are how the files backend stores objects, and a custom store owns its own layout. A custom store still gets a commit-graph, built in memory and kept in its own storage (see [Commit-graphs for a custom store](#commit-graphs-for-a-custom-store)), and garbage collection when it can delete objects (next section). Use `Odb::files_objects_dir` when you need the on-disk `objects/` path only for files-backed repos.

## Garbage collection on a custom store

A store that can delete objects implements [`PrunableObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.PrunableObjectStore.html) and returns `Some(self)` from [`WritableObjectStore::as_prunable`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.WritableObjectStore.html#method.as_prunable). `MemoryStore` does. Then these work on a repository whose primary is that store:

| API | What it does on a custom store |
| --- | --- |
| [`Maintenance::prune_loose_objects`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.prune_loose_objects) | Deletes unreachable objects older than `gc.pruneExpire` (or `PruneOptions::older_than`) |
| [`Maintenance::gc`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.gc) | Pack-refs, reflog expiry, then the same prune; repack, drop-large-blobs and the commit-graph write are skipped |
| [`Odb::gc`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.gc) | Deletes every unreachable object, with no grace period |
| [`refs::gc::prune_loose_unreachable`](https://docs.rs/grit-lib/latest/grit_lib/refs/gc/fn.prune_loose_unreachable.html) | Deletes what your own root set does not reach |

Reachability is the same as for the files backend: every ref, every reflog entry (including linked worktrees' reflogs), `HEAD` and the index of each worktree, and the stash; walks stop at shallow boundaries. Grit lists your objects with `ObjectStore::for_each_object`, walks the graph once, passes the unreachable ids to `PrunableObjectStore::remove` in batches, and calls `WritableObjectStore::flush` at the end.

The grace period comes from [`PrunableObjectStore::object_mtime`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.PrunableObjectStore.html#method.object_mtime), which plays the part of a loose file's modification time. It defaults to `None`, and an object without a known time is kept whenever a grace period applies: with the default `gc.pruneExpire` of `2.weeks.ago`, a store that records no times (like `MemoryStore`) loses nothing until you prune with `now`. Record a time on `write` and `freshen` to get Git's behavior. The clock a relative expiry is measured from is passed in (`PruneOptions::with_now`, `GcOptions::now_unix`).

With `extensions.preciousObjects` set, `prune_loose_objects` and `Odb::gc` fail with `RepositoryError::PreciousObjectsRepository` (on the files backend too), and `maintenance::gc` on a custom store skips its prune step (`GcStats::prune_ran` stays false).

A store whose `as_prunable` is `None` is never pruned: those calls fail with `UnsupportedObjectStore` and `operation` `prune` before touching anything, and never fall back to the `objects/` directory.

## Filesystem-only by design

Some parts of grit-lib read or write `objects/` on disk directly, because what they work on is the files layout itself or a directory that only exists on disk. None of them runs against your store's objects:

| Area | Why it needs `objects/` on disk |
| ---- | ------------------------------- |
| The files backend | The files primary inside `Odb`, the loose, pack and multi-pack-index stores, and the pack readers and writers they are built from. |
| Maintenance | `gc`, repack, prune, offload, commit-graph, multi-pack-index and pack bitmap writing rewrite the files layout. On a custom primary they are refused (see the table above). |
| Pack install | Installing a received pack as `objects/pack/pack-*.pack` (index-pack, bundle install, fetch's pack spool) and receive-pack's on-disk quarantine. A custom primary takes the ingest path instead. |
| Repository layout | Opening a repository with the default files primary, discovering a repository from a directory, and creating the directories of a new repository. |
| Submodules and alternates | A submodule's git dir and `objects/info/alternates` name directories on disk. Alternates are read for the files primary unless `OdbBuilder::alternates(false)`, and for a custom primary only with `OdbBuilder::alternates(true)`. |
| Local-path transport | Fetch, push and clone from a peer repository given as a local path open that repository's own files store. |
| Gated fast paths | Rev-list, merge-base, fsck, bitmap walks, change-id lookup and author grouping (`log --group-by author`) read packs directly only after checking that the primary is the files backend, or that a pack bitmap exists. A custom primary takes the general path through `ObjectStore`. |
| Git-directory fallbacks | Functions that take only a git directory path, such as `refs::write_ref`, `refs::pack_remote_tracking_refs_for_clone`, `remote::list_refs_from_git_dir` without an `Odb`, and `promisor_pack_object_ids`, have no repository to ask, so they use that directory's files database. Called through a `Repository`, the same work (ref updates, `packed-refs` peel lines, ls-refs peeling) goes through your store. |
| Scratch databases | Throwaway, empty databases in a temporary directory, such as the one the thin-pack check indexes a received pack against. They never hold your objects. |

A source-scan test in grit-lib (`storage_backend_guard`) keeps this list honest: any new direct access to `objects/` outside these areas fails the build, and the places that still bypass a custom store are tracked there until they go through it.

## Fast history walks

Rev-list, merge-base and path-limited log read every commit they cross through [`ObjectStore::read_into`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.ObjectStore.html#method.read_into), into one buffer the walk reuses. Implement it to copy or decode your stored bytes straight into that buffer. The default goes through `read`, which allocates an owned `Object` per commit before copying it. Without a commit-graph, a store that implements `read_into` walks history about as fast as the files backend: on a 120,000-commit history, counting every commit takes the same time through a pass-through store as through the files backend.

## Change ids and author counts

A change id used as a revision (or passed to [`find_commits_by_change_id_prefix`](https://docs.rs/grit-lib/latest/grit_lib/change_id/fn.find_commits_by_change_id_prefix.html)) names a commit by the `change-id` header grit stamps into it, or by the id derived from its commit id when it has none. Finding a stored header means walking every commit reachable from your refs and reading its header. On the files backend grit records under `objects/info` whether any object holds a change-id header at all, so a repository without them (a clone of a project that never used grit) skips the header scan and matches derived ids from the walk alone. A custom primary has no such record and grit writes nothing to disk for it, so every lookup reads each reachable commit's header through `ObjectStore::read_into`, spread over the repository's worker threads.

On a git.git clone (86,000 commits, release build, 4-vCPU VM) a warm lookup takes about 72 ms on the files backend, which walks its commit-graph and skips the scan. Git's closest operation, `git rev-list --all --count`, takes 76 ms. With the same commits in a `MemoryStore` and no attached graph, a lookup takes about 243 ms: about 217 ms walking history through the store and about 26 ms scanning headers. Attaching a commit-graph (see [Commit-graphs for a custom store](#commit-graphs-for-a-custom-store)) shortens the walk, and implementing `read_into` (see [Fast history walks](#fast-history-walks)) keeps each header read down to one copy. A store that pays per call pays it once per commit, on every lookup.

Author counts (`log --group-by author`) read packs, the pack bitmap and commit-graph files directly on the files backend. On a custom primary they read each commit through the store instead, and walk parents through the commit-graph attached with `OdbBuilder::commit_graph`, if there is one. The counts are the same either way.

## Commit-graphs for a custom store

A commit-graph lets walks skip reading commit objects entirely. Parents, root trees, committer dates and generation numbers come from the graph, and so do changed-path Bloom filters for `log -- <path>`. On the 120,000-commit history above, counting commits drops from about 650 ms to about 40 ms.

Graph files under `objects/info/` describe the files layout, not your store, so grit never reads them for a custom primary: a stale or foreign graph there cannot make a walk report commits your store does not have. Instead:

1. Build the graph through any `Odb` with [`repo.maintenance().build_commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.build_commit_graph). It walks every commit reachable from the repository's refs and returns a [`CommitGraphBuild`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.CommitGraphBuild.html): either a [`BuiltCommitGraph`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.BuiltCommitGraph.html) or, in a shallow repository or one with grafts or replace refs, the [`CommitGraphSkipReason`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/enum.CommitGraphSkipReason.html) no graph may be built.
2. Store `BuiltCommitGraph::bytes` wherever your backend keeps its data. They are byte for byte the file Git writes to `objects/info/commit-graph`, and `git commit-graph verify` accepts them.
3. When you open the repository, turn stored bytes into a chain with [`BuiltCommitGraph::to_chain`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.BuiltCommitGraph.html#method.to_chain) (or build fresh from step 1 and call `to_chain` on the result) and attach it with [`OdbBuilder::commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.OdbBuilder.html#method.commit_graph).

```rust
use std::sync::Arc;

use grit_lib::config::environment::RepositoryOptions;
use grit_lib::maintenance::{CommitGraphBuild, CommitGraphOptions};
use grit_lib::objects::odb::store::WritableObjectStore;
use grit_lib::objects::odb::OdbBuilder;
use grit_lib::repo::{Repository};
use grit_lib::maintenance::BuiltCommitGraph;

fn open(
    git_dir: &std::path::Path,
    store: Arc<dyn WritableObjectStore>,
    graph: Option<Vec<u8>>,
) -> grit_lib::error::Result<Repository> {
    let mut layers = OdbBuilder::new();
    if let Some(bytes) = graph {
        let built = BuiltCommitGraph { bytes };
        layers = layers.commit_graph(Arc::new(built.to_chain()?));
    }
    Repository::open(
        git_dir,
        &RepositoryOptions::empty()
            .with_object_store(store)
            .with_odb_builder(layers),
    )
}

fn refresh_graph(repo: &Repository) -> grit_lib::error::Result<Option<Vec<u8>>> {
    match repo
        .maintenance()
        .build_commit_graph(&CommitGraphOptions::with_changed_paths(true))?
    {
        CommitGraphBuild::Built(graph) => Ok(Some(graph.bytes)),
        CommitGraphBuild::Skipped(_) => Ok(None),
    }
}
```

An attached graph is trusted, not checked against the store: every commit it lists must be in the store with the parents and tree it records, which holds for a graph built from the same repository. Commits written after the graph was built are not in it and are read from the store as usual, so rebuilding now and then (with your other maintenance) is enough. With changed paths on, a rebuild reuses the Bloom filters of the attached graph and only computes filters for new commits. The graph's hash algorithm must match the repository's object format, or opening fails with [`RepositoryError::ObjectFormatMismatch`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html#variant.ObjectFormatMismatch). `OdbBuilder::commit_graph` works for a files primary too, and takes the place of its on-disk graph.

### Benchmarks

A 120,000-commit linear history (350 files, 44 MB `.git`, one pack) on a 4-vCPU Linux VM, release build, best of three, in milliseconds. The custom store is a pass-through over the same repository's files backend, so only the cost of the store interface differs. Git 2.43 timings are hyperfine means of the matching commands.

| Operation | Git, no graph | Files backend | Custom store, before | Custom store | Git, graph | Custom store, attached graph |
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
| `rev-list --count HEAD` | 425 | 651 | 1129 | 682 | 75 | 41 |
| `rev-list --count HEAD~100000..HEAD` | 356 | 285 | 661 | 304 | 67 | 110 |
| `merge-base HEAD~60000 HEAD~10` | 196 | 161 | 381 | 163 | 36 | 40 |
| `log -n 20 -- dir7/f3.txt` | 53 | 43 | 95 | 52 | 10 | 8 |

"Before" is grit-lib before custom-store reads stopped installing the files backend's pack-read context on every object. The graph columns use changed-path Bloom filters. Peak memory for all four walks in one process is about 187 MB for the files backend and for the custom store without a graph, and 46 MB with the attached graph.

## Receiving packs into a custom store

Fetch, clone, push and bundles move objects as a pack stream. [`ingest_pack_into`](https://docs.rs/grit-lib/latest/grit_lib/objects/unpack_objects/fn.ingest_pack_into.html) applies one to any [`WritableObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.WritableObjectStore.html): it inflates each object, resolves `OFS_DELTA` and `REF_DELTA` chains, verifies the pack checksum, and calls `write` for every object. A *thin* pack (one whose deltas name bases the sender knew you have) resolves those bases from the `bases` store you pass, after looking in the target store itself. Objects up to 1 MiB stay in memory until the pack is resolved; larger blobs are read back from your store when a delta needs them.

The repository-level entry points use it automatically. [`ingest_received_pack`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.ingest_received_pack.html) and [`ingest_received_pack_path`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.ingest_received_pack_path.html) write into a custom primary instead of installing `objects/pack/pack-*.pack`, reading thin bases through the whole `Odb`; the returned [`IngestedPack`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/struct.IngestedPack.html) has `pack_path: None`. Each successful ingest ends with one [`Odb::flush`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.flush) on the primary (one store round trip per new object during unpack, not a `contains` probe on read sources). [`Bundle::unbundle`](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.Bundle.html#method.unbundle) streams the bundle's pack straight from the file into your store, with no temporary copy.

[`ReceivePack`](https://docs.rs/grit-lib/latest/grit_lib/remote/serve/struct.ReceivePack.html) uses the same quarantine contract on a custom primary: the pack is spooled to a system temp file, unpacked object-by-object into an in-memory overlay whose read side is the repository's [`Odb::read_store`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.read_store), and nothing is copied into your primary until pre-receive succeeds. Then the overlay objects are written through [`Odb::primary_writable`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.primary_writable) and [`Odb::flush_for_publish`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.flush_for_publish). A declined push or a corrupt pack drops the overlay with no primary writes. Shell hooks do not get `GIT_OBJECT_DIRECTORY` / `GIT_QUARANTINE_PATH` for a memory overlay (only the files quarantine sets them). Objects that were published and then lose a later ref update stay in the store, as on the files backend after the quarantine migrates, until garbage collection removes them: that needs a store with the prune capability (see [Garbage collection on a custom store](#garbage-collection-on-a-custom-store)).

```rust
//! Apply a pack stream to a custom object store.
//!
//! Builds a pack from a files-backed repository (as a fetch, push or bundle would
//! deliver it), then writes its objects into an in-memory store two ways: straight
//! through the [`WritableObjectStore`](https://grit-scm.com/docs/library/object-stores/grit_lib::objects::odb::store::WritableObjectStore/index.md)
//! trait, and through a repository whose primary is that store.

use grit_lib::objects::FileMode;
use std::io::Cursor;
use std::sync::Arc;

use grit_lib::config::environment::RepositoryOptions;
use grit_lib::objects::index_pack::{ingest_received_pack, IngestPackOptions};
use grit_lib::objects::odb::store::{MemoryStore, ObjectStore};
use grit_lib::objects::pack_objects::{build_pack, PackBuildOptions};
use grit_lib::objects::unpack_objects::{ingest_pack_into, UnpackOptions};
use grit_lib::objects::{serialize_tree, HashAlgo, ObjectId, ObjectKind, TreeEntry};
use grit_lib::refs::store::MemoryRefStore;
use grit_lib::repo::{InitOptions, Repository};

fn main() -> grit_lib::error::Result<()> {
    let dir = tempfile::tempdir()?;
    let (source, _) = Repository::init(&dir.path().join("source"), &InitOptions::default())?;
    let mut parent = None;
    let mut tip = ObjectId::zero();
    for version in 1..=2 {
        let blob = source
            .odb()
            .write(ObjectKind::Blob, format!("version {version}\n").as_bytes())?;
        let tree = source.odb().write(
            ObjectKind::Tree,
            &serialize_tree(&[TreeEntry::new(b"file.txt", FileMode::REGULAR, blob)]),
        )?;
        let parent_line = parent.map(|p| format!("parent {p}\n")).unwrap_or_default();
        let body = format!(
            "tree {tree}\n{parent_line}author A <a@example.com> 1 +0000\ncommitter A <a@example.com> 1 +0000\n\nv{version}\n"
        );
        tip = source.odb().write(ObjectKind::Commit, body.as_bytes())?;
        parent = Some(tip);
    }
    let pack = build_pack(source.odb(), &[tip], &[], &PackBuildOptions::default())?;
    println!("pack_bytes={}", pack.len());

    // Any WritableObjectStore: deltas are resolved and each object is written.
    let store = MemoryStore::new(HashAlgo::Sha1);
    let ingested = ingest_pack_into(
        &mut Cursor::new(&pack),
        &store,
        &store,
        &UnpackOptions::default(),
        &mut grit_lib::progress::NullProgress,
        &grit_lib::progress::CancelToken::never(),
    )?;
    println!("store_objects={}", ingested.object_ids.len());
    println!("store_has_tip={}", store.contains(&tip)?);

    // A repository whose primary is a custom store: the same entry point fetch and
    // clone use writes into that store instead of installing a pack under objects/.
    let git_dir = dir.path().join("custom.git");
    std::fs::create_dir_all(&git_dir)?;
    let primary = Arc::new(MemoryStore::new(HashAlgo::Sha1));
    let repo = Repository::open(
        &git_dir,
        &(RepositoryOptions::empty()
            .with_object_store(primary.clone())
            .with_ref_store(Arc::new(MemoryRefStore::new()))
            .with_initial_branch("main")),
    )?;
    let received = ingest_received_pack(
        pack,
        repo.odb(),
        &IngestPackOptions::default(),
        &mut grit_lib::progress::NullProgress,
        &grit_lib::progress::CancelToken::never(),
    )?;
    println!("repo_objects={}", received.object_ids.len());
    println!("repo_commits={}", received.object_counts.commits);
    println!("pack_installed={}", received.pack_path.is_some());
    println!("repo_reads_tip={}", repo.odb().read(&tip).is_ok());
    Ok(())
}
```

```bash
cargo run -p grit-examples --bin ingest_pack_into_store
```

For a lower-level hook, [`RepositoryRemotes::fetch_from`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.fetch_from) with [`TransferEndpoint::Connection`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/enum.TransferEndpoint.html#variant.Connection) drives wire negotiation on an open [`Connection`](https://docs.rs/grit-lib/latest/grit_lib/remote/transport/trait.Connection.html) and ingests into the repository's primary store. With [`FetchOptions`](https://docs.rs/grit-lib/latest/grit_lib/remote/transfer/struct.FetchOptions.html) configured to spool the negotiated pack without index-pack, you receive a temp pack file and ingest it yourself with [`ingest_received_pack_path`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.ingest_received_pack_path.html) or [`ingest_pack_into`](https://docs.rs/grit-lib/latest/grit_lib/objects/unpack_objects/fn.ingest_pack_into.html). Going the other way, [`build_pack`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_objects/fn.build_pack.html) on the custom repository's `Odb` produces a pack that `git index-pack --strict` accepts.

## Short ids and prefix lookup

Resolving a short id and abbreviating an id (for example [`RevWalk::abbreviate`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.abbreviate)) both call [`ObjectStore::lookup_prefix`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.ObjectStore.html#method.lookup_prefix) once per id. A backend only has to implement `for_each_object`: the default `lookup_prefix` parses the prefix once into an [`ObjectIdPrefix`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectIdPrefix.html) and compares raw id bytes without allocating, so each call is one pass over the whole store (about 1 ms per 200 000 ids on the factory VM).

For a label that does not need to resolve back to the id (log lines, conflict markers, status rows), [`ObjectId::to_short_hex`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectId.html#method.to_short_hex) returns the first seven hex digits without touching the store, and [`short_hex`](https://docs.rs/grit-lib/latest/grit_lib/objects/fn.short_hex.html) does the same for a hex string you already hold.

If your backend keeps ids sorted (a B-tree, an ordered key-value store, an SQL index on the raw id), override `lookup_prefix` with a range scan. Every id that starts with the prefix lies between [`ObjectIdPrefix::lowest`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectIdPrefix.html#method.lowest) and [`ObjectIdPrefix::highest`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectIdPrefix.html#method.highest), inclusive, and nothing else does:

```rust
use std::collections::BTreeSet;

use grit_lib::error::Result;
use grit_lib::objects::{HashAlgo, ObjectId, ObjectIdPrefix};

fn lookup_prefix(
    ids: &BTreeSet<ObjectId>,
    prefix: &str,
    limit: usize,
    out: &mut Vec<ObjectId>,
) -> Result<()> {
    let prefix = ObjectIdPrefix::from_hex(prefix, HashAlgo::Sha1)?;
    let matches = ids.range(prefix.lowest()..=prefix.highest());
    out.extend(matches.take(if limit == 0 { usize::MAX } else { limit }));
    Ok(())
}
```

## Batched existence checks

When grit needs to know whether many objects exist at once, it calls [`ObjectStore::contains_many`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.ObjectStore.html#method.contains_many) with the whole batch and expects one answer per id, in input order. Write-tree (and so every commit) uses it to confirm that the cached trees of unchanged directories still exist. Fetch and push negotiation use it to sort out which ids are already present. Local-path and `file://` clone or fetch into an empty custom primary does not probe existence at all (every reachable object is written once). An incremental local fetch or push into a non-empty custom primary asks `contains_many` once over the candidate send set. The default implementation calls `contains` once per id. A store that pays per call, such as a database or a network service, should override it to answer the batch in one query.

With an override, committing one changed file costs a handful of store calls however many directories the repository has: one batch for the reused trees, one for the changed directory's files, and one [`WritableObjectStore::write`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.WritableObjectStore.html#method.write) per new object (no Odb-level existence probe on a custom primary). Subtrees grit has just confirmed or written are not probed again. The reuse batch covers every layer of the database: the primary first, then each [`OdbBuilder::push_read_source`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.OdbBuilder.html#method.push_read_source) store and the alternates, each asked only about the trees earlier layers lack. An empty local cache in front of a slow read source therefore costs one batch to that source per commit, not one call per directory.

[`WritableObjectStore::flush`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.WritableObjectStore.html#method.flush) and [`WritableObjectStore::rollback`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.WritableObjectStore.html#method.rollback) let backends batch many writes (one transaction, one fsync). Pack ingest and [`Odb::flush`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.flush) before ref updates call flush on a custom primary; failed ingest calls rollback. Reads must observe successful writes before flush; flush is the durability barrier.

## Conformance tests

Object-store suites live in `grit_test_support::odb_conformance`; repository-level scenarios use `grit_test_support::repository_conformance`. See [Writing storage backends — Testing](https://grit-scm.com/docs/library/object-stores/storage-backends.md/index.md#testing) for `BackendFixture`, parity checks, and the SQLite example test.

## Example: append-only packfile KV store

`grit-examples` ships a single-file `PackfileKvStore` in `grit_examples::packfile_kv` (zlib records plus an in-memory index rebuilt on open) and a walkthrough that commits through a custom primary, walks history, and exports loose objects for system Git:

```rust
//! Custom append-only object store wired through [`RepositoryOptions::with_object_store`](https://grit-scm.com/docs/library/object-stores/grit_lib::config::environment::RepositoryOptions::with_object_store/index.md).
//!
//! Writes a small commit graph in the KV store, walks history with [`rev_list`],
//! then exports objects as loose files for interoperability with system Git.

use std::env;
use std::path::PathBuf;

use grit_examples::packfile_kv;

fn main() -> grit_lib::error::Result<()> {
    let (root, _tmpdir) = match env::args().nth(1) {
        Some(path) => (PathBuf::from(path), None),
        None => {
            let dir = tempfile::tempdir().map_err(grit_lib::error::Error::Io)?;
            let root = dir.path().to_path_buf();
            (root, Some(dir))
        }
    };
    let log = packfile_kv::run_custom_object_store_demo(&root)?;
    for oid in log {
        println!("{oid}");
    }
    Ok(())
}
```

## Example: SQLite object database

See [Writing storage backends — SQLite example](https://grit-scm.com/docs/library/object-stores/storage-backends.md/index.md#example-sqlite-object-database) for the walkthrough and conformance test. Implementation: [`grit_examples::sqlite_odb::SqliteOdbStore`](https://github.com/gitbutlerapp/grit/blob/main/grit-examples/src/sqlite_odb.rs).

# https://grit-scm.com/docs/library/objects/index.md

# Objects

> ObjectId, ObjectKind, and reading or writing blobs, trees, and commits through Odb.

Git stores four object kinds grit-lib exposes as [`ObjectKind`](https://docs.rs/grit-lib/latest/grit_lib/objects/enum.ObjectKind.html). Every object is named by an [`ObjectId`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectId.html) (SHA-1 by default). Prefer [`Repository::objects`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) ([`Objects`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Objects.html)) for read/write/contains; it delegates to the pluggable [`Odb`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) on the same [`Repository`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html).

## Writing

[`Objects::write`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Objects.html#method.write) takes a kind and payload bytes, stores a loose object under `objects/`, and returns the id. Tree, commit and tag payloads are checked first with the same rules as `git hash-object -t <kind>`: an unsorted tree, a duplicate entry, or an identity line without a timestamp fails with `InvalidObject` on [`Error`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html), which carries Git's fsck message id (`treeNotSorted`, `missingSpaceBeforeDate`, …), and nothing is written. [`Objects::write_literally`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Objects.html#method.write_literally) skips the checks, like `git hash-object --literally`; it exists to reproduce corrupt objects in tests. [`Odb::write`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.write) is the unchecked internal path the engine uses for objects it has built itself. Use [`parse_tree`](https://docs.rs/grit-lib/latest/grit_lib/objects/fn.parse_tree.html) and [`parse_commit`](https://docs.rs/grit-lib/latest/grit_lib/objects/fn.parse_commit.html) when reading objects back.

## Big objects

[`Odb::write_stream`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.write_stream) stores an object from any [`Read`](https://doc.rust-lang.org/std/io/trait.Read.html) of known size without holding it in memory. Objects of at least [`Odb::big_file_threshold`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.big_file_threshold) bytes (`core.bigFileThreshold`, 512 MiB unless configured) are hashed and deflated in fixed-size chunks straight into a new single-object pack at the pack compression level (`pack.compression` / `core.compression`), which is what Git does with big files; smaller objects are written loose as usual. If the object already exists, the new pack is discarded. [`Odb::hash_stream`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.hash_stream) computes the id the same way without storing anything. A reader that ends early fails with [`ObjectError::StreamTruncated`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.StreamTruncated).

Staging uses the same path: `add`, `commit` auto-staging and `status` stream every worktree file at or above the threshold whose content needs no clean conversion (no clean filter, `working-tree-encoding` or line-ending conversion), so their memory use does not grow with the file size. Files that need a conversion are read whole, as in Git.

Staging never stores content twice. Like Git, it freshens an existing copy instead of writing a new one: a blob already in a local pack (promisor packs included) or an alternate object directory gets its pack's mtime refreshed, and no loose object is written, so re-adding packed content (for example after `rm --cached -r .`) adds nothing to `objects/`. Only an object stored solely in a cruft pack, which cannot be freshened, is written loose again. Bulk staging sets [`WriteOptions::freshen_existing`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.WriteOptions.html#structfield.freshen_existing) only when the repository has a pack or an alternate, so writing into a repository without either skips the probe entirely. Callers of [`Odb::write_with`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.write_with) build the same options with `WriteOptions::default().with_freshen_existing(true)`; the loose-store hints in [`WriteOptions`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.WriteOptions.html) are ignored by custom object stores.

```rust
use std::fs::File;
use grit_lib::objects::ObjectKind;
use grit_lib::objects::odb::WriteOptions;

let mut file = File::open("dataset.bin")?;
let size = file.metadata()?.len();
let oid = repo.odb().write_stream(ObjectKind::Blob, size, &mut file, WriteOptions::default())?;
```

## Building trees and commits

A program that creates history without an index or work tree (a bare-repository tool, a changelog bot) should not assemble object bytes by hand. [`Objects::write_tree`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Objects.html#method.write_tree) takes [`TreeEntry`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeEntry.html) values ([`TreeEntry::new(name, mode, oid)`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeEntry.html#method.new), with a typed [`FileMode`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.FileMode.html)) in any order, sorts them into Git's tree order, and refuses entries `git fsck` would reject with a typed [`TreeEntryError`](https://docs.rs/grit-lib/latest/grit_lib/objects/enum.TreeEntryError.html): an empty, `.`, `..` or `.git` name, a `/` or NUL in a name, a mode other than `100644`, `100755`, `120000`, `40000` or `160000`, the null id, an id of the other hash algorithm, a name over 4096 bytes, a name used twice (a file and a directory with the same name count), or a symlink to a reserved metadata file name (`.gitmodules`, `.gitattributes`, and related spellings). Each entry's object must exist in the repository with the kind implied by its mode (tree or blob; gitlink `160000` entries may name a commit that is not stored locally), matching `git mktree` without `--missing`; missing or wrong-kind oids return [`ObjectError::NotFound`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.NotFound) or [`ObjectError::UnexpectedKind`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.UnexpectedKind) (under [`Error::Object`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Object)). Pass [`WriteTreeOptions::allow_missing`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.WriteTreeOptions.html#structfield.allow_missing) to [`Objects::write_tree_with`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Objects.html#method.write_tree_with) when building trees bottom-up or referencing objects a partial clone has not fetched (wrong kinds are still rejected).

[`Objects::write_commit`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Objects.html#method.write_commit) takes a [`NewCommit`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.NewCommit.html): a tree, parents, message, and author and committer as typed [`Signature`](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.Signature.html) values. [`Signature::new`](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.Signature.html#method.new) takes a name, an email and an `OffsetDateTime` and rejects `<`, `>` and control characters, times before 1970 and offsets with a seconds part ([`SignatureError`](https://docs.rs/grit-lib/latest/grit_lib/ident/enum.SignatureError.html)), so the header line always has Git's `Name <email> <unix> <±HHMM>` shape. `write_commit` checks that the tree is a tree and each parent is a commit, as `git commit-tree` does. It adds a trailing newline to the message when missing. When `grit.changeIds` is on (the default) the commit gets a fresh `change-id` header; call [`NewCommit::with_change_id`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.NewCommit.html#method.with_change_id) to keep the id of a change you are rewriting. The commit is not signed and no ref moves. To commit the index onto the current branch, use [`CommitRequest`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitRequest.html) (as `grit commit` does) instead.

For hot paths that only need headers (tree, parents, identities) or a borrowed message body, prefer [`CommitRef::parse`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.CommitRef.html#method.parse). It borrows from the object bytes and decodes author, committer, and message on demand via [`CommitRef::author`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.CommitRef.html#method.author), [`CommitRef::committer`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.CommitRef.html#method.committer), and [`CommitRef::message`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.CommitRef.html#method.message). [`parse_commit`](https://docs.rs/grit-lib/latest/grit_lib/objects/fn.parse_commit.html) is `CommitRef::parse(data)?.to_owned()` for callers that need an owning [`CommitData`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.CommitData.html).

[`Odb::hash`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) (or [`HashAlgo::hash_object`](https://docs.rs/grit-lib/latest/grit_lib/objects/enum.HashAlgo.html)) computes an id without writing—useful for dry runs and tests. The algorithm follows the repository’s configured object format (SHA-1 or SHA-256).

Object ids and file checksums share the same digest algorithms but serve different roles. [`ObjectHasher`](https://docs.rs/grit-lib/latest/grit_lib/objects/hash/struct.ObjectHasher.html) and [`HashAlgo::digest`](https://docs.rs/grit-lib/latest/grit_lib/objects/enum.HashAlgo.html) name Git objects (canonical `"<kind> <len>\\0<payload>"` bytes or raw payloads that become an [`ObjectId`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectId.html)). [`ChecksumHasher`](https://docs.rs/grit-lib/latest/grit_lib/objects/hash/struct.ChecksumHasher.html), [`HashAlgo::checksum_digest`](https://docs.rs/grit-lib/latest/grit_lib/objects/enum.HashAlgo.html), [`HashingWriter`](https://docs.rs/grit-lib/latest/grit_lib/objects/hash/struct.HashingWriter.html), and [`verify_trailer`](https://docs.rs/grit-lib/latest/grit_lib/objects/hash/fn.verify_trailer.html) cover pack, index, MIDX, and commit-graph trailers—integrity checks, not object identities.

## Collision detection

SHA-1 object ids are computed with collision detection (sha1dc). [`hash_object`](https://docs.rs/grit-lib/latest/grit_lib/objects/hash/fn.hash_object.html), [`HashAlgo::hash_object`](https://docs.rs/grit-lib/latest/grit_lib/objects/enum.HashAlgo.html#method.hash_object), [`HashAlgo::digest`](https://docs.rs/grit-lib/latest/grit_lib/objects/enum.HashAlgo.html#method.digest), [`ObjectHasher::finalize`](https://docs.rs/grit-lib/latest/grit_lib/objects/hash/struct.ObjectHasher.html#method.finalize), and [`Odb::hash`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.hash) return [`Result`](https://docs.rs/grit-lib/latest/grit_lib/error/type.Result.html) and surface [`ObjectError::HashCollision`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.HashCollision) (under [`Error::Object`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Object)) when a chosen-prefix collision is detected. Ingestion paths (`Odb::write`, pack indexing, worktree staging) propagate the same error instead of storing a colliding object.

```rust
use grit_lib::error::{Error, ObjectError};
use grit_lib::objects::{HashAlgo, ObjectKind};
use grit_lib::objects::hash::hash_object;

let payload = b"hello\n";
match hash_object(HashAlgo::Sha1, ObjectKind::Blob, payload) {
    Ok(oid) => println!("blob id {oid}"),
    Err(Error::Object(ObjectError::HashCollision { oid })) => {
        eprintln!("refusing colliding digest {}", oid.to_hex());
    }
    Err(e) => return Err(e.into()),
}
```

Patch ids, rerere ids, and pack/index trailers use [`ChecksumHasher`](https://docs.rs/grit-lib/latest/grit_lib/objects/hash/struct.ChecksumHasher.html)—same digests, not object identities, and no collision guard on those paths.

## Revision labels

[`Repository::revision_label`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.revision_label) returns an optional [`RevisionLabel`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/object_inspect/enum.RevisionLabel.html) for a short local branch or tag name. `HEAD` labels its symbolic local branch, including an unborn branch; detached `HEAD` has no label. Short branch names take precedence over equally named tags. It uses the repository's ref store, including injected backends. This is the classification used by `grit show`; resolve the revision separately when you need its object id.

`RevisionLabel::Tag` carries the tag ref's short name and an optional parsed annotation. Lightweight tags have no annotation. Annotated tags retain their original tag header, tagger, target, extra headers and untrimmed message; the target is not peeled. Missing labels return `None`, while unreadable tag objects and malformed annotations return library errors.

## Reading

[`Odb::read`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) returns an [`Object`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Object.html) with `kind` and uncompressed `data`. Packed and loose objects share the same API.

For hot loops (tree walks, batch cat-file), [`Odb::read_into`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.read_into) inflates into a caller-owned [`Vec`](https://doc.rust-lang.org/std/vec/struct.Vec.html) and returns the [`ObjectKind`](https://docs.rs/grit-lib/latest/grit_lib/objects/enum.ObjectKind.html). Payload bytes stay in the buffer; wrap them with [`ObjectRef::from_buf`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectRef.html#method.from_buf) when you need a borrowed view. The same method exists on [`ObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.ObjectStore.html) backends (default: copy from `read`; native for loose files and packs).

When you only need type and size (for example listing objects without loading blob bodies), use [`Odb::read_info`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) (see `read_info` on [`Odb`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html)). It returns [`ObjectInfo`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectInfo.html) and avoids inflating full payloads for loose objects and non-delta pack entries; delta chains are resolved from headers and delta size varints only.

## Streaming large objects

For user-facing object inspection, [`Repository::read_object_info_for_display`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.read_object_info_for_display) returns kind and size, and [`Repository::with_object_stream_for_display`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.with_object_stream_for_display) passes the payload reader to a callback. Both follow replace refs unless the repository environment disables them. `grit cat` uses these APIs to stream large blobs in human output; JSON and Markdown keep their documented content fields.

[`Odb::with_stream`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.with_stream) hands a callback an [`ObjectStream`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.ObjectStream.html) (kind, size and a reader over the payload) and returns the callback's result, or `None` when the object is missing. Loose objects and objects stored whole in a pack are inflated as you read, in fixed-size chunks, so copying a multi-gigabyte blob to a file takes a few hundred KiB of memory. Pack deltas are rebuilt in memory first, which Git also has to do. A truncated or corrupt object, including one whose zlib checksum fails, comes back as an `io::Error` from the reader. [`Odb::open_stream`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.open_stream) returns a stream that owns its payload, so it reads the whole object first. Use it only for small objects.

```rust
use std::io::{Read, Write};

let copied = odb.with_stream(&blob_id, |stream| {
    let mut reader = stream.reader;
    let mut buf = vec![0u8; 256 * 1024];
    loop {
        let n = reader.read(&mut buf)?;
        if n == 0 {
            break;
        }
        out.write_all(&buf[..n])?;
    }
    Ok(stream.size)
})?;
```

Checkout uses this path. `restore`, `switch`, `reset --hard` and clone stream any regular file larger than 1 MiB straight into the work tree when no content conversion applies to its path (no `ident`, `working-tree-encoding`, smudge filter or LF-to-CRLF setting; see `worktree_conversion_is_identity`). Files at or under 1 MiB, which is nearly all of them, are still read with one lookup: a loose object's header, or a whole pack entry's header, gives the size before the body is inflated, so the size check is part of the read. A file that does stream is looked up twice, once to size it and once to open the stream, and a whole pack entry's bytes are checked against the pack index CRC before streaming, so a corrupt copy is never streamed. Streamed data goes to a temporary file next to the destination, which is renamed into place only after the object's size and zlib checksum have been verified. A corrupt object fails the checkout and leaves the old file, or no file, in place. The check that a restored file matches its blob hashes large files in chunks too, when nothing would change the file on its way into Git (`git_conversion_is_identity`).

## Reading commits

[`Odb::read_commit`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.read_commit) (also on [`Objects`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Objects.html)) reads an id, checks it names a commit and returns the parsed [`CommitData`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.CommitData.html). When you only need the root tree, [`Odb::commit_tree`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.commit_tree) decodes just the commit headers. Neither follows annotated tags; peel first (see below) when the id may name one. An id that names a tree, blob or tag fails with `UnexpectedObjectKind` on [`Error`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html), which carries the id and both kinds, so callers can tell "wrong kind of object" from a missing or corrupt one without matching message text. Stash, merge, pull, the history engine and commit-graph Bloom filters read commits through these two methods.

One-line listings need less than a whole commit. [`Odb::read_commit_through_subject`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.read_commit_through_subject) returns the leading bytes of a commit's payload through the first non-blank line of its message: every header (tree, parents, author, committer, `change-id`, signatures) and the subject, so [`parse_commit`](https://docs.rs/grit-lib/latest/grit_lib/objects/fn.parse_commit.html) and [`read_commit_subject_line`](https://docs.rs/grit-lib/latest/grit_lib/objects/fn.read_commit_subject_line.html) give the same values as for the whole commit. For a commit stored whole in a pack it stops inflating at that line, so a long message body is never decompressed (or checked); deltas, loose objects and other stores read the commit whole and cut it. A commit that declares a non-UTF-8 `encoding`, or whose message has no line with a printable ASCII character, comes back whole, since where its subject ends is only known after decoding.

## Looking up a path in a tree

[`Odb::tree_entry_at_path`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.tree_entry_at_path) returns the [`TreeEntry`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeEntry.html) at a `/`-separated path such as `b"src/lib.rs"` under a root tree, or `None` when a component is missing or a directory on the way is really a file. The last entry comes back whatever its mode (file, symlink, gitlink or subtree), so filter on `mode` when only files will do. Trees on the way go through the handle's bounded tree cache and are scanned without allocating an entry per name, so looking up many paths under the same directories stays cheap. Diff, stash, blame, the history engine and snapshot checkout all look up single paths this way.

## Tree iteration without copying names

[`parse_tree`](https://docs.rs/grit-lib/latest/grit_lib/objects/fn.parse_tree.html) allocates an owning [`TreeEntry`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeEntry.html) for every name. For hot paths that only walk a tree once (object walks, pack enumeration, fsck), use [`TreeRefIter`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeRefIter.html): it yields [`TreeEntryRef`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeEntryRef.html) values that borrow name bytes from the tree blob. Pass the repository hash width with [`TreeRefIter::with_oid_len`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeRefIter.html#method.with_oid_len), or call [`TreeRefIter::infer_oid_len`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeRefIter.html#method.infer_oid_len) when the algorithm is not threaded through (same SHA-1-then-SHA-256 detection as [`parse_tree`](https://docs.rs/grit-lib/latest/grit_lib/objects/fn.parse_tree.html)). Call [`TreeEntryRef::to_owned`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeEntryRef.html#method.to_owned) when you need a [`TreeEntry`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TreeEntry.html). The compiled example below reads a tree with both APIs.

## Peeling tags

A ref tip can name an annotated tag, or a tag of a tag. `Odb::peel_tags` (on [`Odb`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html)) follows the chain and returns the id and kind of the first non-tag object; `Odb::peel_to_commit` returns `Some(commit)` when that object is a commit and `None` for a tree or blob. Only tag objects are read in full, and only their `object` header is parsed, so tags with non-UTF-8 messages peel fine; the final object's kind comes from `read_info`. Chains of any length are followed. A missing object, a tag without a valid `object` header, or a store that serves a tag cycle is an error, not `None`, so you can tell "not a commit" apart from a broken repository. Revision walks, fetch negotiation, bundles, commit-graph tips, `packed-refs` peel lines, tag listing and log decorations all peel through these two methods.

When you read a full annotated tag with [`parse_tag`](https://docs.rs/grit-lib/latest/grit_lib/objects/fn.parse_tag.html), the message body is stored as raw bytes like Git (there is no `encoding` header on tags). Invalid UTF-8 is decoded lossily into [`TagData::message`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TagData.html#structfield.message) (U+FFFD replacement characters), with the original bytes kept in [`TagData::raw_message`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TagData.html#structfield.raw_message) so [`serialize_tag`](https://docs.rs/grit-lib/latest/grit_lib/objects/fn.serialize_tag.html) round-trips the object id. This matches how grit treats commit messages without an `encoding` header.

## Pack read caching

[`Odb`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) owns a repository-scoped [`PackStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_store/struct.PackStore.html): pack directory listings, parsed `.idx` files, pack bytes, MIDX layers, and the delta-base LRU. Cloned [`Odb`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) handles share the same store; alternate object directories get separate stores on the parent [`Odb`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html). When the last handle to a [`PackStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack_store/struct.PackStore.html) is dropped, thread-local pack and index mappings for that store are released on the dropping thread.

After repack, garbage collection, or installing a pack with [`install_pack_bytes`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.install_pack_bytes.html), call [`Odb::invalidate_packs`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) so the next read rescans `objects/pack/`. If another [`Odb`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) in the same process still holds a stale listing, a lookup miss retriggers directory reprepare when the pack folder’s mtime changes.

For batch reads (`cat-file --batch`, `--batch-all-objects`), wrap the loop in [`Odb::with_pack_read_context`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) so pack indexes, mmap-backed pack bytes, and the delta-base LRU stay on one thread-local context instead of reinstalling it per object. [`Odb::read`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html) detects an active matching context and skips nested setup.

When iterating a pack in offset order (unordered `--batch-all-objects`), prefer [`read_object_from_pack_at_offset`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack/index.html) with the entry offset from [`PackIndex`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack/struct.PackIndex.html) so the read path does not repeat index lookup by OID.

The reverse direction, from a pack offset to the object stored there (resolving an `OFS_DELTA` base, for example), is [`PackIndex::find_position_by_offset_sorted`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack/struct.PackIndex.html#method.find_position_by_offset_sorted). Each index decodes its offset table once, from Git's `.rev` reverse index when the pack has a valid one and by sorting the index rows otherwise, and clones of the index share it, so every later lookup is a binary search.

## Pack deltas (encoding)

When building new pack deltas (as opposed to reusing on-disk zlib), grit-lib indexes the base blob with [`DeltaIndex`](https://docs.rs/grit-lib/latest/grit_lib/objects/delta_encode/struct.DeltaIndex.html) and encodes targets with a rolling fingerprint matcher. Reuse one index across many targets in a pack-objects window; `encode` on that index accepts an optional `max_size` cap (zero means no limit). An empty target yields a valid delta (header varints only). [`encode_delta`](https://docs.rs/grit-lib/latest/grit_lib/objects/delta_encode/fn.encode_delta.html) is a convenience wrapper for one-off base/target pairs.

## Example

This example initializes a repository, writes a blob, then a tree and commit through the typed API, verifies structure in memory, and prints the commit id:

```rust
//! Write a blob, tree, and commit through [`grit_lib::objects::Objects`], then read them back.
//!
//! Source for the library guide "Objects" page (included in the docs site).

use grit_lib::config::environment::RepositoryOptions;
use grit_lib::error::ObjectError;
use grit_lib::ident::Signature;
use grit_lib::objects::FileMode;
use grit_lib::objects::{parse_commit, parse_tree, NewCommit, ObjectKind, TreeEntry, TreeRefIter};
use grit_lib::repo::{InitOptions, Repository};
use std::path::{Path, PathBuf};
use time::OffsetDateTime;

fn write_demo_objects(
    repo: &Repository,
) -> Result<
    (
        grit_lib::objects::ObjectId,
        grit_lib::objects::ObjectId,
        grit_lib::objects::ObjectId,
    ),
    grit_lib::error::Error,
> {
    let blob_data = b"hello from the library guide\n";
    let blob_oid = repo.objects().write(ObjectKind::Blob, blob_data)?;

    let tree_oid =
        repo.objects()
            .write_tree([TreeEntry::new(b"README", FileMode::REGULAR, blob_oid)])?;

    let epoch = OffsetDateTime::UNIX_EPOCH;
    let ada = Signature::new("Ada Lovelace", "ada@example.com", epoch)?;
    let commit_oid = repo.objects().write_commit(&NewCommit::new(
        tree_oid,
        ada.clone(),
        ada,
        "Library guide objects example",
    ))?;

    let tree_obj = repo.objects().read(&tree_oid)?;
    let mut iter_entries = TreeRefIter::infer_oid_len(&tree_obj.data)?;
    let first = iter_entries.next().ok_or_else(|| {
        grit_lib::error::Error::Object(ObjectError::Corrupt {
            detail: "tree has no entries".into(),
        })
    })??;
    assert_eq!(first.oid, blob_oid);
    assert_eq!(parse_tree(&tree_obj.data)?[0].oid, blob_oid);

    let commit_obj = repo.objects().read(&commit_oid)?;
    let parsed = parse_commit(&commit_obj.data)?;
    assert_eq!(parsed.tree, tree_oid);

    Ok((blob_oid, tree_oid, commit_oid))
}

fn open_repo(root: &Path) -> Result<Repository, grit_lib::error::Error> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::empty();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Repository::open(&git_dir, &opts)
}

fn main() -> Result<(), grit_lib::error::Error> {
    let repo = if let Some(root) = std::env::args().nth(1).map(PathBuf::from) {
        open_repo(&root)?
    } else {
        let temp = tempfile::tempdir().map_err(grit_lib::error::Error::Io)?;
        Repository::init(
            temp.path(),
            &InitOptions::new()
                .with_initial_branch("main")
                .with_ref_storage(grit_lib::refs::ref_storage::RefStorageFormat::Files),
        )?;
        open_repo(temp.path())?
    };

    let (blob_oid, tree_oid, commit_oid) = write_demo_objects(&repo)?;
    println!("{commit_oid}");
    println!("blob={blob_oid} tree={tree_oid}");
    Ok(())
}
```

Objects land on disk in standard loose format. System Git can read them:

```bash
cargo run --bin guide_objects /path/to/repo
git -C /path/to/repo fsck --strict
```

When run without arguments the binary uses a temporary repository (fine for `cargo run`, not for fsck demos).

# https://grit-scm.com/docs/library/pack-bitmaps/index.md

# Pack reachability bitmaps

> Read and write Git pack `.bitmap` sidecars (EWAH reachability sets, name-hash cache, lookup tables).

Git can attach a **reachability bitmap** to a pack (or multi-pack-index) so rev-list and fetch paths avoid walking the full object graph. grit-lib implements the on-disk **BITM v1** format: type bitmaps, XOR-compressed commit entries, optional name-hash cache, and optional lookup table.

## Reading

[`BitmapIndex`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html) on a [`Repository`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) loads the preferred bitmap (MIDX over pack when both exist). Decoded commit reachability sets, per-kind type filters, and optional name-hash cache entries are available on the opened index (see rustdoc on [`BitmapIndex`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.BitmapIndex.html)).

## Writing

[`PackBitmapWriter`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.PackBitmapWriter.html) and [`Repository::write_largest_pack_bitmap`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) build a `.bitmap` for an **existing** pack index whose objects are closed under reachability from the repository’s refs—the shape produced by an all-into-one repack. Options are passed explicitly as [`PackBitmapWriteOptions`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/struct.PackBitmapWriteOptions.html); [`ConfigSet::pack_bitmap_write_options`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html) maps Git’s `pack.writeBitmapHashCache`, `pack.writeBitmapLookupTable`, and `pack.preferBitmapTips` when you want config-driven defaults.

If no `.rev` sidecar exists, the writer creates one first so object order matches Git’s pack-offset order. Output is deterministic for identical inputs. A pack that is not closed under reachability returns [`PackBitmapWriteError::NotClosed`](https://docs.rs/grit-lib/latest/grit_lib/objects/bitmap/enum.PackBitmapWriteError.html).

The writer only inflates commits and trees. Object types come from pack entry headers, tree entries are classified by mode (blobs are never read), and each commit is parsed once. Selected commits are filled oldest first, seeded from bitmaps already computed for their ancestors. Where the first-parent histories of two selected commits meet (for example, a release branch forking from the main line), the writer computes an unwritten bitmap at the fork, so the history below it is walked once. Closure is checked during that strict walk, plus a check of the tags, trees and blobs that refs name directly. On `rust-lang/cargo` (195k objects, 277 bitmaps) a write takes about 1 s; see [Benchmarks](https://grit-scm.com/docs/library/benchmarks.md/index.md#grit-lib-writing-pack-bitmaps).

A blob's name-hash entry is the path from the newest tree that named it when that tree was first walked. A tree keeps the first path it was reached by. Like Git's, these hashes are only delta-search hints.

## Compatibility

Integration tests in `grit-lib` round-trip against the system `git` binary (`rev-list --test-bitmap`, `--use-bitmap-index` counts). Name hashes use Git's v1 `pack_name_hash` (recorded during tree walks inside the library).

# https://grit-scm.com/docs/library/parallelism/index.md

# Parallelism

> Thread policy, Git config keys, and ordered parallel maps in grit-lib.

Grit centralizes worker counts and batch thresholds in [`grit_lib::parallel`](https://docs.rs/grit-lib/latest/grit_lib/parallel/index.html) so embedders and the CLI share one policy.

## Thread policy

[`ThreadPolicy`](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ThreadPolicy.html) holds optional overrides:

- **`threads_override`** — explicit worker count (`0` = auto / all logical CPUs, `1` = serial). The `grit` CLI sets this from global [`--threads`](https://grit-scm.com/docs/library/global-options.md/index.md).
- **`min_items_override`** — minimum input length before spawning a pool. Setting it to **`0`** forces the parallel path on tiny inputs (integration tests use this).
- **`min_total_bytes_override`** — optional byte threshold for hashing-style maps (`Some(0)` disables the byte gate).

Call [`ThreadPolicy::resolve`](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ThreadPolicy.html#method.resolve) with a [`ParallelOp`](https://docs.rs/grit-lib/latest/grit_lib/parallel/enum.ParallelOp.html) and a merged [`ConfigSet`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html) to obtain [`ParallelOptions`](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ParallelOptions.html) (threads + batch thresholds).

| `ParallelOp` | Config keys | Default when unset (vs Git) |
| --- | --- | --- |
| `IndexRefresh` | `core.preloadIndex`, `index.threads` | `core.preloadIndex` defaults **on** (same as Git). `index.threads` unset → auto (all logical CPUs) for hash-style refresh; serial when preload is off or `index.threads` is `1` / `false`. Batch: **≥32** entries and **≥256 KiB** total payload before pooling. |
| `IndexLoad` | `core.preloadIndex`, `index.threads` | Same thread semantics as refresh. Batch: **≥4000** index entries (`2 × LAZY_THREAD_COST`, Git `name-hash.c`) before lazy name-hash threading. |
| `Checkout` | `checkout.workers`, `checkout.thresholdForParallelism` | **Windows:** `checkout.workers` **unset** → **1 worker**; explicit **`0` or any value `< 1`** → auto (all logical CPUs), same as Git; explicit **`N ≥ 1`** → `N`. Global `--threads` applies only when `checkout.workers` is explicitly set. **Other platforms:** unset or `< 1` → auto unless `--threads` caps the process. Threshold **100** entries (Git default) — parallel file creation only when `\|entries\| ≥ threshold`. [`grit switch`](https://grit-scm.com/docs/library/commands/switch.md/index.md) uses the repository threshold (not a forced zero). Switch prepare stat checks stay **serial on Windows** even when `index.threads` is auto (issue #1613). |
| `IndexPack` | `pack.threads` | Unset / `0` → auto; invalid values error via [`try_resolve`](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ThreadPolicy.html#method.try_resolve). No item-count floor (`min_items = 0`). |
| `PackWrite` | `pack.threads` | Same as `IndexPack`. Parallel delta encoding + zlib in small batches on long-lived workers, streamed to the writer in plan order; on-wire bytes match the single-threaded writer. |
| `PackDeltaSearch` | `pack.threads` | Same as `IndexPack`. Segments are fixed from object count and `pack.window` so chosen delta bases do **not** depend on worker count. The object walk that selects what a pack sends (fetch and clone serving, push, bundles) uses the same count: one thread parses trees while the others read the queued trees ahead of it, in runs of 256. Results are consumed in queue order, so the object list and pack bytes match the single-threaded walk; walks with fewer than 256 trees queued never start workers. |
| `DiffRename` | `index.threads` with `core.preloadIndex` | Same threads as `IndexRefresh` when preload is on; same **32** / **256 KiB** batch gates. |

### Git value semantics for `index.threads`

Matches Git's `repo_config_get_index_threads`:

- unset — auto (all logical CPUs for hash-style refresh paths)
- `true` or `0` — auto
- `false` or `1` — serial (one worker)
- integer `n > 1` — up to `n` workers (clamped to available CPUs)
- other integers (for example `-3`) — preserved as serial (Git only parallelizes when `nr_threads > 1` after treating `0` as auto)

When `core.preloadIndex` is false, index refresh/load operations stay serial regardless of `index.threads`.

### EOIE / IEOT (parallel index read and write)

When `index.threads` is explicitly set to more than one worker, Git may also write **EOIE** (end-of-index-entries) and **IEOT** (index entry offset table) extensions so entry blocks can be parsed on worker threads while extension payloads load in parallel. Grit reads and writes these extensions when the same config keys are enabled:

- `index.recordEndOfIndexEntries` / `index.recordendofindexentries`
- `index.recordOffsetTable` / `index.recordoffsettable`

If those booleans are unset, they default to **on** when `index.threads` is explicitly configured and not serial (`1` / `false`).

[`repo.index().load`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexFile.html#method.load) parses with the repository config and the thread policy from [`Repository::thread_policy`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.thread_policy); [`IndexLoadOptions::with_parse_context`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexLoadOptions.html) overrides the policy. For bytes you already have, [`Index::parse`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.Index.html#method.parse) takes the config and an [`IndexParseContext`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexParseContext.html) through [`IndexParseOptions`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexParseOptions.html). Invalid EOIE data falls back to the serial entry parse. Writes go through [`repo.index().write`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexFile.html#method.write), which emits the extensions with the repository's thread policy ([`Repository::with_thread_policy`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.with_thread_policy) changes it) so split indexes and sparse indexes keep working.

### `pack.threads` (index-pack / pack-objects)

Unset or `0` selects auto (all logical CPUs). Positive integers cap worker count. Git rejects booleans, non-numeric strings, and negative values with a config error; use [`ThreadPolicy::try_resolve`](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ThreadPolicy.html#method.try_resolve) for [`ParallelOp::IndexPack`](https://docs.rs/grit-lib/latest/grit_lib/parallel/enum.ParallelOp.html) to surface those errors. Fetch and [`clone`](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/fn.clone.html) pass [`CloneOptions::thread_policy`](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/struct.CloneOptions.html) (and the repository [`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html)) into received-pack indexing so global `--threads` overrides `pack.threads` and command-scope `GIT_CONFIG_*` / `-c pack.threads=N` still applies when no override is set.

Stat preload during status/diff uses Git's **~500 entries per thread** rule with a **20**-thread cap ([`ThreadPolicy::index_stat_preload_threads`](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ThreadPolicy.html#method.index_stat_preload_threads)), still honoring `core.preloadIndex`, `index.threads`, and the global thread override.

The stat refresh in status, diff, reset and stash has to re-hash racily clean entries: files whose mtime falls in the same second as the index file, which is every file right after a clone, switch or `reset --hard`. On Windows, where `core.usenanosec` defaults to on, an entry is racy only when its mtime is at or after the index file's to the 100 ns, so a fresh checkout has none. It collects those entries from the stat scan and hashes them on the `IndexRefresh` pool before applying any stat updates. It uses the scan's `lstat` results instead of a second one per file. This step keeps the **32**-entry gate but has no byte threshold, because opening each small file costs more than hashing it. A stat-thread cap (`DiffIndexToWorktreeOptions::stat_parallel_threads`, `Some(1)` for serial) also caps this pool.

The untracked walk in status (no pathspecs) uses the `IndexRefresh` worker count and runs one task per directory entry. With at least 1000 index entries it first splits directories that only recurse (they hold tracked files and are not a gitlink or nested submodule) into their children, until each worker has about eight directories, so a work tree whose files sit under a single top-level directory still walks in parallel. Splitting changes neither the reported paths nor their order.

Optional `pack.windowMemory` caps sliding-window retention during delta search (Git `pack.windowMemory`, default unlimited).

## Global `--threads` (CLI)

[`grit --threads`](https://grit-scm.com/docs/library/global-options.md/index.md) sets [`RepositoryOptions::thread_policy`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html) for the whole process:

| Value | Effect |
| --- | --- |
| **`0`** | Auto — all logical CPUs for ops that honor unset config (`index.threads`, `pack.threads`, etc.). For **checkout on Windows**, unset **`checkout.workers`** stays serial; set **`checkout.workers = 0`** (or any value `< 1`) for auto. On other platforms, unset **`checkout.workers`** also uses auto unless you pass **`--threads` ≥ 2** to cap checkout workers. |
| **`1`** | Force serial pools (`threads = 1`) regardless of `index.threads` / `pack.threads` / `checkout.workers` (non-Windows checkout). |
| **`N > 1`** | Cap workers at **`min(N, available CPUs)`** for index/pack/diff operations. Checkout honors the cap when the entry threshold is met; on **Windows**, parallel checkout requires an explicit **`checkout.workers`** (including **`0`** for auto), not an unset key. |

Embedders pass the same semantics via [`ThreadPolicy::with_threads_override`](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ThreadPolicy.html#method.with_threads_override), for example `ThreadPolicy::default().with_threads_override(Some(4))`.

## Determinism

Parallelism must not change Git-compatible **results**, only latency:

- [`try_par_map`](https://docs.rs/grit-lib/latest/grit_lib/parallel/fn.try_par_map.html) / [`par_map`](https://docs.rs/grit-lib/latest/grit_lib/parallel/fn.par_map.html) return outputs **in input order** even when workers finish out of order.
- Pack writing (`PackWrite`) emits the same bytes as the serial writer (header order follows the pack plan).
- Windowed delta search (`PackDeltaSearch`) partitions work by fixed segments so the chosen delta base for each object is independent of thread count.
- Index-pack builds the same object ids and offsets as the serial path; only scheduling differs. Each worker resolves the whole delta tree under one base at a time, depth-first, so memory follows the deepest chain (capped per worker) rather than the number of deltas, and adding threads adds only one chain's worth of memory each. Workers read compressed deltas with positioned file reads and hand their records over in small batches, so neither the pack file nor per-thread result buffers grow with the pack.
- Checkout records the same index entries and file contents; parallel creation is ordered before post-processing.

There is **no global thread pool** and **no environment reads** inside `grit_lib::parallel`; pass policy explicitly (via [`RepositoryOptions::thread_policy`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html) or a local [`ThreadPolicy`](https://docs.rs/grit-lib/latest/grit_lib/parallel/struct.ThreadPolicy.html)).

## Ordered parallel maps

[`try_par_map_force`](https://docs.rs/grit-lib/latest/grit_lib/parallel/fn.try_par_map_force.html) skips batch thresholds (used for index-pack). Hash-specific helpers in [`grit_lib::objects::hash`](https://docs.rs/grit-lib/latest/grit_lib/objects/hash/index.html) remain thin wrappers over these APIs.

## Progress and cancellation

Long-running library work reports through [`ProgressSink`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html) and accepts a separate [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html) signal (embedders should prefer a shared [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html)). Call cancellation polling on [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html) at loop boundaries (or rely on built-in checks in fetch pack demux and status scans); when the cancel handle is set, the operation stops with [`Error::Cancelled`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Cancelled). Pass [`CancelToken::never`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html#method.never) or [`CancelToken::never`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html#method.never) when interruption is not needed.

[`ProgressSink`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html) is the only progress sink: typed [`ProgressPhase`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html) updates use [`start`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html#method.start) / [`inc`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html#method.inc) / [`finish`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html#method.finish). Wire fetch and push take the same trait; its other provided methods are transfer events a sink may override ([`message`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html#method.message) for side-band channel 2, [`milestone`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html#method.milestone) with [`FetchMilestone`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.FetchMilestone.html), [`received_objects`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html#method.received_objects), [`resumable_transfer`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html#method.resumable_transfer)). Pack builds for upload-pack report through the same sink (no separate callback type). Use [`NullProgress`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.NullProgress.html) when you do not need output.

Local [`file://`](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/fn.clone.html) and plain-path fetches report [`ProgressPhase::EnumeratingObjects`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html#variant.EnumeratingObjects) while resolving refspecs, tags, the send set, and (when linking packs) strided counts while source pack indexes are examined, then a single [`ProgressPhase::CopyingObjects`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html#variant.CopyingObjects) phase with strided counts only for objects actually linked, loose-copied, or written into a remainder pack, plus indexing (including [`ProgressPhase::IndexingObjects`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html#variant.IndexingObjects) / [`ProgressPhase::ResolvingDeltas`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html#variant.ResolvingDeltas) on the received pack). Empty copy phases are not emitted when linking finds nothing to install.

Network and long-running entry points that accept [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html) today include [`RepositoryRemotes::fetch_from`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.fetch_from) / [`RepositoryRemotes::push_to`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.push_to), [`Remote::fetch`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.Remote.html#method.fetch) / [`Remote::push`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.Remote.html#method.push), [`RepositoryRemotes::fetch_all`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.fetch_all), [`clone`](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/fn.clone.html) (fetch **and** post-fetch checkout), [`pull`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/pull/fn.pull.html), [`status`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/fn.status_options_from_config.html), [`switch_repository`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/switch/struct.SwitchOutcome.html), [`reset_to_commit`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/reset/struct.ResetOutcome.html) (keep/hard worktree apply), [`History::apply`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.apply), read-only history walks ([`RevWalk::walk`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.walk), [`RevWalk::rev_list`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.rev_list), [`RevWalk::commits`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.commits), [`RevWalk::rev_list_result`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.rev_list_result), [`RevWalk::count`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.count), [`RevWalk::commits_stream`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.commits_stream), [`RevWalk::commits_iter`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.commits_iter), [`RevWalk::describe`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.describe), [`Diff::blame`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html#method.blame)) with phases [`WalkingHistory`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html#variant.WalkingHistory), [`Describing`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html#variant.Describing), and [`Blaming`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html#variant.Blaming), checkout helpers ([`checkout_between_trees_with_progress`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.checkout)), bundle write/fetch/unbundle ([`RepositoryBundles::write`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryBundles.html#method.write), [`RepositoryBundles::fetch`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryBundles.html#method.fetch), [`Bundle::unbundle`](https://docs.rs/grit-lib/latest/grit_lib/bundle/struct.Bundle.html#method.unbundle)), and received-pack indexing ([`install_pack_path`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.install_pack_path.html) / [`ingest_received_pack_path`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.ingest_received_pack_path.html), which take the progress sink and cancel token as their last two parameters). Local [`file://`](https://docs.rs/grit-lib/latest/grit_lib/remote/clone/fn.clone.html) / path clones poll cancel while linking or copying objects into the new repository. The coordinator thread calls cancellation polling on [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html) at ingest phase boundaries (before/after parallel object hashing, between idx write, verify, and rename); index-pack worker threads observe a [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html) clone, not [`ProgressSink`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html). **Not yet cancellable mid-flight:** thin-pack repair during fetch, a single ordered delta-resolution pool batch, and v2 idx sorting inside [`write_v2_pack_index_from_trailer`](https://docs.rs/grit-lib/latest/grit_lib/objects/pack/fn.write_v2_pack_index_from_trailer.html) — cancel is checked before/after those steps. Sideband demux during fetch uses the same cancel handle as the transport. Pass [`CancelToken::never`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html#method.never) when interruption is not needed.

A push checks for a cancel all the way through: while it walks the objects to send, enumerates and delta-searches them (search workers stop at the next chunk), and streams the pack, and while a local remote indexes it. A cancel before the objects are stored returns [`Error::Cancelled`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Cancelled) with no remote ref moved and no pack or temporary file left in the remote, so the same push can simply be retried. Over smart HTTP, a cancel mid-pack abandons the request body (the server sees a truncated request and updates nothing), and a cancel while the server is still unpacking returns within a fraction of a second; at that point the whole request was sent, so the server may still apply it, as with an interrupted `git push`. Waiting for the report on `git://` and `ssh` connections is not interruptible.

A cancelled (or otherwise failed) checkout, switch, hard reset, or work-tree [`restore_paths`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/restore/struct.RestoreOutcome.html) with `--source` leaves refs, the index and the work tree as they were: until the index is written, every file it created is removed again, files it deleted or overwrote are restored, and paths it could not put back are listed in [`WorktreeError::CheckoutRollbackIncomplete`](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.WorktreeError.html#variant.CheckoutRollbackIncomplete).

Work-tree sessions take a sink and a cancel handle too: staging ([`stage`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexFile.html#method.stage_for_commit), [`stage_on_index`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexFile.html#method.stage_for_commit), [`stage_for_commit`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexFile.html#method.stage_for_commit)), commits ([`commit_with_scope`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/enum.CommitScope.html), [`commit_worktree`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitRequest.html), [`create_commit`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitRequest.html), [`continue_merge`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.continue_sequence)), [`RepositoryStash::push`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryStash.html#method.push) / [`apply`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryStash.html#method.apply) / [`pop`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryStash.html#method.pop), [`integrate_branch`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.integrate_into_branch), [`History::start_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.start_rebase) / [`History::continue_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.continue_rebase) / [`History::skip_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.skip_rebase), [`replay_commit`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/replay_sequence/struct.ReplayOptions.html) and [`restore_paths`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/restore/struct.RestoreOutcome.html). Hashing work-tree files reports [`ProgressPhase::StagingFiles`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html#variant.StagingFiles) (no total: the changed set is found while scanning); work-tree updates report [`ProgressPhase::CheckingOutFiles`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html#variant.CheckingOutFiles). Staging's parallel hash workers stop on the shared flag of a [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html), so a cancel from another thread lands within one file per worker. The rule for where a cancel lands is the same everywhere: before the commit object, stash entry or ref moves, nothing visible changes (the on-disk index is not written; blobs already hashed stay as unreachable loose objects, as after an interrupted `git add`). Once a commit object is written, its branch update always follows; once a merge checkout finished, the branch moves. A cancel during a checkout inside these sessions is rolled back as described above. Files a session writes itself stay written for `reset --hard`: the content-merged files of a stash apply onto a moved `HEAD`, and the paths [`restore_paths`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/restore/struct.RestoreOutcome.html) already restored. A stash push keeps the stored entry when its reset (full, `--keep-index`, `--staged`, pathspec or hunk selection) is cancelled. A rebase that stops on a conflict checks for a cancel before it records the stop; once the stop state and `HEAD` are written, its checkout always finishes, so [`History::continue_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.continue_rebase) never sees a stop without its conflict stages.

Checkout resolves the `Checkout` worker policy before splitting eligible jobs into cancellation chunks. The parallelism threshold applies to that set of jobs, so even a small cancellation chunk can use the selected pool. Chunks start at 8 files and double up to 2048; cancellation is checked between chunks and during serial reads and writes. Populated-tree checkout already walks in 2048-entry chunks and starts at full size after its first walk chunk. Prepared contents use a separate 1 MiB flush threshold; parallel readers run in bounded batches, so growing cancellation chunks does not retain all their file contents at once. Streamed files consume part of that budget too, limiting each flush to at most eight streams before cancellation is checked again. Bulk checkout reuses cached small loose objects (up to 64 KiB each); direct worktree writes and the one-pass local-object walk bypass that cache bookkeeping.

## Tests

- Policy unit tests live in `grit-lib/src/parallel/policy.rs`.
- Public API coverage: `grit-lib/tests/parallel_api.rs`.
- Hash wrappers: `grit-lib/tests/hash_parallel_api.rs` (unchanged behavior).
- `grit_test_support::forced_parallel_policy` sets `threads = 4` and `min_items = 0` for deterministic parallel paths in integration tests (see the `grit-test-support` crate in the workspace).
- CI **`test-threaded`** runs `cargo test --release --workspace` with `index.threads`, `pack.threads`, `checkout.workers`, and `checkout.thresholdForParallelism=0` forced via `GIT_CONFIG_COUNT` (see [TESTING.md](https://grit-scm.com/docs/TESTING.md/index.md)).

# https://grit-scm.com/docs/library/path-validation/index.md

# Path component validation

> Reject hostile tree and worktree path components the same way Git fsck and verify_path do.

# Path component validation

Grit centralizes Git’s path-component rules in [`grit_lib::path_validate`](https://docs.rs/grit-lib/latest/grit_lib/path_validate/index.html). Use it before writing tree entries, populating the index, or checking out files so NTFS/HFS spellings and `.git` aliases cannot slip through.

## Protection options

[`ProtectOptions`](https://docs.rs/grit-lib/latest/grit_lib/path_validate/struct.ProtectOptions.html) mirrors `core.protectNTFS` (default **true**) and `core.protectHFS` (default **true** on macOS, **false** elsewhere). Load them from a merged [`ConfigSet`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html):

```rust
use grit_lib::config::ConfigSet;
use grit_lib::path_validate::ProtectOptions;

let opts = ProtectOptions::from_config(&config);
```

Object fsck always enables both flags via [`ProtectOptions::fsck`](https://docs.rs/grit-lib/latest/grit_lib/path_validate/struct.ProtectOptions.html#method.fsck).

## Validating components and paths

[`validate_component`](https://docs.rs/grit-lib/latest/grit_lib/path_validate/fn.validate_component.html) checks a single tree/index segment (no `/` inside). Pass the Git mode and a [`PathValidationKind`](https://docs.rs/grit-lib/latest/grit_lib/path_validate/enum.PathValidationKind.html). Worktree population and checkout use **`Worktree`**. On Windows with `core.protectNTFS` (default), each segment is checked with Git’s `is_valid_win32_path` rules: forbidden characters (`:*?"<>|` and controls), trailing spaces or periods (except `.` and `..`), DOS device names (`CON`, `AUX`, `COM1`, …), plus NTFS drive prefixes and backslash-`.git` spellings. Symlink names reject **`.gitmodules`** on worktree; object fsck uses **`Fsck`** (all four symlink dot-files):

```rust
use grit_lib::path_validate::{validate_component, EntryMode, PathValidationKind, ProtectOptions};

let opts = ProtectOptions::fsck();
validate_component(b"src", EntryMode::new(0o100644), opts, PathValidationKind::Worktree)?;
```

Fsck checks all symlink dot-files (`.gitmodules`, `.gitattributes`, `.gitignore`, `.mailmap`):

```rust
use grit_lib::path_validate::{validate_component, EntryMode, PathValidationKind, ProtectOptions};

let opts = ProtectOptions::fsck();
validate_component(
    b".gitignore",
    EntryMode::new(0o120000),
    opts,
    PathValidationKind::Fsck,
)?;
```

## `.git` aliases

With `core.protectNTFS` on, every platform rejects the NTFS spellings of `.git` for both kinds, because a repository checked out on Linux may later be used from Windows. These are `.git` and its 8.3 short name `git~1` in any case, each optionally followed by spaces and periods (which NTFS strips) or by a `:` stream suffix. Examples are `.git.`, `GIT~1.`, `git~1  ` and `.git::$INDEX_ALLOCATION`. A `\`-separated segment that spells `.git`, such as `.git\config`, is rejected too. System git refuses the same names on Linux, so a hostile tree cannot plant a second `.git` directory through either implementation.

[`validate_path`](https://docs.rs/grit-lib/latest/grit_lib/path_validate/fn.validate_path.html) splits on `/` and validates each segment. [`audit_tree_entry_name`](https://docs.rs/grit-lib/latest/grit_lib/path_validate/fn.audit_tree_entry_name.html) returns a bitmask-style summary for fsck-style reporting when several rules fire on one name.

## Errors

[`PathComponentError`](https://docs.rs/grit-lib/latest/grit_lib/path_validate/enum.PathComponentError.html) is a typed, non-exhaustive enum (empty, `.`, `..`, slash/NUL, ASCII and platform `.git` aliases, NTFS backslash/drive/stream spellings, NTFS illegal characters, trailing space/period, reserved DOS device names, and symlinked dot-files). Checkout and index population return [`WorktreeError::InvalidPathComponent`](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.WorktreeError.html#variant.InvalidPathComponent) with the full path and reason. User-facing `add`/`mv` path arguments use the same typed error; legacy [`Error::InvalidPath`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html) remains for empty or escaping paths.

## Related

- Ref names under `refs/` use [`RefName::parse`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefName.html#method.parse) with [`RefNamePolicy::storable`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefNamePolicy.html#method.storable) or [`safe_for_fs`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefNamePolicy.html#method.safe_for_fs) instead of the old free validators. See [Refs](https://grit-scm.com/docs/library/path-validation/refs.md/index.md#ref-names-refname--refnamepolicy).
- Tree object fsck uses the same rules via `grit-lib` maintenance APIs.
- Index population, checkout, restore, and `grit add` staging run these validators internally with [`ProtectOptions::from_config`](https://docs.rs/grit-lib/latest/grit_lib/path_validate/struct.ProtectOptions.html#method.from_config). Code that writes its own tree or index entries calls [`validate_path`](https://docs.rs/grit-lib/latest/grit_lib/path_validate/fn.validate_path.html) or [`validate_component`](https://docs.rs/grit-lib/latest/grit_lib/path_validate/fn.validate_component.html) directly.

# https://grit-scm.com/docs/library/rebase/index.md

# Rebase planning

> Plan a fork-point rebase with bounded cherry patch-id detection before applying ref updates.

[`History::plan_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.plan_rebase) builds a [`RebasePlan`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebasePlan.html) for `git rebase [--onto <base>] <upstream>` semantics on a single branch tip. [`History::plan_rebase_check`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.plan_rebase_check) returns [`RebaseCheckPlan`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebaseCheckPlan.html) (`UpToDate`, `Clean { commits }`, or `Conflict { commit, paths }`) without updating refs, the index, or the worktree.

Set [`RebaseOntoOptions::favor`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RebaseOntoOptions.html#structfield.favor) to [`MergeFavor::Ours`](https://docs.rs/grit-lib/latest/grit_lib/diff/merge_file/enum.MergeFavor.html#variant.Ours) or [`MergeFavor::Theirs`](https://docs.rs/grit-lib/latest/grit_lib/diff/merge_file/enum.MergeFavor.html#variant.Theirs) to match `git rebase -X`. During replay merges, **ours** is the onto tree and **theirs** is the commit being replayed (Git’s rebase convention, not branch-merge “ours”). [`History::plan_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.plan_rebase) computes the exclude boundary as the merge base of `upstream` and `branch_tip` ([`RevWalk::merge_bases`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.merge_bases) with `MergeBaseMode::Best`), then replays commits above that boundary onto `onto.unwrap_or(upstream)`. Pull and implicit-upstream rebase build the request with [`History::rebase_request_after_fetch`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.rebase_request_after_fetch): the fork point in the upstream tracking ref's reflog ([`RevWalk::fork_point`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.fork_point), matching `git merge-base --fork-point`) can replace the merge-base boundary, with Git's guard that keeps the upstream tip when the fork point is already its merge base with the branch. An explicit upstream argument leaves fork-point off unless the caller opts in; [`rebase_fork_point_enabled`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/merge_base/fn.rebase_fork_point_enabled.html) reads `rebase.forkPoint`. Planning returns either [`RebasePlan::UpToDate`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebasePlan.html#variant.UpToDate), a [`RewritePlan`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewritePlan.html), or [`RebasePlan::Conflict`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebasePlan.html#variant.Conflict) (conflicts are values, not [`HistoryError`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html), so callers can report paths without treating them as I/O failures).

Cherry detection (`skip_applied` on [`RebaseOntoOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RebaseOntoOptions.html)) hashes the replay range first and walks only the onto side between fork and onto when a matching stable patch-id might exist. Onto commits that do not touch any path changed in the replay range are dropped using commit-graph Bloom filters (when present) and path-limited tree diffs; merge commits with no such change are skipped before hashing. A root commit on the onto side (such as an unrelated history merged with `--allow-unrelated-histories`) is diffed against the empty tree. Every candidate and range commit that survives the filter is compared using a full stable patch-id (matching `git patch-id --stable`). With no `--onto`, a linear branch that already extends `upstream` yields [`RebasePlan::UpToDate`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebasePlan.html#variant.UpToDate), matching `git rebase <upstream>`. A skipped commit becomes a [`CommitEdit::Reuse`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.CommitEdit.html#variant.Reuse) edit: its [`RewrittenCommit`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RewrittenCommit.html) row names the upstream equivalent with `reused: true`, but descendants and refs continue from the edit's `parent` (the skipped commit's own replayed first parent, or the new base when it is a root of the range), so nothing before or after the skip is lost and the branch never lands on an older upstream commit. [`History::rebase_onto`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.rebase_onto) keeps the same replay engine for callers (such as pull) that already supply the fork as their upstream boundary.

After planning, apply with [`History::apply`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.apply) the same way as other history edits. See [History rewrite](https://grit-scm.com/docs/library/rebase/history.md/index.md) for scope, empty-commit policy, and change-id behavior.

## Stop and resume

[`History::start_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.start_rebase) runs resumable planning. When replay finishes without conflicts, it applies the plan atomically and returns [`RebaseOutcome::Done`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebaseOutcome.html#variant.Done). When a commit conflicts, grit writes Git-compatible `.git/rebase-merge/` files plus `rebase-merge/grit-plan` (mapping, replay order, and options), detaches `HEAD` at the replayed parent, and leaves the branch ref at its pre-rebase tip — matching `git rebase` stop behavior.

Resolve conflicts in the worktree, stage paths, then [`History::continue_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.continue_rebase) to record the resolved tree and replay remaining commits. [`History::skip_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.skip_rebase) maps the current commit to `HEAD` and replans the rest. [`History::abort_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.abort_rebase) hard-resets the branch to `orig-head` and removes session state, even when something else moved the branch during the stop; it returns a [`RebaseAbort`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.RebaseAbort.html) whose `overwritten` list names each such branch with the tip it replaced (still in the branch reflog as `rebase (abort)`). For an exec stop the reset is a compare-and-swap against the tip just read; a concurrent move returns [`RebaseSessionError::AbortRefMoved`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebaseSessionError.html#variant.AbortRefMoved) and leaves the rebase in place to retry. [`History::continue_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.continue_rebase) returns [`RebaseSessionError::UnmergedPaths`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebaseSessionError.html#variant.UnmergedPaths) while the index still has conflict stages. If `rebase-merge/grit-plan` records something other than a hex object id where one belongs, `continue_rebase`, `skip_rebase` and `abort_rebase` return [`RebaseSessionError::InvalidStateOid`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebaseSessionError.html#variant.InvalidStateOid) with the offending text and change nothing.

On completion, [`RebaseOutcome::Done`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebaseOutcome.html#variant.Done) exposes `head_change: Option<(ObjectId, ObjectId)>`. It compares `HEAD` at the start of that `start_rebase`, `continue_rebase`, or `skip_rebase` call with `applied.head` after completion and branch reattachment. For resume calls, the old OID is the stopped, detached `HEAD`, which can differ from the original branch tip in the plan's ref updates. `None` means the OID did not change, including a final skip that only reattaches `HEAD`. The plan retains its detached-HEAD metadata for apply validation; use `head_change` for the completed call's transition rather than deriving it from the plan. When [`ApplyOptions::record_operation`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.ApplyOptions.html#structfield.record_operation) is set, a finished `continue_rebase` or `skip_rebase` overwrites `.git/grit/history-last` after reattaching `HEAD` to the branch, using the pre-rebase branch tip and final tip (not the detached stop commit), so [`History::undo_last`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.undo_last) matches a one-shot rebase. The CLI exposes this same pair as `head: {old, new}` in completed JSON and as the HEAD row in Markdown.

With [`StartRebaseOptions::exec`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.StartRebaseOptions.html#structfield.exec) set,
[`History::start_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.start_rebase) runs the
commands through the [`CommandRunner`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/trait.CommandRunner.html) it is given,
using the same resumable planning. When the first replayed commit conflicts before any `--exec` command runs, grit stops with
[`RebaseOutcome::Stopped`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebaseOutcome.html#variant.Stopped) and
persists the exec command list on `rebase-merge/grit-plan`. [`History::continue_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.continue_rebase)
runs those commands at the resolved commit before replaying the rest.

## Exec verification and recovery

[`History::verify_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.verify_rebase)
checks out each replacement and runs the injected command runner. It takes the
plan by `&mut` with the plan's `RewriteOptions`: after a successful invocation, a
detached `HEAD` that amends the replay commit (same first parent) or adds commits on
top of it is adopted into the plan, later commits are replayed onto it with those
options, and ref updates and the `HEAD` effect follow. Any other `HEAD` move returns
[`HistoryError::ExecHeadMoved`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.ExecHeadMoved)
after a rollback. After every successful invocation it also reloads the index and
checks staged and unstaged tracked changes against the resulting `HEAD` tree,
including racy file timestamps. Clean commands restore the original HEAD, index, and
tracked files before the caller applies the updated plan atomically.

```rust
use grit_lib::progress::{CancelToken, NullProgress};
use grit_lib::revwalk::history::ExecSpec;

// `plan` comes from `repo.history().plan_rebase(&request, &options)`.
let history = repo.history();
let spec = ExecSpec::default()
    .with_commands(vec!["cargo fmt && git commit -qa --amend --no-edit".into()]);
let report = history.verify_rebase(&mut plan, &spec, &options.rewrite, runner.as_ref())?;
history.apply(&plan, &apply, &mut NullProgress, &CancelToken::never())?;
```

When replaying a later commit onto an amended one conflicts,
[`HistoryError::ExecConflict`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.ExecConflict)
leaves the conflict checked out on top of the rewritten commit and saves recovery
state: stage a resolution and call `continue_rebase` (commands then run at the
resolved commit), or `skip_rebase` to drop the commit (its commands still run at the
current `HEAD`, as in Git's todo list), or `abort_rebase`. The recovery record keeps
the `RewriteOptions` the exec run started with, and resuming uses those rather than
the options passed to `continue_rebase` / `skip_rebase`. If the record cannot be
written, the run is rolled back instead of leaving a detached conflict behind.

[`HistoryError::ExecDirty`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.HistoryError.html#variant.ExecDirty)
carries the `HEAD` the command left (the replay commit or its amended replacement),
the command, changed paths, and captured run records. The
edited index and worktree are preserved at that detached HEAD. Original
branch refs remain unchanged. Do **not** apply the rewrite after this error.
The library saves the original HEAD and index, plan, and next command position in
`rebase-merge/grit-exec`; it distinguishes this stop from an unresolved pick.

Save edits with a stash, then call `continue_rebase` to run the next command and
remaining commits. `skip_rebase` skips remaining commands at the current commit
without dropping that commit. Both reject a dirty index/worktree without changing
it. A moved replay HEAD returns
[`RebaseSessionError::ExecHeadChanged`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebaseSessionError.html#variant.ExecHeadChanged):
save any new commits on a branch, abort, and restart. When the rebased branch, or a
ref the saved plan updates, was moved while stopped, both return
[`RebaseSessionError::StaleExecPlan`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/enum.RebaseSessionError.html#variant.StaleExecPlan)
with the ref name and the expected and current tips, before checking the worktree and
without changing anything. `abort_rebase` explicitly
restores the saved HEAD, index, and tracked files, discarding unsaved exec edits.
Clean recovery returns `RebaseOutcome::ExecDone` with an `exec` report containing the
invocations captured during that call, for the embedding caller to render.
Nonzero exec exits keep their existing `ExecFailed` rollback behavior.

## Clean exec benchmark

Measured on Linux x86_64 with system Git 2.55.0 and Rust's `release` profile.
Each sample rebases a fresh copy of a repository with 200 or 2,000 tracked files
and 40 feature commits onto a one-commit upstream advance. Commands are `git rebase main
--exec true` and `grit rebase main --exec true --json`; output is captured. The table
shows medians of seven runs, measured together with `/usr/bin/time -v` after builds
and tests were idle.

| Tracked files | Implementation | Wall time | Peak RSS (KiB) |
| ---: | --- | ---: | ---: |
| 200 | System Git 2.55.0 | 220 ms | 6,924 |
| 200 | Grit before this fix (`34c10122c`) | 180 ms | 21,888 |
| 200 | Grit with dirty-exec detection | 280 ms | 22,316 |
| 2,000 | System Git 2.55.0 | 540 ms | 12,776 |
| 2,000 | Grit before this fix (`34c10122c`) | 1,780 ms | 32,420 |
| 2,000 | Grit with dirty-exec detection | 2,620 ms | 32,776 |

Checking the index and tracked worktree after every successful command adds
100 ms across 40 invocations (2.5 ms per command) and 428 KiB of peak RSS in this
200-file fixture. At 2,000 files, it adds 840 ms (21 ms per command) and 356 KiB.
This verification cost belongs to `--exec`; it closes the unchecked path that
previously discarded successful commands' edits. The wider fixture also exposes
an existing performance gap against Git that needs further work.

# https://grit-scm.com/docs/library/refs/index.md

# Refs

> Repository ref handles, HEAD, reflogs, operation state, transactions and backend selection.

References name commits and other objects. Everything you do with them goes through [`repo.references()`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html): `head`, `resolve`, `symbolic`, `dwim`, `list`, `list_glob`, `update`, `update_direct`, `update_symbolic`, `compare_and_swap`, `delete`, `compare_and_delete`, and `apply` / `apply_each` for batches. Reflogs are on [`repo.reflogs()`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryReflogs.html), and paused merges, rebases, picks and reverts on [`repo.operation()`](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.Operations.html). Call `Repository::ref_store` to borrow the cached `RefStore` trait object, or `with_ref_store` to inject a custom backend (for example `MemoryRefStore` or the `custom_ref_store` example below). All of these work on the repository's store, so an injected store is always honoured.

Ref names are [`RefName`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefName.html) values, validated when you build them: [`RefName::new`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefName.html#method.new) (or `TryFrom<&str>`, `str::parse`) accepts full names under `refs/`, `HEAD` and pseudo-refs such as `ORIG_HEAD`, and [`RefName::branch`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefName.html#method.branch) / [`RefName::tag`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefName.html#method.tag) build one from a short name. Plain strings do not convert implicitly and there is no public unchecked constructor, so a name from user input cannot reach the ref store (or the files under `.git`) unchecked. A custom ref store rebuilds the names it lists with `RefName::new` as well. A failed check is `RefError::InvalidName`, so `?` works in functions returning `grit_lib::error::Result`. `RefNameRef::HEAD` is a ready-made `HEAD`.

```rust
use grit_lib::refs::store::RefName;
use grit_lib::state::HeadState;

let refs = repo.references();
if let HeadState::Branch { refname, oid: Some(tip), .. } = refs.head()? {
    refs.update(&RefName::new("refs/heads/backup")?, &tip)?;
    println!("{refname} is at {tip}");
}
for (name, oid) in refs.list_glob("refs/tags/v*")? {
    println!("{name} {oid}");
}
if let Some(found) = refs.dwim("main")? {
    println!("main is {} ({} candidates)", found.name, found.candidates);
}
```

## Injected stores and porcelain

Every porcelain operation that moves a ref writes through `Repository::ref_store`: commit, switch, branch, tag, merge ([`integrate_branch`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.integrate_into_branch)), reset, stash, pick, revert and rebase. So does the history engine: planning and [`History::apply`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.apply) (reword, drop, squash, move, fixup, absorb), [`History::start_rebase`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.start_rebase), `rebase --exec` and [`History::undo_last`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/history/struct.History.html#method.undo_last). Each one reads `HEAD` with [`References::head`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.head), updates refs and `HEAD` in the store, and appends reflog entries there. With an injected store such as `MemoryRefStore`, nothing is written to `.git/HEAD`, `.git/refs`, `.git/logs` or `packed-refs`. The reflog handle, [`repo.reflogs()`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryReflogs.html), lists, reads, deletes and expires entries in that same store, and `gc` expires reflogs there too. The index, objects and operation-state files (`MERGE_HEAD`, `ORIG_HEAD`, `rebase-merge/`, sequencer state, the `grit/history-last` undo record) stay in the git directory.

The network operations keep the local side in the store the same way. [`Remote::fetch`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.Remote.html#method.fetch) (local, `file://`, bundle and wire remotes) reads the previous tracking-ref values from it and writes the new tips, `--prune` deletions and `refs/remotes/<name>/HEAD` there. [`Remote::push`](https://docs.rs/grit-lib/latest/grit_lib/remote/struct.Remote.html#method.push) records the pushed tips as tracking refs there. [`Remotes::prune`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.prune), [`set_head`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.set_head) and [`inspect`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryRemotes.html#method.inspect) read and write the store too. Received objects go to the repository's object store (the custom primary when one is configured). `FETCH_HEAD` is still written under the git directory, and the destination of a local push keeps its own on-disk refs. Packing the imported refs into `packed-refs` after a clone only happens on a files repository.

Reads go through the store too. [`RevWalk`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html) ref selections (`All`, `Branches`, `Tags`, `Remotes`, with or without a glob such as `v*`), `--stdin` pseudo-options ([`RevWalk::parse_stdin_specs`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.parse_stdin_specs)), [`RevWalk::tag_targets`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.tag_targets), `:/text` searches, `@{-N}` and the other rev-parse forms that read `HEAD` all list and resolve refs through `Repository::ref_store`. Linked worktree add/list/remove do as well (see [Worktree](https://grit-scm.com/docs/library/worktree/index.md)).

To advance a checked-out branch from your own code, call [`References::update`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.update) with `HEAD` or the branch name. It follows symbolic `HEAD` to the branch, appends reflog entries when [`core.logAllRefUpdates`](https://docs.rs/grit-lib/latest/grit_lib/refs/enum.LogRefsConfig.html) allows, and mirrors a `HEAD` log line when you update the checked-out branch by name. Use [`References::update_direct`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.update_direct) to detach or rewrite the `HEAD` file itself, and [`References::compare_and_swap`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.compare_and_swap) when the tip must still match an expected commit.

[`update_branch_for_commit_on_store`](https://docs.rs/grit-lib/latest/grit_lib/refs/fn.update_branch_for_commit_on_store.html) remains the typed path for porcelain commits: it checks that `HEAD` points at the branch, compares the tip with the expected old commit, then moves the branch and appends the branch and `HEAD` reflog entries. On the files backend, the branch lock is held while the reflogs are appended. On every other backend, the branch update and its reflog entries commit as one transaction.

## Backend selection

On-disk layout is chosen once from **repository-local** config (`extensions.refStorage`), never from global or system config. [`RefStorageFormat`](https://docs.rs/grit-lib/latest/grit_lib/refs/ref_storage/enum.RefStorageFormat.html) in [`ref_storage`](https://docs.rs/grit-lib/latest/grit_lib/refs/ref_storage/index.html) reads that value via `detect` and returns `files` (loose refs plus `packed-refs`) or `reftable`. [`RepoCaches::open_ref_store`](https://docs.rs/grit-lib/latest/grit_lib/repo/caches/struct.RepoCaches.html#method.open_ref_store) constructs [`FilesRefStore`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.FilesRefStore.html) or [`ReftableRefStore`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.ReftableRefStore.html). The store's `format()` reports which backend is active (`files`, `reftable`, or `memory` for injected stores).

### Reftable HEAD and linked worktrees

Reftable stores both symbolic and detached `HEAD` values in the worktree's own stack.
The common stack holds shared branches. The loose `HEAD` file serves repository
discovery only and does not override a stack record. Fresh reftable repositories
and linked worktrees initialize this layout before checkout, so system Git sees
the same branch and commit as `Repository::ref_store()`. Compaction also uses stack
refs and reflogs, so deleting HEAD cannot revive a stale loose value.

HEAD changes use the ref store's transaction, compare-and-swap and reflog handling.
Updating through an attached linked-worktree HEAD advances the shared branch and
writes its branch reflog in the common stack, with the HEAD reflog in the worktree
stack. These two stack commits have the partial-failure semantics documented on
[`ReftableRefStore`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.ReftableRefStore.html).

### Reading `packed-refs`

The files backend maps `packed-refs` and keeps one view per store, shared by lookups, listings and peel snapshots. Opening it checks what Git checks: the file ends in a newline and its last line can hold an object id. When the header carries the `sorted` trait (Git and grit always write it), lookups and prefix listings binary-search the mapped bytes in place. They read only the lines they probe and parse strictly the lines a listing covers, so a command on a repository with tens of thousands of packed refs touches a few pages of the file. As in Git, the trait is trusted rather than verified on every read. The trust model:

- **Point lookups** (resolving one ref) trust the header completely. In a file that claims `sorted` but is not, a lookup can miss a ref, exactly as `git rev-parse` does.
- **Prefix listings** (`refs/heads/`, `refs/tags/`, …) validate every line in the range and the records just before and after it, including their object ids and peel lines. They check name order across those records too. If any are out of order, the listing reads the whole file instead of returning part of the range. A record misplaced somewhere the listing does not read goes unnoticed, as in Git.
- **Full scans** (all refs, `refs/` as a whole, `PackedRefs::load`) read every line. They reject a carriage return or invalid UTF-8 anywhere in the file, and they return every record whatever its order.

[`refs_fsck`](https://docs.rs/grit-lib/latest/grit_lib/refs/refs_fsck/fn.refs_fsck.html) (and `grit fsck`) reports a file whose records break the trait as `packedRefUnsorted`. A file without the trait is searched linearly for lookups and scanned in full for listings.

## Lock files and contention

Loose ref updates, `packed-refs`, the index, config, commit-graph, and reftable `tables.list` all use Git-style lock files created exclusively (`O_CREAT|O_EXCL`). [`LockFile`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/struct.LockFile.html) centralizes acquisition, optional jittered exponential backoff, staged writes, and atomic rename. Backoff budgets come from repository config: `core.filesRefLockTimeout` (milliseconds, default 100; `0` fail-fast, `-1` retry indefinitely), `core.packedRefsTimeout` (milliseconds, default 1000 ms), and `reftable.lockTimeout` (milliseconds, default 1000 ms). Dropping a [`LockFile`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/struct.LockFile.html) without [`commit`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/struct.LockFile.html#method.commit) removes only the lock file this handle created.

When `.git/index.lock` is still held after the budget, [`stage`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexFile.html#method.stage_for_commit) and [`IndexLock::acquire`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexLock.html#method.acquire) return [`Error::LockHeld`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.LockHeld) with the lock `path`. The index is unchanged. Low-level loose-ref helpers use the same variant, while ref-store transactions retain `RefStoreError::LockHeld { name }`. Grit-owned index locks write a pid sidecar next to the lock (`index~pid.lock`) by default ([`grit_lockfile_pid_enabled`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/fn.grit_lockfile_pid_enabled.html); set `core.lockfilePid=false` to opt out). The sidecar records the holder as a [`LockHolder`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/struct.LockHolder.html); its `running` field records whether that process existed when checked. Converting [`LockError::Held`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/enum.LockError.html#variant.Held) with `?` preserves these fields; other `LockError` variants retain their I/O source. [`LockHolder::remove_if_stale`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/struct.LockHolder.html#method.remove_if_stale) removes the lock and sidecar when the holder has exited (used during interrupted rewrite recovery; ordinary acquire never steals a foreign lock).

For callers migrating from `Error::IndexLocked`, match `Error::LockHeld(LockHeldError { path, holder, .. })` instead of `{ lock_path, holder }`, and import `LockHolder` from `grit_lib::lockfile` instead of `grit_lib::error`. [`LockHolder::read`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/struct.LockHolder.html#method.read) replaces the removed prose helper `format_index_lock_blocked_detail` when inspecting a pid sidecar directly. [`pid_path_for_lock`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/fn.pid_path_for_lock.html) names the sidecar path for a lock file.

```rust
use grit_lib::error::Error;
use grit_lib::lockfile::LockHolder;

fn explain(err: &Error) -> Option<String> {
    let Error::LockHeld(held) = err else {
        return None;
    };
    let path = &held.path;
    Some(match held.holder {
        Some(LockHolder { running: false, pid, .. }) => {
            format!("{} is stale (process {pid} exited); remove it", path.display())
        }
        Some(LockHolder { pid, .. }) => format!("process {pid} holds {}", path.display()),
        None => format!("another process holds {}", path.display()),
    })
}
```

Ref-store transactions follow the same budget. [`RefStore::prepare`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/trait.RefStore.html#tymethod.prepare) fails fast with `RefStoreError::LockHeld { name }` when the caller uses [`LockWait::Immediately`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/enum.LockWait.html#variant.Immediately) and another writer holds a lock it needs; `name` is always one of the failed transaction's own refs. On the files backend that is the per-ref `<ref>.lock` (or `packed-refs.lock` when the batch rewrites packed refs), so updates to disjoint refs run concurrently and only the same ref contends. A store with one in-process writer slot for everything (such as [`MemoryRefStore`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.MemoryRefStore.html), or a database with a single write transaction) must wait inside [`RefStore::prepare_for`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/trait.RefStore.html#method.prepare_for) using [`SingleWriterGate`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.SingleWriterGate.html) (or equivalent FIFO queueing) for the supplied [`LockWait`](https://docs.rs/grit-lib/latest/grit_lib/lockfile/enum.LockWait.html); returning immediate `LockHeld` for every overlap and relying on jittered exponential backoff between retries will starve waiters under load. grit-lib's ref writes call `prepare_for` through [`prepare_with_lock_wait`](https://docs.rs/grit-lib/latest/grit_lib/refs/fn.prepare_with_lock_wait.html) with `core.filesRefLockTimeout` (100 ms by default, `0` to fail fast, `-1` to wait indefinitely) and only retry backoff when the store still reports `LockHeld` after that wait (typically another process holding a ref lock file). Immediate `LockHeld` from another process is expected; in-process single-slot stores should not surface it until the budget elapses. [`RefStore::ref_lock_wait`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/trait.RefStore.html#method.ref_lock_wait) selects that budget: the files backend reads its git directory, a bare [`MemoryRefStore`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.MemoryRefStore.html) uses Git's default, and the store from [`Repository::ref_store`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.ref_store) (including an injected backend) reads `core.filesRefLockTimeout` from the open repository's git directory so porcelain and library commit helpers honor the same setting as on disk. Time spent inside `prepare_for` counts against the budget, so backends that already wait for their own lock files are not waited for twice when they ignore the passed `wait`. Call `prepare_with_lock_wait` yourself when you prepare transactions directly:

```rust
use grit_lib::lockfile::LockWait;
use grit_lib::refs::prepare_with_lock_wait;
use grit_lib::refs::store::{RefStore, RefTransaction};

fn apply(store: &dyn RefStore, txn: RefTransaction) -> grit_lib::error::Result<()> {
    let wait = LockWait::files_ref_lock(None);
    prepare_with_lock_wait(store, txn, wait)?.commit()?;
    Ok(())
}
```

Reftable failures are typed as [`ReftableError`](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/enum.ReftableError.html) inside `Error::Reftable`: `Locked` when another writer holds `tables.list.lock`, `ExpectedMismatch` when a compare-and-swap update finds a different value, and corruption variants such as `BadMagic`, `FooterChecksumMismatch` or `Truncated` (which names the [`ReftableField`](https://docs.rs/grit-lib/latest/grit_lib/refs/reftable/enum.ReftableField.html) that was cut short). Through a [`ReftableRefStore`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.ReftableRefStore.html) transaction, a held lock surfaces as `RefStoreError::LockHeld` and a compare-and-swap failure as `RefStoreError::ExpectedMismatch`, the same variants the files backend returns.

## Transactions

Batch ref updates use [`RefTransaction`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefTransaction.html): queue [`RefUpdate`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefUpdate.html) entries with [`Expected`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.Expected.html) old-value checks, optional [`ReflogUpdate`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.ReflogUpdate.html), then `RefStore::prepare` → commit or abort. Fetch, push, receive-pack, and [`update_refs`](https://docs.rs/grit-lib/latest/grit_lib/refs/gc/fn.update_refs.html) route through this path so locking and compare-and-swap semantics stay in the backend. A failed compare-and-swap on the files backend is side-effect free: neither the ref nor its reflog is updated.

Non-atomic receive-pack and local push batch ref updates the way [`References::apply_each`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.apply_each) does: deletions commit in one transaction, then creates and updates in another (matching Git `execute_commands_non_atomic`). Within each phase, [`RefTransaction::allowing_failures`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefTransaction.html#method.allowing_failures) records compare-and-swap, directory/file, and object-target rejections per ref while siblings still share one reftable table or one files batch. Atomic pushes still use all-or-nothing [`commit_ref_updates_on_store`](https://docs.rs/grit-lib/latest/grit_lib/refs/fn.commit_ref_updates_on_store.html), which [`References::apply`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.apply) calls on the repository's store.

To fill a new repository, such as the refs a clone imports, mark the batch with [`RefTransaction::initial`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefTransaction.html#method.initial), the equivalent of Git's initial ref transaction. When every update creates a direct ref that does not exist yet (no reflog, `Expected::Any` or `Expected::Missing`), the files backend checks names against one listing of the store and writes the whole batch as a single sorted `packed-refs` rewrite, with peel lines for annotated tags, under `packed-refs.lock` only. It writes no loose file or lock per ref, so 200,000 refs cost one file write. Any other batch, and every other backend, commits as usual. Only use it where no other writer creates the same refs at the same time.

Every backend (files, reftable, memory, or your own wrapper around one) refuses the same malformed batches in `prepare`, before taking any lock. A name that is not safe to store (path traversal, a `.lock` suffix, spaces, empty or doubled components, a non-`refs/` name that is not an all-caps pseudo-ref like `ORIG_HEAD`), on an update or on either side of a reflog or case-only rename, fails with [`RefStoreError::InvalidRefName`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.RefStoreError.html#variant.InvalidRefName). A symbolic value whose target is malformed (control characters, spaces, `..`, `.lock`, and the other rules Git applies to symref targets), would make `HEAD` point outside `refs/`, or points a ref at itself, fails with [`RefStoreError::InvalidSymrefTarget`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.RefStoreError.html#variant.InvalidSymrefTarget). Non-`HEAD` symrefs may use Git one-level targets such as `foo` or `heads/main`; `HEAD` must point under `refs/`. The target ref does not have to exist yet (unborn branches and aliases to not-yet-created refs stay valid). Storing the all-zero object id as a direct value fails with [`RefStoreError::NullOid`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.RefStoreError.html#variant.NullOid), because Git reads such a ref as broken. To delete a ref, set `new_value: None`; the commit removes that ref's reflog (matching Git), even when the update carries a [`ReflogUpdate`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.ReflogUpdate.html). Reflog-only updates may still record the null id.

The store a repository hands out, [`Repository::ref_store`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.ref_store), also checks every transaction against the repository's objects before any lock, as `git update-ref` does. This covers injected stores, [`References::update`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.update) and the branch move of [`update_branch_for_commit_on_store`](https://docs.rs/grit-lib/latest/grit_lib/refs/fn.update_branch_for_commit_on_store.html) (its files-backend fast path runs the same check before it takes the branch lock), and every other `References` writer (`update_direct`, `compare_and_swap`, `apply`, `apply_each`). A direct value naming an object the repository does not store fails with [`RefStoreError::MissingObject`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.RefStoreError.html#variant.MissingObject). A branch (`refs/heads/…`) or `HEAD` pointed at anything but a commit fails with [`RefStoreError::NotACommit`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.RefStoreError.html#variant.NotACommit). Tags, remote-tracking refs and other refs may name any object. The lookup reads object headers only and never lazily fetches from a promisor remote. The empty tree counts only once it is actually stored, because `git fsck` reports a ref to an unstored one as missing. An unreadable object fails with [`RefStoreError::ObjectLookup`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.RefStoreError.html#variant.ObjectLookup). Deletes and symbolic values are not looked up; reflog-only updates and explicit reflog object ids are checked the same way. One bad update fails the whole batch, and every ref stays unchanged.

Because of this check, writing a commit and then moving a branch to it with a compare-and-swap update is safe against a concurrent `git gc --prune=now`. If the prune removes the commit before the update, the update fails with `MissingObject` and does not leave a branch pointing at a missing commit. To write a dangling ref on purpose (for example, a corrupt-repository fixture), set [`RefUpdateFlags::skip_oid_verification`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefUpdateFlags.html#structfield.skip_oid_verification) on the update. A backend opened on its own, such as one from [`RepoCaches::open_ref_store`](https://docs.rs/grit-lib/latest/grit_lib/repo/caches/struct.RepoCaches.html#method.open_ref_store) or a bare `MemoryRefStore`, does not look at objects.

## Reset validation

[`reset_to_commit`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/reset/struct.ResetOutcome.html) validates
[`ResetOptions::identity`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/reset/struct.ResetOptions.html#structfield.identity)
before changing any repository state. If a caller modifies a public
[`Signature`](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.Signature.html) field to an invalid value, reset
returns [`ObjectError::InvalidSignature`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.ObjectError.html#variant.InvalidSignature)
with HEAD, branch refs, index bytes, worktree files, reflogs, and operation state
unchanged. This includes merge autostashes and `refs/stash`.

The same validation applies to
[`preview_reset`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/reset/struct.ResetOutcome.html) and dry runs,
even when the target is already HEAD or `core.logAllRefUpdates=false`. This is a
preflight guarantee for invalid signatures; later I/O errors can leave partial
updates.

## Resolving HEAD and symbolic refs

`resolve_head` reads `HEAD` from a git directory and returns a `HeadState`; `resolve_head_for_repository` reads it through the repository's store (an empty injected store gives `HeadState::Invalid`). When you only need the commit `HEAD` is on, call [`Repository::head_commit`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.head_commit): it reads through the same store and fails with [`RefError::UnbornHead`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.RefError.html#variant.UnbornHead) on a branch with no commits yet, or [`RefError::InvalidHead`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.RefError.html#variant.InvalidHead) when `HEAD` names nothing (both under [`Error::Ref`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Ref)). For the tree to diff or check out against, [`Repository::head_tree`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.head_tree) returns `None` on an unborn branch and the same `RefError::InvalidHead` otherwise; [`HeadState::tree`](https://docs.rs/grit-lib/latest/grit_lib/state/enum.HeadState.html#method.tree) does the same for a `HeadState` you already resolved, but treats an invalid `HEAD` as "no tree". `resolve_ref` (or `RefStore::resolve` on the repository store) follows symbolic refs with cycle detection. `read_ref_file` returns a `Ref` without resolving the full chain.

On every backend, a missing ref fails with [`RefStoreError::NotFound`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.RefStoreError.html#variant.NotFound) inside `Error::RefStore`, naming the ref that is absent. For a dangling symbolic ref (an unborn branch behind `HEAD`, say) that is the target, not the name you asked for. [`References::delete`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.delete) on a missing ref fails the same way. Match on the variant rather than the message:

```rust
use grit_lib::error::Error;
use grit_lib::refs::store::{RefName, RefStoreError};

let topic = RefName::try_from("refs/heads/topic")?;
match repo.references().resolve(&topic) {
    Ok(oid) => println!("topic is at {oid}"),
    Err(Error::RefStore(RefStoreError::NotFound { name })) => {
        println!("{} does not exist", name.as_str());
    }
    Err(err) => return Err(err.into()),
}
```

## Listing, writing, and reflog

Parse a newest-first `ref@{n}` entry with [`ReflogSelector`](https://docs.rs/grit-lib/latest/grit_lib/refs/reflog/struct.ReflogSelector.html)
and pass its `ref_name` and `index` to `repo.reflogs().entries` or `delete`.
[`parse_reflog_ref`](https://docs.rs/grit-lib/latest/grit_lib/refs/reflog/fn.parse_reflog_ref.html) validates a reference alone:
`HEAD` stays `HEAD`, `main` becomes `refs/heads/main`, and already valid multi-component
names are retained as supplied. Neither parser reads the repository or checks existence.
Malformed selectors return `Error::ReflogInvalidSelector`, invalid or overflowing indices
return `Error::ReflogInvalidIndex` (with the integer error as its source), and invalid
reference names return `Error::ReflogUnknownRef`. The handle checks for missing logs
and out-of-range indices when you query or delete entries. It works on
`Repository::ref_store` (`for_each_reflog_ref`, `for_each_reflog_entry`, `replace_reflog`, `rewrite_reflog`),
so it behaves the same on the files, reftable and injected backends; on the files
backend, newest-first queries read the log backwards and stop at the limit.

[`References::list`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.list) iterates with a prefix and [`References::list_glob`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.list_glob) with a glob such as `refs/tags/v*`, both sorted by name. Use [`References::apply`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.apply) (or a [`RefTransaction`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/struct.RefTransaction.html) on the store) when updating many refs atomically. There are no git-directory-path ref functions: open a [`Repository`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) on the git directory and use its handles.

Reflog helpers live in [`reflog`](https://docs.rs/grit-lib/latest/grit_lib/refs/reflog/index.html) and on [`RefStore`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/trait.RefStore.html) (`for_each_reflog_entry`, `replace_reflog`, [`rewrite_reflog`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/trait.RefStore.html#tymethod.rewrite_reflog), …). Use `rewrite_reflog` for expire, delete, and other read-modify-write paths. Built-in backends hold the same writer lock as `prepare`/`commit` for the whole call; **custom backends must implement `rewrite_reflog` themselves** (there is no default) and keep that exclusion through the transform closure—do not call back into the store from the closure. [`RepositoryReflogs::append`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryReflogs.html#method.append) records an entry without moving the ref, [`RepositoryReflogs::exists`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryReflogs.html#method.exists) checks for a log, and [`References::reflog`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.reflog) reads entries back oldest first.

## Operation state

[`repo.operation()`](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.Operations.html) reports what a paused merge, rebase, `am`, cherry-pick, revert or bisect left behind. [`state`](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.Operations.html#method.state) returns an [`OperationState`](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.OperationState.html) with the paused operations, `MERGE_HEAD`, `MERGE_MSG`, `CHERRY_PICK_HEAD`, `REVERT_HEAD` and `ORIG_HEAD`; [`in_progress`](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.Operations.html#method.in_progress) is the cheap check, [`blocking_switch`](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.Operations.html#method.blocking_switch) names the operation that must finish before `HEAD` may move, [`status_state`](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.Operations.html#method.status_state) has the details `grit status` shows, and [`clear`](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.Operations.html#method.clear) forgets every paused operation without touching `HEAD`, refs or files.

```rust
let state = repo.operation().state()?;
if !state.merge_heads.is_empty() {
    println!("merging {} commit(s)", state.merge_heads.len());
}
if let Some(op) = repo.operation().blocking_switch()? {
    println!("finish the {} first", op.description());
}
```

## Branches and tags

[`repo.branches()`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Branches.html) covers branch create, delete, rename, upstream configuration, and listing. Pass [`BranchListQuery`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.BranchListQuery.html) and [`BranchDetail::Full`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/enum.BranchDetail.html#variant.Full) to [`Branches::list`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Branches.html#method.list) for what `grit branch` renders (subject, committer time, upstream ahead/behind, worktree). Use [`BranchDetail::Names`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/enum.BranchDetail.html#variant.Names) for ref names and oids only. For a minimal local list without commit reads, [`Branches::list_simple`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Branches.html#method.list_simple) returns [`BranchList`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/struct.BranchList.html) (name, oid, current).

[`repo.tags()`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Tags.html) creates, lists, deletes, and verifies tags. Call [`Tags::list`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Tags.html#method.list) with [`TagListOptions`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.TagListOptions.html) and [`TagDetail::Names`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/enum.TagDetail.html#variant.Names) for names without tag-object reads, [`TagDetail::Kind`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/enum.TagDetail.html#variant.Kind) for packed-peel classification, or [`TagDetail::Annotation`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/enum.TagDetail.html#variant.Annotation) for complete [`TagSummary`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/struct.TagSummary.html) rows (annotation messages and taggers). [`TagListOptions::full_annotations`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.TagListOptions.html#method.full_annotations) is a convenience builder for the legacy annotated listing.

[`repo.checkout()`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Checkout.html) switches branches, checks out trees, resets, restores paths, cleans untracked files, and performs index path moves — the same operations the `grit switch`, `reset`, `restore`, `clean`, `mv`, and `rm` commands call.

[`Branches::delete`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Branches.html#method.delete) refuses the current branch and branches checked out in another worktree. With [`BranchDeleteMode::Safe`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/enum.BranchDeleteMode.html#variant.Safe) it also requires the branch tip to be reachable from the branch's upstream, or from `HEAD` when there is no upstream (the same rule as `git branch -d`).

Each refusal is an `Error::Branch(BranchError::...)`: `NotFound` for a missing branch, `CurrentlyCheckedOut { name }` for the branch named by this repository's own `HEAD`, `CheckedOut { name, worktree }` for a branch held by another worktree, or `NotFullyMerged` for an unmerged tip.

The current-branch check reads `HEAD` through the repository's store, including injected stores, even when the on-disk `HEAD` differs. `DeleteMode::Force` skips only the merge-state check; both it and dry runs retain the checked-out safety checks and leave HEAD and refs unchanged on refusal. The CLI maps both checked-out variants to the JSON kind `branch_checked_out`.

[`Tags::delete`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Tags.html#method.delete) returns the object the tag pointed at, or `Error::Tag(`[`TagError::NotFound`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/enum.TagError.html#variant.NotFound)`)` when the tag does not exist. Both deletes run on the repository's ref store (so an injected store is honoured), compare-and-swap against the commit they checked, and remove the ref's reflog.

```rust
use grit_lib::error::Error;
use grit_lib::porcelain::branch::{BranchDeleteMode, BranchDeleteOptions, BranchError};

let dry_run = false;
match repo.branches().delete(
    "topic",
    &BranchDeleteOptions::default()
        .with_mode(BranchDeleteMode::Safe)
        .with_dry_run(dry_run),
) {
    Ok(deleted) => println!("deleted topic (was {})", deleted.oid),
    Err(Error::Branch(BranchError::CurrentlyCheckedOut { name })) => {
        println!("{name} is the current branch");
    }
    Err(Error::Branch(BranchError::CheckedOut { name, worktree })) => {
        println!("{name} is held by {worktree}");
    }
    Err(Error::Branch(BranchError::NotFullyMerged { .. })) => {
        println!("topic has unmerged commits");
    }
    Err(err) => return Err(err),
}
```

[`References::query`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.query) shares ancestry results between evaluated tips for finite, name-ordered `contains` queries. It stops after `RefQuery::limit` matching rows, preserving patterns, namespace unions, reverse ordering, and annotated-tag peeling. Filter targets are validated even for a zero limit or an empty candidate set. Unlimited queries, version/date sorts, and combined reachability or object filters retain the shared batch walk.

## Upstream, target branch, and ahead/behind

[`branch_tracking`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/index.html) answers "how does this branch compare with its base?", the question `grit status` and `grit shortlog` show at the top. `upstream_branch` resolves a branch's configured upstream, `target_branch` finds the repository's trunk (the `target.branch` config value, then [`DEFAULT_TARGET_CANDIDATES`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/constant.DEFAULT_TARGET_CANDIDATES.html)), and `comparison_base` picks the upstream when it exists and the target otherwise (legacy helper). [`BranchStanding::compute`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.BranchStanding.html#method.compute) returns separate [`TrackedComparison`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.TrackedComparison.html) values for target and upstream for status, with [`StatusHeader`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/enum.StatusHeader.html) for the human header line and pull hints. Each base resolves to a [`ComparisonBase`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.ComparisonBase.html) with the display name, full ref, commit, and [`BaseSource`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/enum.BaseSource.html), through the repository's ref store.

[`TipComparison`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.TipComparison.html)`::compute` then counts commits on each side (the same numbers as `git rev-list --left-right --count tip...base`), keeps the newest ahead commits up to a limit, and classifies the result as a [`Standing`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/enum.Standing.html): even, ahead, behind, or diverged. For `grit shortlog`, [`Branches::compare_with_target`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.Branches.html#method.compare_with_target) with [`TargetComparisonOptions`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.TargetComparisonOptions.html) resolves the current branch and target (including `--target`) and returns [`TargetComparison`](https://docs.rs/grit-lib/latest/grit_lib/refs/branch_tracking/struct.TargetComparison.html) with bounded ahead and optional behind OID lists. For symmetric tip comparisons when you already have two commit ids, use `TargetTipListOptions` and `TargetTipLists``::compute`.

```rust
use grit_lib::refs::branch_tracking::{BranchStanding, Standing, StandingOptions};
use grit_lib::state::HeadState;

let head = repo.references().head()?;
let standing = BranchStanding::compute(&repo, &head, StandingOptions::default())?;
if let Some(target) = standing.target.as_ref() {
    if target.standing() == Standing::Behind {
        println!("{} new commits on {}", target.behind, target.base.name);
    }
}
```

## Writing a ref backend

Ref backend design, transaction helpers, conformance tests, and how init interacts with [`RepositoryOptions::with_ref_store`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_ref_store) are documented in [Writing storage backends](https://grit-scm.com/docs/library/refs/storage-backends.md/index.md) (see [Ref storage](https://grit-scm.com/docs/library/refs/storage-backends.md/index.md#ref-storage) and [Testing](https://grit-scm.com/docs/library/refs/storage-backends.md/index.md#testing)). The worked example remains [`grit-lib/tests/refstore_custom_backend.rs`](https://github.com/gitbutlerapp/grit/blob/main/grit-lib/tests/refstore_custom_backend.rs).

## Ref names (`RefName` / `RefNamePolicy`)

Parse human-facing ref strings with [`RefName::parse`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefName.html#method.parse) and a [`RefNamePolicy`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefNamePolicy.html). The default policy matches `git check-ref-format` with no flags. Setters such as [`allow_onelevel`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefNamePolicy.html#method.allow_onelevel), [`refspec_pattern`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefNamePolicy.html#method.refspec_pattern), [`normalize`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefNamePolicy.html#method.normalize), [`storable`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefNamePolicy.html#method.storable), [`advertised_fetch`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefNamePolicy.html#method.advertised_fetch), and [`receive_pack`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefNamePolicy.html#method.receive_pack) mirror the free validators removed from the public API.

Branch and tag short names use [`RefName::branch`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefName.html#method.branch) and [`RefName::tag`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefName.html#method.tag). When normalization may allocate, parse into an owned [`RefName`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefName.html); when the input is already canonical, [`RefNameRef::parse`](https://docs.rs/grit-lib/latest/grit_lib/refs/check_ref_format/struct.RefNameRef.html#method.parse) validates in place. Names loaded from the ref store skip re-validation when the library already trusts the on-disk source.

## Examples

**Library guide** — resolve HEAD, list branches and tags, update a demo branch (included on this page):

```rust
//! Resolve HEAD, list branches and tags, update a branch ref with reflog.
//!
//! Source for the library guide "Refs" page (included in the docs site).

use anyhow::Result;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::objects::ObjectId;
use grit_lib::refs::listing::{RefNamespace, RefQuery, RefSort, SortKey};
use grit_lib::refs::reflog::ReflogEntry;
use grit_lib::refs::store::RefName;
use grit_lib::refs::{self, Ref};
use grit_lib::repo::Repository;
use grit_lib::repo_handles::ReflogCreate;

use std::path::{Path, PathBuf};

const DEMO_BRANCH: &str = "refs/heads/library-guide-demo";

fn open_repo(root: &Path) -> Result<Repository> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::from_process();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Ok(Repository::open(&git_dir, &opts)?)
}

fn main() -> Result<()> {
    let root = std::env::args()
        .nth(1)
        .map(PathBuf::from)
        .or_else(|| std::env::current_dir().ok())
        .ok_or_else(|| anyhow::anyhow!("missing repository path"))?;
    let repo = open_repo(&root)?;
    let git_dir = repo.git_dir();

    let head = repo.references().head()?;
    match &head {
        grit_lib::state::HeadState::Branch { refname, oid, .. } => {
            println!("head_symbolic={refname}");
            if let Some(oid) = oid {
                println!("head_oid={}", oid.to_hex());
            }
        }
        grit_lib::state::HeadState::Detached { oid } => {
            println!("head_detached={}", oid.to_hex());
        }
        grit_lib::state::HeadState::Invalid => println!("head_invalid=1"),
    }

    let head_file = refs::read_ref_file(&git_dir.join("HEAD"))?;
    if let Ref::Symbolic(target) = head_file {
        println!("head_file_symbolic={target}");
    }

    for branch in repo.branches().list_simple()?.branches {
        let marker = if branch.current { "*" } else { " " };
        println!("branch {marker} {} {}", branch.name, branch.oid.to_hex());
    }
    let tag_query = RefQuery::default()
        .with_namespaces(vec![RefNamespace::Tags])
        .with_sort(RefSort::default().with_key(SortKey::Name));
    let tag_rows = repo
        .tags()
        .list(&grit_lib::repo_handles::TagListOptions::full_annotations(
            tag_query,
        ))?
        .into_summaries()
        .ok_or_else(|| anyhow::anyhow!("expected annotated tag summaries"))?;
    for tag in tag_rows {
        println!("tag {} {} {:?}", tag.name, tag.oid.to_hex(), tag.kind);
    }

    println!("ref_storage={}", repo.ref_store().format());

    let target = head
        .oid()
        .cloned()
        .ok_or_else(|| anyhow::anyhow!("HEAD has no commit"))?;

    let demo = RefName::try_from(DEMO_BRANCH)
        .map_err(|err| anyhow::anyhow!("invalid demo ref name: {err}"))?;
    let old = repo.references().resolve(&demo).ok();
    repo.references().update(&demo, &target)?;

    let zero = ObjectId::zero();
    let old_oid = old.as_ref().unwrap_or(&zero);
    let identity = "Library Guide <guide@grit-scm.com> 1735689600 +0000";
    repo.reflogs().append(
        &demo,
        &ReflogEntry {
            old_oid: *old_oid,
            new_oid: target,
            identity: identity.to_owned(),
            message: "library guide refs example".to_owned(),
        },
        ReflogCreate::Always,
    )?;

    println!("demo_ref={DEMO_BRANCH}");
    println!("demo_oid={}", target.to_hex());

    let entries = repo.references().reflog(&demo)?;
    if let Some(last) = entries.last() {
        println!("demo_reflog_new={}", last.new_oid.to_hex());
        println!("demo_reflog_message={}", last.message);
    }

    Ok(())
}
```

**Custom ref store** — wrap `MemoryRefStore` with operation counting and inject it via `Repository::with_ref_store`:

```rust
//! Inject a counting in-memory ref store through [`Repository::with_ref_store`].
//!
//! Demonstrates embedder-owned ref storage without touching on-disk refs.

use std::sync::Arc;

use grit_examples::counting_ref_store::CountingRefStore;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::objects::ObjectId;

use grit_lib::refs::store::{
    Expected, MemoryRefStore, RawRef, RefName, RefStore, RefTransaction, RefUpdate,
};
use grit_lib::repo::Repository;
use grit_lib::revwalk::ResolveOptions;

fn main() -> grit_lib::error::Result<()> {
    let repo = Repository::discover(None, &RepositoryOptions::from_process())?;
    let oid: ObjectId = "0100000000000000000000000000000000000000".parse()?;

    let memory = Arc::new(MemoryRefStore::new());
    memory.set_ref("refs/heads/custom-demo", RawRef::Direct(oid))?;
    let counting = Arc::new(CountingRefStore::new(memory));
    let repo = repo.with_ref_store(counting.clone());

    let resolved = repo
        .revwalk()
        .resolve("refs/heads/custom-demo", &ResolveOptions::default())?;
    let listed = repo.references().list("refs/heads/").map(|refs| {
        refs.into_iter()
            .map(|(n, o)| (String::from(n), o))
            .collect::<Vec<_>>()
    })?;

    println!("resolved={resolved}");
    println!("listed={}", listed.len());
    println!("read_raw_calls={}", counting.read_raw_calls());
    println!("for_each_ref_calls={}", counting.for_each_ref_calls());

    let txn = RefTransaction::new().update(
        RefUpdate::new(
            RefName::new("refs/heads/custom-demo")?,
            Some(RawRef::Direct(oid)),
        )
        .with_expected(Expected::Oid(oid)),
    )?;
    counting.prepare(txn)?.commit()?;
    println!("prepare_calls={}", counting.prepare_calls());

    Ok(())
}
```

Library code calls back into the store from iteration callbacks (for example, it reads each listed ref's reflog inside `for_each_reflog_ref`), so a custom backend must not hold an internal lock while it runs a `for_each_ref`, `for_each_reflog_entry` or `for_each_reflog_ref` callback. Collect what you need, or clone an `Arc` of the current state, and release the lock first. See [`RefStore`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/trait.RefStore.html) for the full contract.

```bash
cargo run --bin guide_refs /path/to/repo
cargo run --bin custom_ref_store
```

# https://grit-scm.com/docs/library/repository/index.md

# Repository

> Open and discover Git repositories with an explicit Environment, read git-dir vs work tree, load config, and handle grit_lib::Error.

A [`Repository`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) is the main handle for grit-lib. Use [`Repository::git_dir`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html), [`Repository::work_tree`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html), and [`Repository::odb`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) for paths and the object store; discovery provenance is available through [`DiscoveryInfo`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.DiscoveryInfo.html) via [`Repository::discovery_info`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html). The [`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html) used to open the handle is returned by [`Repository::environment`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html).

## Environment

[`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html) holds discovery and config variables (`GIT_DIR`, `GIT_WORK_TREE`, `GIT_CEILING_DIRECTORIES`, `GIT_CONFIG_*`, home paths, `cwd`, and related fields) without reading the process environment inside the library. Construct one with `Environment::capture_process()` (an explicit snapshot of the calling process, which is what the `grit` CLI uses), `Environment::from_vars()` (parse an iterator of `(key, value)` pairs plus an explicit working directory) or `Environment::empty()` (no variables: no home directory, so no global config, and no Git for Windows system config). See [`Environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html).

To point at a specific repository or override config for one operation (what `grit -C`, `--git-dir`, `--work-tree` and `-c` do), use `Environment::with_git_dir` and `Environment::with_work_tree` (relative paths resolve against the environment's `cwd`), and parse `key=value` into a [`ConfigOverride`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.ConfigOverride.html) for `Environment::push_config_override`. Overrides are stored in `GIT_CONFIG_PARAMETERS` form, so they load with command-line scope and reach hooks through `Environment::subprocess_environment`.

The `grit` CLI builds an environment from the process in `grit-cli` and passes it into discovery. A tool that works on a user's repositories should do the same so system and global config (`core.autocrlf`, identity, `safe.directory`, `core.excludesFile`, credential helpers) apply as they do for `git`: open with [`RepositoryOptions::from_process`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.from_process), or snapshot the variables you care about once and pass them through [`RepositoryOptions::with_environment`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_environment), then call [`Repository::discover`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) or [`Repository::open`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html). [`RepositoryOptions::empty`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.empty) is for hermetic use such as tests.

Create new repositories with [`Repository::init`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) and [`InitOptions`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.InitOptions.html); the call returns `(Repository, InitOutcome)` so callers can read what was written on disk (for example the initial branch name). Pass [`RepositoryOptions`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html) through [`InitOptions::with_repository_options`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.InitOptions.html#method.with_repository_options) and the returned handle keeps them, as if opened with them: the environment (which also resolves `init.defaultBranch`), command runner, diagnostics and injected stores. The default [`InitOptions`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.InitOptions.html) leaves the handle hermetic, like [`RepositoryOptions::empty`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.empty). Custom object and ref backends use [`RepositoryOptions::with_object_store`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_object_store) (read layers through [`RepositoryOptions::with_odb_builder`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_odb_builder)) and [`RepositoryOptions::with_ref_store`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_ref_store), with [`Repository::init`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.init) (which then creates no `objects/` or `refs/` for them; see [Object stores](https://grit-scm.com/docs/library/repository/object-stores.md/index.md#creating-a-repository-on-your-stores)), [`Repository::open`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) or [`Repository::discover`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html).

[`ConfigSet::load`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.ConfigSet.html) takes `&Environment` as its first argument and always parses the cascade from disk (no process-global cache). Repository-scoped memoization lives on each open handle: [`Repository::config`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) returns a [`Config`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html) handle backed by [`RepoCaches`](https://docs.rs/grit-lib/latest/grit_lib/repo/caches/struct.RepoCaches.html) (config cascade, gitattributes stacks, filter-process drivers, precompose flags, and related state). Call [`Config::snapshot`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.snapshot) when you need an `Arc<ConfigSet>`.

## Command runner

Hooks, clean/smudge filters, credential helpers, signing, SSH transport, and similar features spawn subprocesses through a [`CommandRunner`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/trait.CommandRunner.html) stored on the repository (via [`RepositoryOptions::command_runner`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html)). The default is [`SystemCommandRunner`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.SystemCommandRunner.html), which is the only non-test code path that calls `std::process::Command`. Tests and embedders can install [`RecordingRunner`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/struct.RecordingRunner.html) or a custom runner to assert argv, environment, and stdin without executing real programs. Hook failures surface as [`HookError`](https://docs.rs/grit-lib/latest/grit_lib/command_runner/hooks/enum.HookError.html); shell filter subprocess failures use [`FilterError`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.FilterError.html). When a `filter.<driver>.required` filter fails, staging, status and checkout return [`WorktreeError::Filter`](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.WorktreeError.html#variant.Filter) and never fall back to unfiltered content. A filter that cannot be started at all is `FilterError::ExternalFilterSpawnFailed`, which carries the program and the OS error. An optional filter that fails leaves the content unfiltered, as Git does.

## Discover vs open

Call [`Repository::discover`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) when you have a working directory and want Git-style upward search. Call [`Repository::open`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) when you already know the git directory; set [`RepositoryOptions::work_tree`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html) for non-bare layouts, [`RepositoryOptions::for_serving`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html) for smart-HTTP paths, and [`RepositoryOptions::without_format_validation`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html) when discovery must open before format checks.

After a handle is open, [`Repository::discovery_info`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) returns [`DiscoveryInfo`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.DiscoveryInfo.html) (whether discovery started from an explicit git directory, the discovery root, and related metadata). [`RepositoryLocation`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.RepositoryLocation.html) is the path-oriented view of the same layout (`From<&Repository>`); use it when you already have a handle and need git-dir vs work-tree paths without opening again.

Ownership during discovery goes through [`RepositoryOptions::ownership_check`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.ownership_check) ([`OwnershipCheck`](https://docs.rs/grit-lib/latest/grit_lib/ownership_check/trait.OwnershipCheck.html)). The default [`SystemOwnershipCheck`](https://docs.rs/grit-lib/latest/grit_lib/ownership_check/struct.SystemOwnershipCheck.html) matches Git: owned repositories open immediately; foreign-owned paths require `safe.directory`. Embedders and tests install a custom check with [`RepositoryOptions::with_ownership_check`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_ownership_check) (for example one that sets [`always_apply_safe_directory`](https://docs.rs/grit-lib/latest/grit_lib/ownership_check/trait.OwnershipCheck.html#method.always_apply_safe_directory) instead of reading `GIT_TEST_ASSUME_DIFFERENT_OWNER`).

Bare repositories return `None` from `Repository::work_tree`. When a handle has a work tree, [`Repository::is_bare`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.is_bare) is `false`, even if `core.bare` is `true` (for example a linked checkout of a bare repository, or opening the bare git directory with an explicit `GIT_WORK_TREE` / [`RepositoryOptions::work_tree`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html)). Linked worktrees and gitfile indirection are handled during discovery so `Repository::git_dir` always points at the directory that contains `objects/`.

Both paths are canonical (symlinks resolved). On Windows they use the plain `C:\...` or `\\server\share\...` spelling, so you can compare them with your own paths, use `starts_with` and show them to users. The `\\?\` form that `std::fs::canonicalize` returns is kept only for a path that cannot be written any other way, such as one longer than `MAX_PATH`. If your path may be relative or go through a symlink, pass both sides through [`path_for_disk_compare`](https://docs.rs/grit-lib/latest/grit_lib/config/git_path/fn.path_for_disk_compare.html) before comparing.

## Config

`Repository::config` returns a lazily loaded snapshot of the merged cascade (system / global / local / worktree / environment overrides). Prefer it on hot paths instead of calling `ConfigSet::load` repeatedly. Keys use Git’s dotted names (`user.name`, `core.bare`, …).

## Typed handles

Core engine areas use thin handles on `Repository` (no duplicated logic):

| Method | Handle | Role |
| --- | --- | --- |
| [`objects`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) | [`Objects`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.Objects.html) | read/write/contains for the ODB |
| [`references`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) | [`References`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html) | resolve, list, update refs; read reflog |
| [`reflogs`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) | [`RepositoryReflogs`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryReflogs.html) | list reflog refs, show/delete/expire entries |
| [`index`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) | [`IndexFile`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexFile.html) | load/write the index |
| [`config`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.config) | [`Config`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html) | merged get; local set + reload |
| [`revwalk`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) | [`RevWalk`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html) | rev-parse specs; rev-list walks |
| [`diff`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) | [`Diff`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Diff.html) | tree↔tree, index↔tree, worktree↔index |

For the raw backend, use [`references().store()`](https://docs.rs/grit-lib/latest/grit_lib/refs/struct.References.html#method.store) (same as [`ref_store`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.ref_store)).

Larger subsystems use [`repo_handles`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/index.html):

| Method | Handle | Role |
| --- | --- | --- |
| `Repository::remotes` | `Remotes` | List/get remotes, `ls-remote`, fetch, push, push planning, fetch/push over a caller-supplied transport (`fetch_from` / `push_to`) |
| `Repository::worktrees` | `Worktrees` | List/add/remove/lock/unlock linked worktrees |
| `Repository::stash` | `RepositoryStash` | Stash list/push/apply/pop/drop/branch/clear (the one stash API) |
| `Repository::notes` | `RepositoryNotes` | Notes list/read/add/remove via `NotesRef` |
| `Repository::bundles` | `Bundles` | Bundle write/verify/list-heads/unbundle/fetch |
| `Repository::snapshot_checkouts` | `SnapshotCheckouts` | Snapshot checkouts: make and project snapshots (server), refresh and check in (checkout). Only with the `unstable-hosting` feature, which is outside the semver promise |

Transport options, the stash identity, and notes authors and committers are passed in as arguments on those methods (no hidden wall-clock reads in the handle layer).

## Identity

Author, committer, and stash identities are typed [`Signature`](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.Signature.html) values (name, email, and an `OffsetDateTime`), not pre-formatted strings. [`Repository::identity`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.identity) resolves the one Git would record for an [`IdentRole`](https://docs.rs/grit-lib/latest/grit_lib/config/ident_resolve/enum.IdentRole.html) at a timestamp: it honours `GIT_AUTHOR_*` / `GIT_COMMITTER_*` (including the `*_DATE` overrides) from the handle's environment and `author.*`, `committer.*` and `user.*` config, and fails with [`CommitError::Identity`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/enum.CommitError.html#variant.Identity) (a typed `IdentityError`) when no identity is configured or a date override is not a date Git accepts. The same resolution without a repository is [`resolve_signature_with`](https://docs.rs/grit-lib/latest/grit_lib/config/ident_resolve/fn.resolve_signature_with.html).

Use [`CommitRequest::new`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/commit/struct.CommitRequest.html#method.new) for the message, then set public fields such as `author`. `CommitRequest` and `ContinueOptions` (merge `--continue`) take `Option<Signature>`, where `None` means the repository's identity for that role (for example, leave `committer` unset and `create_commit` uses the handle's committer identity); `RewriteOptions`, `StashPushOptions` and `NotesWriteOptions` take a `Signature`. Build one by hand with [`Signature::new`](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.Signature.html#method.new), parse a full `Name <email> <unix> <±HHMM>` header line with `str::parse`, or stamp a `--author`-style contact with [`AuthorContact::signature`](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.AuthorContact.html#method.signature). Reflog entries use [`resolve_loose_committer_identity_with`](https://docs.rs/grit-lib/latest/grit_lib/config/ident_resolve/fn.resolve_loose_committer_identity_with.html), which never fails. [`Repository::identity_now`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.identity_now) gives the handle's clock (its reference time when one was set) in its `TZ`.

```rust
//! Resolve author identity and build a [`CommitRequest`].
//!
//! Source for the library guide "Repository" page Identity section (included in the docs site).

use std::ffi::OsString;

use grit_lib::config::environment::{Environment, RepositoryOptions};
use grit_lib::config::ident_resolve::IdentRole;
use grit_lib::error::Error;
use grit_lib::porcelain::commit::CommitRequest;
use grit_lib::repo::{InitOptions, Repository};

fn main() -> Result<(), Error> {
    let base = tempfile::tempdir().map_err(Error::Io)?;
    let root = base.path().join("repo");

    let env = Environment::from_vars(
        [
            ("GIT_AUTHOR_NAME", OsString::from("Ada Lovelace")),
            ("GIT_AUTHOR_EMAIL", OsString::from("ada@example.com")),
            ("GIT_COMMITTER_NAME", OsString::from("Committer Example")),
            (
                "GIT_COMMITTER_EMAIL",
                OsString::from("committer@example.com"),
            ),
        ]
        .into_iter()
        .map(|(k, v)| (OsString::from(k), v)),
        root.clone(),
    );

    let (repo, _) = Repository::init(
        &root,
        &InitOptions::new()
            .with_initial_branch("main")
            .with_repository_options(RepositoryOptions::with_environment(env)),
    )?;

    let author = repo.identity(IdentRole::Author, repo.identity_now())?;
    let mut request = CommitRequest::new("first\n");
    request.author = Some(author);
    // committer left None — create_commit uses the repository committer identity

    if let Some(author) = &request.author {
        println!("author={}", author.name);
    }

    Ok(())
}
```

## Errors

Library operations return `grit_lib::error::Result`. The top-level [`Error`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html) enum groups failures by area; repository layout, discovery, init, and embedding checks are [`Error::Repository`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Repository) wrapping [`RepositoryError`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html). Match on the inner variant in application code; the `grit` CLI maps them to exit codes and messages separately.

[`RepositoryError::NotARepository`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html#variant.NotARepository) carries a [`NotARepositoryReason`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.NotARepositoryReason.html): `NoRepositoryAt` when there is simply no repository at or above the path, or a gitfile problem (`GitfileNotRegularFile`, `GitfileMissingGitdir`, `GitfileUnreadable`) naming the `.git` entry. Discovery stops at a malformed gitfile instead of searching parent directories, as Git does, so treat the gitfile reasons as errors to report rather than "not in a repository". Other common [`RepositoryError`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html) variants include `DubiousOwnership` (`safe.directory`), `UnsupportedRepositoryFormatVersion`, `RequiresWorkTree`, `GitDirPathIo` (typed [`PathIoError`](https://docs.rs/grit-lib/latest/grit_lib/error/struct.PathIoError.html)), `ObjectFormatMismatch`, and init refusals such as `InitObjectFormatChange`.

## Example

The program below discovers a repository (or opens `.git` in the current directory), prints paths, and reads `user.name` from config:

```rust
//! Open and discover repositories; load config from the git directory.
//!
//! Source for the library guide "Repository" page (included in the docs site).

use grit_lib::config::environment::{Environment, RepositoryOptions};
use grit_lib::error::Error;
use grit_lib::repo::{Repository, RepositoryError};

fn main() -> Result<(), Error> {
    let cwd = std::env::current_dir().map_err(Error::Io)?;
    let env = Environment::from_vars(std::env::vars_os(), cwd.clone());
    let options = RepositoryOptions::with_environment(env.clone());

    let repo = match Repository::discover(None, &options) {
        Ok(r) => r,
        Err(Error::Repository(RepositoryError::NotARepository(_))) => {
            let git_dir = cwd.join(".git");
            Repository::open(&git_dir, &options.clone().with_work_tree(&cwd))?
        }
        Err(err) => return Err(err),
    };

    println!("git_dir={}", repo.git_dir().display());
    if let Some(wt) = &repo.work_tree() {
        println!("work_tree={}", wt.display());
    } else {
        println!("work_tree=<bare>");
    }

    let name = repo.config().get("user.name")?.unwrap_or_default();
    if !name.is_empty() {
        println!("user.name={name}");
    }

    Ok(())
}
```

Run from any Git checkout:

```bash
cargo run --bin guide_repository
```

# https://grit-scm.com/docs/library/revwalk/index.md

# Revwalk

> Resolve revisions, walk history with rev-list, ranges (A..B), ordering, and merge bases.

History walks start from one or more **tips** (resolved ref names or expressions), follow parent links, optionally subtract another set of tips, then sort the result. Everything that needs a repository is a method on [`RevWalk`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html), the handle [`Repository::revwalk`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.revwalk) returns: resolving revisions, listing and counting commits, merge bases and reachability, log decorations and author grouping. The `revwalk::rev_parse` and `revwalk::rev_list` modules keep only the option and result types and pure helpers that parse strings.

## Rev-parse

[`RevWalk::resolve`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.resolve) turns a single spec (`HEAD`, `main`, `v1.0`, `abc1234`, `main^`, `HEAD~3`, `HEAD:path`, `@{-1}`, `:/message`, peel suffixes and more) into an [`ObjectId`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectId.html). [`ResolveOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.ResolveOptions.html) says how:

| Field | Values | Effect |
| --- | --- | --- |
| [`peel`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.Peel.html) | `Any` (default), `Commit`, `Tree`, `Blob` | The kind the result is peeled to. The kind also breaks ties when abbreviated hex matches several objects. `Commit` reads `A..B` as `B` and `A...B` as the merge base, like the commit-ish arguments of `log` or `reset`. |
| [`index_dwim`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.IndexDwim.html) | `On` (default), `Off` | Whether a name that matches no ref or object is reported as a possible path (`RevParseError::AmbiguousArgument`) or as a bad revision (`RevParseError::InvalidObjectName`). |
| [`purpose`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.ResolvePurpose.html) | `Revision` (default), `RangeEnd`, `CheckoutNoGuess` | `RangeEnd` makes ambiguous abbreviated hex prefer a commit, as range endpoints and `rev-parse --verify` do. `CheckoutNoGuess` stops a bare name from matching the one remote-tracking branch of that name (`checkout --no-guess`). |

```rust
use grit_lib::revwalk::{IndexDwim, Peel, ResolveOptions, ResolvePurpose};

# fn demo(repo: &grit_lib::repo::Repository) -> grit_lib::error::Result<()> {
let revwalk = repo.revwalk();
// git rev-parse --verify <spec>
let verify = ResolveOptions::default()
    .with_index_dwim(IndexDwim::Off)
    .with_purpose(ResolvePurpose::RangeEnd);
let head = revwalk.resolve("HEAD", &verify)?;
// The commit and the root tree of a tag
let commit = revwalk.resolve("v1.0", &ResolveOptions::default().with_peel(Peel::Commit))?;
let tree = revwalk.resolve("v1.0", &ResolveOptions::default().with_peel(Peel::Tree))?;
# let _ = (head, commit, tree);
# Ok(())
# }
```

The same handle peels ids you already hold ([`peel_to_commit`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.peel_to_commit), [`peel_to_tree`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.peel_to_tree)), names refs ([`symbolic_full_name`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.symbolic_full_name), [`upstream_symbolic_name`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.upstream_symbolic_name) for `@{upstream}` and `@{push}`), and shortens ids ([`abbreviate`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.abbreviate) with an [`AbbrevLength`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.AbbrevLength.html): `core.abbrev` or a minimum length; [`abbrev_matches`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.abbrev_matches) lists every object a prefix names).

Common helpers that do not need a repository:

- [`split_double_dot_range`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_parse/fn.split_double_dot_range.html) — split `main..feature` into two tokens (ignores `...` and path segments).
- [`abbreviate_ref_name`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_parse/fn.abbreviate_ref_name.html) — shorten `refs/heads/main` to `main` for display.

## Listing commits on a repository handle

`RevWalk` has two ways to list commits:

- [`RevWalk::commits`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.commits), [`rev_list_result`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.rev_list_result) and [`count`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.count) take revision **tokens** (`&["main", "^v1.0"]`, `&["main...topic"]`) plus [`RevWalkListOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkListOptions.html). This is the API most callers want. Ref selections (`--all`, `--branches`) go in `RevWalkListOptions::refs` and path limits in [`RevWalkListOptions::pathspec`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkListOptions.html#structfield.pathspec) (default [`Pathspec::entire_tree`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html#method.entire_tree)), not in the tokens. Build that value with [`Repository::pathspec`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.pathspec) or [`Pathspec::scoped`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html#method.scoped).
- For plain default-order walks (no path limits, filters, or symmetric diff markers), [`RevWalk::commits_stream`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.commits_stream) yields commits lazily with the same tokens and options, optionally retaining raw commit bytes the walk already read (`RevWalkListOptions::retain_commit_data`). Set `RevWalkListOptions::retained_commit_extent` to [`CommitExtent::ThroughSubject`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.CommitExtent.html) when the listing shows only one line per commit (author, dates, change id, subject): the walk then reads each commit only through its subject line instead of inflating its whole message, and the retained bytes are that prefix (see [`Odb::read_commit_through_subject`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.read_commit_through_subject)). `grit log` and `grit revs` do this for human and Markdown output; JSON rows carry the full message and keep [`CommitExtent::Whole`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.CommitExtent.html).
- [`RevWalk::walk`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.walk) takes **one** spec (`main`, `^tip`, `A..B` or `A...B`) plus the full engine [`RevListOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListOptions.html) described below. Options, `--`, and several space-separated tokens fail with `RevListError::UnsupportedWalkSpec`, so use `commits` for those.

Both list the symmetric difference for `A...B`, exactly like `git rev-list A...B`. [`RevWalk::parse_tokens`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.parse_tokens) does the expansion if you call [`RevWalk::rev_list`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.rev_list) yourself.

When expanding symmetric ranges on ordinary histories, endpoint navigation such as
`HEAD~500` shares the parent links and timestamps it parses with the following walk.
Standalone revision resolution does not retain this metadata. Navigation seeds at most 1,024
entries, so resolving a distant ancestor alone does not retain its entire history.
Shallow boundaries, grafts, promisor repositories and replacement objects keep their
existing traversal rules.

## Rev-list

[`RevWalk::rev_list`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.rev_list) takes positive and negative revision specs plus [`RevListOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListOptions.html). It returns a [`RevListResult`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListResult.html) whose `commits` field is the final oid list (after skip, max-count, and reverse).

For counts, read [`RevListResult::commit_count`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListResult.html#method.commit_count) or use `RevWalk::count`: count-only walks can leave `commits` empty. For an unlimited count with only author, committer or message filters, the walk visits each reachable commit once, matches its borrowed bytes and discards the payload. It retains visited ids rather than parsed commit maps or a sorted list, including when subtracting excluded ancestry; shallow boundaries and grafts still apply.

| Option | Meaning |
| --- | --- |
| [`ordering`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListOptions.html) | [`OrderingMode`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/enum.OrderingMode.html) — default date order, topo, author-date variants. |
| `first_parent` | Follow only the first parent at merges. |
| `max_count` / `skip` | Limit how many commits are returned. |
| `reverse` | Reverse the selected list after sorting. |
| `commit_filter` | Optional [`CommitFilter`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/filter/struct.CommitFilter.html) (`--author`, `--committer`, `--grep`, mailmap). |
| `pickaxe` | Optional [`Pickaxe`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Pickaxe.html) (`-S` / `-G` tree-diff filters). |
| `retain_commit_data` | Keep the commits the walk parses in [`RevListResult::commit_data`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListResult.html), so code that prints the listed commits does not read them again. |

With [`RevListOptions::default`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListOptions.html) and [`OrderingMode::Default`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/enum.OrderingMode.html#variant.Default), every listing path — bounded or unbounded [`max_count`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListOptions.html#structfield.max_count), [`RevWalk::commits`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.commits), [`RevWalk::walk`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.walk), and [`RevWalk::commits_iter`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.commits_iter) — uses the same ungated committer-date priority queue as `git rev-list` (newest committer date first, equal dates broken by tip insertion order). When a limit is set and there are no negative specs, the walk stops as soon as it has enough commits. [`OrderingMode::DateOrderWalk`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/enum.OrderingMode.html#variant.DateOrderWalk) is Git's `--date-order` variant: the same heap with a parent-after-children gate so skewed clocks do not print ancestors before descendants. The default enables the on-disk commit-graph for parent/date lookup when `core.commitGraph` allows it, matching `git rev-list` speed on large histories; set `use_commit_graph: false` to parse every commit object. A repository with a custom primary object store never reads graph files from `objects/`; its walks use the graph attached with [`OdbBuilder::commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.OdbBuilder.html#method.commit_graph) instead, built with [`Maintenance::build_commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.build_commit_graph) (see [Object stores](https://grit-scm.com/docs/library/revwalk/object-stores.md/index.md#commit-graphs-for-a-custom-store)).

To print the listed commits, collect the ref labels once with [`RevWalk::decorations`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.decorations) ([`DecorationOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/log/struct.DecorationOptions.html) picks full or short names, the `--decorate-refs` filter, and optionally only the commits you show), set `retain_commit_data`, and hand `commit_data` to [`RevWalk::load_commits`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.load_commits). It moves out the commits the walk parsed and reads only the rest, such as commits whose parents came from a commit-graph; pass `&mut ()` when you hold none.

Path-limited walks compare the requested entries directly in tree data and reuse packed delta bases. At a merge, ordinary path history follows the first parent whose tree matches the requested paths. Setting `sparse: true` keeps every commit reached along those selected parent links, including merges whose paths match a parent. These rules work with SHA-1 and SHA-256 repositories, with or without commit-graph Bloom filters.

For a range `main..feature`, pass `feature` as a positive spec and `main` as a negative spec (or split with [`split_double_dot_range`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_parse/fn.split_double_dot_range.html) as the example does). A symmetric range `main...feature` needs every merge base, so expand it with `RevWalk::parse_tokens` and copy its `symmetric_left` / `symmetric_right` into the options; `rev_list` rejects a raw `A...B` spec with `RevListError::UnexpandedSymmetricRange`. That matches `git rev-list main..feature`, order included. In default order, with or without `max_count`, a range walk paints both sides down to their common frontier and lists only commits reachable from the positive tips but not from the excluded tips — the same set as `git rev-list`, not the whole history behind `main`. Committer dates order the paint heap but do not define membership; when generations are unavailable the paint may need an extra pass so hide-side commits with skewed dates still mark shared ancestors hidden. An expanded `main...feature` uses that same walk and stops at its merge bases, except with `OrderingMode::Topo` (`--graph`), which sorts the whole symmetric range. `OrderingMode::DateOrderWalk` (`--date-order`) and output filters such as paths or `--left-right` still sort the whole range first.

### Commit filters

[`CommitFilter`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/filter/struct.CommitFilter.html) mirrors `git rev-list` / `git log` identity and message filtering. Build one with [`CommitFilterBuilder`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/filter/struct.CommitFilterBuilder.html): author and committer patterns OR together; `--grep` patterns OR together unless `all_match` is set; `invert_grep` negates only the grep group; `-i` applies to all. Patterns default to Git’s POSIX BRE rules (use `fixed_strings` for literal `-F` mode). Load a [`MailmapTable`](https://docs.rs/grit-lib/latest/grit_lib/config/mailmap/struct.MailmapTable.html) with [`repo.config().mailmap()`](https://docs.rs/grit-lib/latest/grit_lib/config/struct.Config.html#method.mailmap) and pass it to the builder — the filter never reads config on its own. Set [`RevListOptions::commit_filter`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListOptions.html) or [`RevWalkListOptions::commit_filter`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkListOptions.html); filtered commits stay traversable (like `--no-merges`), and `-n` / `--count` apply after filtering.

Bounded default-order filters inflate each visited commit once and reuse those bytes for traversal and matching; only the walk's queued frontier is held at a time. Set `retain_commit_data` when loading log rows: selected matches are returned in `RevListResult::commit_data`, including with a commit-graph, and can be passed to [`RevWalk::load_commits`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.load_commits). Skipped and nonmatching payloads are discarded, so selective filters do not retain every scanned message.

## Pickaxe (`-S` / `-G`)

[`Pickaxe`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Pickaxe.html) filters commits by tree diffs against the first parent (Git `log -S` / `-G`). Build with [`Pickaxe::occurrences`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Pickaxe.html#method.occurrences) or [`Pickaxe::line_grep`](https://docs.rs/grit-lib/latest/grit_lib/diff/struct.Pickaxe.html#method.line_grep), then set [`RevListOptions::pickaxe`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/rev_list/struct.RevListOptions.html) or [`RevWalkListOptions::pickaxe`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkListOptions.html). Evaluation runs after cheap [`CommitFilter`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/filter/struct.CommitFilter.html) checks; [`RevWalkListOptions::pathspec`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.RevWalkListOptions.html#structfield.pathspec) limits which files are diffed.

```rust
//! List commits matching an author pattern via [`CommitFilter`](https://grit-scm.com/docs/library/revwalk/grit_lib::revwalk::CommitFilter/index.md) and [`RevWalk::rev_list`](https://grit-scm.com/docs/library/revwalk/grit_lib::revwalk::RevWalk::rev_list/index.md).
//!
//! Source for the library guide "Revwalk" page (included in the docs site).

use grit_lib::progress::{CancelToken, NullProgress};

use anyhow::Result;
use std::path::Path;
use std::sync::Arc;

use grit_lib::config::environment::RepositoryOptions;
use grit_lib::repo::Repository;
use grit_lib::revwalk::rev_list::RevListOptions;
use grit_lib::revwalk::CommitFilterBuilder;

fn main() -> Result<()> {
    let mut args = std::env::args().skip(1);
    let repo_root = args.next().map(std::path::PathBuf::from).ok_or_else(|| {
        anyhow::anyhow!("usage: log_by_author <repo> <author-pattern> [revision…]".to_owned(),)
    })?;
    let author = args
        .next()
        .ok_or_else(|| anyhow::anyhow!("missing author pattern"))?;
    let tips: Vec<String> = args.collect();
    let tips = if tips.is_empty() {
        vec!["HEAD".to_owned()]
    } else {
        tips
    };

    let repo = open_repo(&repo_root)?;
    let mut builder = CommitFilterBuilder::new().author(author);
    if let Ok(table) = repo.config().mailmap() {
        if !table.is_empty() {
            builder = builder.mailmap(table);
        }
    }
    let filter = Arc::new(builder.build()?);
    let opts = RevListOptions::default().with_commit_filter(Some(filter));
    let result =
        repo.revwalk()
            .rev_list(&tips, &[], &opts, &mut NullProgress, &CancelToken::never())?;
    for oid in &result.commits {
        println!("{oid}");
    }
    Ok(())
}

fn open_repo(root: &Path) -> Result<Repository> {
    Ok(Repository::discover(
        Some(root),
        &RepositoryOptions::from_process(),
    )?)
}
```

## Merge base

[`RevWalk::merge_bases`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.merge_bases) takes the commits and a [`MergeBaseMode`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/enum.MergeBaseMode.html): `Best` is `git merge-base A B...` (the best common ancestor of the first commit and a merge of the rest), `All` is `--all` and `Octopus` is `--octopus`. For diff-style “exactly one base or fail”, use [`merge_base_for_diff`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.merge_base_for_diff).

The other reachability questions are methods too:

| Method | Git equivalent |
| --- | --- |
| [`is_ancestor`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.is_ancestor) | `git merge-base --is-ancestor` |
| [`independent`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.independent) | `git merge-base --independent` |
| [`fork_point`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.fork_point) | `git merge-base --fork-point` (`None` when the upstream's reflog has no fork point) |
| [`ahead_behind`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.ahead_behind) | `git rev-list --left-right --count A...B`, with the newest commits of each side on request ([`AheadBehindOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.AheadBehindOptions.html)) |
| [`reachable_excluding`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.reachable_excluding) | `git rev-list tips ^hide`, bounded and date-cut by [`ReachableWalkOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.ReachableWalkOptions.html) |
| [`count_reachable_excluding`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.count_reachable_excluding) | `git rev-list --count tips ^hide` |

## Describe (nearest tag)

[`RevWalk::describe`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/handle/struct.RevWalk.html#method.describe) picks the reachable tag with the smallest exact range count from the tag’s peeled commit to the target revision ([`DescribeOptions`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.DescribeOptions.html), [`DescribedCommit`](https://docs.rs/grit-lib/latest/grit_lib/revwalk/struct.DescribedCommit.html)). The distance matches `grit revs --count tag..rev`, not necessarily Git’s lazy `git describe` depth. When commit-graph generations are available, one backward walk from the target discovers reachable tags (Git’s internal `describe` model): each commit is visited at most once, within flags propagate to parents, and the walk can stop early when the best candidate’s cone covers the queue. Walk depth picks the winner; the library runs one exact `peeled..rev` count for that tag only (not per candidate). Without a commit-graph, the same exact distances come from a single fixpoint pass over the reachable subgraph (within bits from tag peels, then one sweep)—not a separate rev-list count per tag. With `first_parent`, only the first parent is followed in either path.

## Example

The program below opens a repository (created by system Git in tests), walks `main..feature`, prints each commit oid, then prints the merge base of the range tips:

```rust
//! Walk commit history with [`RevWalk::rev_list`](https://grit-scm.com/docs/library/revwalk/grit_lib::revwalk::RevWalk::rev_list/index.md) and compute a merge base.
//!
//! Source for the library guide "Revwalk" page (included in the docs site).

use grit_lib::progress::{CancelToken, NullProgress};

use anyhow::Result;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::repo::Repository;
use grit_lib::revwalk::{MergeBaseMode, ResolveOptions};

use grit_lib::revwalk::rev_list::RevListOptions;
use grit_lib::revwalk::rev_parse::split_double_dot_range;
use std::path::Path;

fn main() -> Result<()> {
    let mut args = std::env::args().skip(1);
    let repo_root = args
        .next()
        .map(std::path::PathBuf::from)
        .ok_or_else(|| anyhow::anyhow!("usage: guide_revwalk <repo> [main..feature]"))?;
    let range = args.next().unwrap_or_else(|| "main..feature".to_owned());

    let repo = open_repo(&repo_root)?;
    let options = RevListOptions::default();
    let result = if let Some((left, right)) = split_double_dot_range(&range) {
        let mut positive = Vec::new();
        let mut negative = Vec::new();
        if !right.is_empty() {
            positive.push(right.to_owned());
        }
        if !left.is_empty() {
            negative.push(left.to_owned());
        }
        repo.revwalk().rev_list(
            &positive,
            &negative,
            &options,
            &mut NullProgress,
            &CancelToken::never(),
        )?
    } else {
        repo.revwalk().rev_list(
            std::slice::from_ref(&range),
            &[],
            &options,
            &mut NullProgress,
            &CancelToken::never(),
        )?
    };

    for oid in &result.commits {
        println!("{oid}");
    }

    let (left_name, right_name) = range_names(&range)?;
    let left = repo
        .revwalk()
        .resolve(left_name, &ResolveOptions::default())?;
    let right = repo
        .revwalk()
        .resolve(right_name, &ResolveOptions::default())?;
    let bases = repo
        .revwalk()
        .merge_bases(&[left, right], MergeBaseMode::Best)?;
    let Some(base) = bases.first() else {
        return Err(anyhow::anyhow!("no merge base for range tips".to_owned(),));
    };
    println!("merge_base={base}");

    Ok(())
}

fn open_repo(root: &Path) -> Result<Repository> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::from_process();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Ok(Repository::open(&git_dir, &opts)?)
}

fn range_names(range: &str) -> Result<(&str, &str), anyhow::Error> {
    split_double_dot_range(range)
        .ok_or_else(|| anyhow::anyhow!("expected a double-dot range, got {range:?}"))
}
```

Run against a repo with diverged `main` and `feature` branches:

```bash
cargo run --bin guide_revwalk /path/to/repo main..feature
```

The integration test `guide_revwalk` checks commit order against `git rev-list` and the merge base against `git merge-base`.

# https://grit-scm.com/docs/library/staging/index.md

# Index

> Load the staging index, stage paths with porcelain add, and write a tree object from staged entries.

The Git index (staging area) lives in `Index`. Open a `Repository`, then use `IndexFile` via `Repository::index` (`load` / `write`). Index extensions (sparse checkout, split index, untracked cache) live under the [`index`](https://docs.rs/grit-lib/latest/grit_lib/index/index.html) domain; working-tree helpers are under [`worktree`](https://docs.rs/grit-lib/latest/grit_lib/worktree/index.html). See [API layout](https://grit-scm.com/docs/library/api-layout/index.md).

See also the [Repository](https://grit-scm.com/docs/library/repository/index.md) and [Objects](https://grit-scm.com/docs/library/objects/index.md) pages for opening repos and writing objects. Other library topics: [Refs](https://grit-scm.com/docs/library/refs/index.md), [Diff](https://grit-scm.com/docs/library/diff/index.md).

## Reading the index

[`IndexFile::load`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexFile.html#method.load) reads the index (`GIT_INDEX_FILE` or `.git/index`), resolves a split index, and by default expands every sparse-directory placeholder (full in-memory materialization). [`IndexLoadOptions`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexLoadOptions.html) selects another file (`with_path`), keeps placeholders for read-mostly work such as `status` and `diff` on cone sparse-index checkouts (`with_sparse(SparseIndexLoad::Preserve)`), or sets the entry-loading thread policy (`with_parse_context`). Entries are [`IndexEntry`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexEntry.html) values with path, mode, object id, and stage; build one in memory with [`IndexEntry::new`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexEntry.html#method.new) (stage 0, zeroed stat data) and [`with_stage`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexEntry.html#method.with_stage) for a conflict stage.

```rust
use grit_lib::index::{IndexLoadOptions, IndexWriteOptions, SparseIndexLoad};

let mut index = repo.index().load(&IndexLoadOptions::default())?;
// ... edit entries ...
repo.index().write(&mut index, &IndexWriteOptions::default())?;

let compact = repo
    .index()
    .load(&IndexLoadOptions::default().with_sparse(SparseIndexLoad::Preserve))?;
```

[`IndexFile::write`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexFile.html#method.write) collapses skip-worktree subtrees back into sparse-directory entries when `index.sparse` is on, writes a split index when [`IndexWriteOptions::split`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexWriteOptions.html) or `core.splitIndex` asks for one, and runs the `post-index-change` hook. To parse index bytes you already have, use [`Index::parse`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.Index.html#method.parse) with [`IndexParseOptions`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexParseOptions.html) (hash algorithm, config for EOIE/IEOT, source path for errors, thread policy); [`Index::empty_for`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.Index.html#method.empty_for) makes an empty index whose version follows `index.version` and `feature.manyFiles`.

## Staging paths

`porcelain::add::stage` compares the index to the work tree once, hashes changed blobs, and writes the index back. Pass `StageOptions` for pathspecs and `StageMode` (`All` vs `Update`). Long-running staging reports through a `ProgressSink`; examples use `NullProgress` when no UI is needed.

The `grit add` command is a thin wrapper around this API.

`StageOptions::pathspecs` are work-tree-relative. Prefer [`Repository::pathspec`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.pathspec) with [`PathspecOptions`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.PathspecOptions.html) to resolve argv and `--pathspec-from-file` input in one step ([`Pathspec::specs`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html#method.specs) for matching, [`Pathspec::iter`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html#method.iter) for display). The resolved [`Pathspec`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html) carries both display sources and normalized specs ([`Pathspec::iter`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html#method.iter)). Resolution applies the current-directory prefix and, on filesystems that alias NFD/NFC spellings (macOS with `core.precomposeunicode`), NFC-normalizes paths. That decision is cached on the `Repository`, so passing hundreds of literal paths costs no config reload per path, and literal pathspecs are matched against the index with hash lookups on every platform.

[`StatusOptions::pathspec`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/status/struct.StatusOptions.html#structfield.pathspec) uses the same [`Pathspec`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html) type; `grit status` resolves CLI path arguments through [`Repository::pathspec`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.pathspec).

## Worktree file modes

Some checkouts cannot show every mode Git records. With `core.filemode=false` the executable bit on disk means nothing, and with `core.symlinks=false` (the Windows default when symlinks need admin rights) a symlink is checked out as a plain file holding the link target. [`WorktreeModePolicy`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.WorktreeModePolicy.html) reads both settings with `from_config` and maps an `lstat` mode onto the mode already in the index: `index_mode_for_worktree` keeps a recorded `120000` for a plain file when symlinks are disabled, and keeps a recorded `100644`/`100755` when the filemode is not trusted. Staging, `commit`, `status` and worktree diffs all go through it, so an untouched link stays a link and an edited one is staged as a new link target, the same as Git.

## Sparse checkout

[`SparseCheckout::load`](https://docs.rs/grit-lib/latest/grit_lib/index/sparse_checkout/struct.SparseCheckout.html#method.load) compiles the repository's sparse-checkout definition (`core.sparseCheckout`, `core.sparseCheckoutCone` and `info/sparse-checkout`, cone or non-cone) once, and returns `None` when sparse checkout is off. [`SparseCheckout::includes`](https://docs.rs/grit-lib/latest/grit_lib/index/sparse_checkout/struct.SparseCheckout.html#method.includes) answers whether a path belongs in the work tree.

[`IndexFile::apply_sparse_checkout`](https://docs.rs/grit-lib/latest/grit_lib/index/struct.IndexFile.html#method.apply_sparse_checkout) marks the excluded stage-0 entries of an index built from a tree as skip-worktree, as Git does after `read-tree` or a branch checkout.

Every operation that updates the work tree from a tree consults it: `reset --hard` and `--mixed`, `switch`, `merge`, `pull` (merge and rebase), stash and the history engine. A path outside the definition that is skip-worktree (or new to the index) gets an index row with the `skip-worktree` bit and nothing is written to disk, the same as `git`. Conflicted paths are written out with conflict markers, also like `git`. When `index.sparse` is on, the index is collapsed back into sparse-directory entries when it is written. [`SparseCheckout::carry_skip_worktree`](https://docs.rs/grit-lib/latest/grit_lib/index/sparse_checkout/struct.SparseCheckout.html#method.carry_skip_worktree) keeps the bits on an index rebuilt from a tree without touching the work tree.

## Writing a tree from the index

[`write_tree_from_index`](https://docs.rs/grit-lib/latest/grit_lib/index/write_tree/fn.write_tree_from_index.html) builds a tree object from stage-0 entries (respecting the optional path prefix). It returns the root [`ObjectId`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectId.html). When the index cache-tree extension is valid, grit reuses cached subtree oids for speed; otherwise it walks entries and writes new tree objects through [`Odb`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html).

## Errors

Index load, write, extension parsing, and write-tree failures return [`IndexError`](https://docs.rs/grit-lib/latest/grit_lib/index/error/enum.IndexError.html) (wrapped as [`Error::Index`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Index) at the repository boundary). Match on the enum, not message text:

| Variant | When |
| --- | --- |
| `Corrupt` | Bad header, unsupported version, truncated bytes, checksum mismatch, or malformed entries/extensions (`IndexCorruptReason` pinpoints the site). |
| `Unmerged` | Conflict stages remain; commit or write-tree needs a clean stage-0 index. |
| `PathPrefixConflict` | Two paths disagree on whether a prefix is a file or directory. |
| `FsmonitorExtension*` | The `FSMN` extension is truncated, has an unknown version, or carries an invalid EWAH bitmap. |
| `CacheTreeCorrupt` | Cache-tree metadata does not match index entries. |
| `LockHeld` | Another process holds `index.lock` (also surfaced as top-level [`Error::LockHeld`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.LockHeld)). |
| `PathIo` | Filesystem I/O on the index path. |
| `SplitIndex` | Split-index link/read/write failed. |
| `Chmod` | Mode change rejected (unmerged path, non-regular file, invalid mode). |
| `WriteTree` | Structured write-tree / cache-tree rebuild failure. |

Stable JSON `kind` slugs (`index_error`, `index_unmerged`, `cache_tree_corrupt`, …) come from [`IndexError::kind_name`](https://docs.rs/grit-lib/latest/grit_lib/index/error/enum.IndexError.html#method.kind_name). See the [errors](https://grit-scm.com/docs/library/errors/index.md) overview for the cross-area map.

## Example

This program loads the index, stages new or changed paths, and prints the tree oid grit would commit:

```rust
//! Read the index, stage paths, and write a tree from staged entries.
//!
//! Source for the library guide "Index" page (included in the docs site).

use grit_lib::config::environment::RepositoryOptions;
use grit_lib::index::write_tree::write_tree_from_index;
use grit_lib::porcelain::add::StageOptions;
use grit_lib::progress::NullProgress;
use grit_lib::repo::{InitOptions, Repository};
use std::fs;
use std::path::{Path, PathBuf};

fn open_repo(root: &Path) -> Result<Repository, grit_lib::error::Error> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::empty();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Repository::open(&git_dir, &opts)
}

fn main() -> Result<(), grit_lib::error::Error> {
    let mut temp_guard = None;
    let repo = if let Some(root) = std::env::args().nth(1).map(PathBuf::from) {
        open_repo(&root)?
    } else {
        let temp = tempfile::tempdir().map_err(grit_lib::error::Error::Io)?;
        Repository::init(
            temp.path(),
            &InitOptions::new()
                .with_initial_branch("main")
                .with_ref_storage(grit_lib::refs::ref_storage::RefStorageFormat::Files),
        )?;
        let path = temp.path().join("hello.txt");
        fs::write(&path, b"staged from the library guide\n").map_err(grit_lib::error::Error::Io)?;
        let opened = open_repo(temp.path())?;
        temp_guard = Some(temp);
        opened
    };
    let _keep = temp_guard;

    let index = repo
        .index()
        .load(&grit_lib::index::IndexLoadOptions::default())?;
    println!("index_entries={}", index.entries().len());

    let outcome = repo.index().stage(
        &StageOptions::default(),
        &mut NullProgress,
        &grit_lib::progress::CancelToken::never(),
    )?;
    println!(
        "staged added={} modified={} removed={}",
        outcome.added.len(),
        outcome.modified.len(),
        outcome.removed.len()
    );

    let index = repo
        .index()
        .load(&grit_lib::index::IndexLoadOptions::default())?;
    let tree_oid = write_tree_from_index(repo.odb(), &index, "")?;
    println!("tree_oid={}", tree_oid.to_hex());

    Ok(())
}
```

With a repository path, compare the printed tree to Git:

```bash
cargo run --bin guide_index /path/to/repo
git -C /path/to/repo write-tree
git -C /path/to/repo fsck --strict
```

Without arguments the binary uses a temporary repository (useful for `cargo run`, not for fsck demos).

# https://grit-scm.com/docs/library/stash/index.md

# Stash

> Stash stack read/write through RepositoryStash, with option and result types in stash.

The stash stack is Git-compatible ref and commit machinery. There is one API for it: `Repository::stash` returns a [`RepositoryStash`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryStash.html) handle with `list`, `push`, `preview`, `create`, `apply`, `apply_commit`, `pop`, `drop`, `clear`, `diff` and `branch`. The option and result types live in [`stash`](https://docs.rs/grit-lib/latest/grit_lib/stash/index.html). Entries are addressed by their newest-first index (`0` is `stash@{0}`), and the handle works on the repository's own work tree, so there is no separate work-tree argument. [`parse_stash_reference`](https://docs.rs/grit-lib/latest/grit_lib/stash/fn.parse_stash_reference.html) and [`StashReference`](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.StashReference.html) parse the same selectors as the CLI (`stash@{{n}}`, an all-decimal index, or any other revision as a commit id). `apply_reference`, `pop_reference`, and `branch_reference` take a parsed reference; `drop` returns the removed W commit id.

## Push and list

[`StashPushOptions`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashPushOptions.html) carries the message, whether to include untracked files, [`StashMode`](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.StashMode.html) (`All`, `StagedOnly`, `KeepIndex`), optional hunk selection and pathspecs, and the [`Signature`](https://docs.rs/grit-lib/latest/grit_lib/ident/struct.Signature.html) used for the stash commits and the `refs/stash` reflog (usually `repo.identity(IdentRole::Committer, now)`, see [Repository](https://grit-scm.com/docs/library/repository/index.md#identity)). [`StashPushOptions::new`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashPushOptions.html#method.new) sets the other fields to their defaults. `RepositoryStash::push` returns a [`StashPushResult`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashPushResult.html) (the stash commit, its message and tree), or `Ok(None)` when there is nothing to stash. `RepositoryStash::preview` takes the same options and lists the paths that would be saved without writing objects or refs. For a partial push (a hunk selection), both the result and the [`StashPreview`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashPreview.html) report what the selection resolved to: `stashed_hunks` maps each path to the hunk ids it stashes and `stashed_lines` to its line range labels, so callers do not need to resolve the selection again. [`StashPushOptions::validate`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashPushOptions.html#method.validate) rejects incompatible flag combinations as [`StashPushValidationError`](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.StashPushValidationError.html). Stash commits are always written unsigned, whatever `commit.gpgsign` says, matching Git.

`push`, `apply`, `apply_commit` and `pop` take a [`ProgressSink`](https://docs.rs/grit-lib/latest/grit_lib/progress/trait.ProgressSink.html) and a [`CancelToken`](https://docs.rs/grit-lib/latest/grit_lib/progress/struct.CancelToken.html). Push reports [`StagingFiles`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html#variant.StagingFiles) while it hashes local changes and [`CheckingOutFiles`](https://docs.rs/grit-lib/latest/grit_lib/progress/enum.ProgressPhase.html#variant.CheckingOutFiles) while it resets them. A cancel before `refs/stash` moves returns [`Error::Cancelled`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Cancelled) with the repository unchanged; once the entry is stored it stays, even if the reset that follows is cancelled. A cancelled apply or pop keeps the entry, leaves the index alone and rolls its checkout back; only files it content-merged onto a moved `HEAD` before the cancel stay written.

## Apply and pop

`RepositoryStash::apply` applies `stash@{n}` and keeps the entry. `RepositoryStash::pop` applies it and drops it only when it applied cleanly. Both take one [`StashApplyOptions`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashApplyOptions.html) (`restore_index` restores the stashed index, like `git stash apply --index`; `overwrite_identical_untracked` skips untracked collisions when on-disk bytes already match the stashed copy) and return a [`StashApplyOutcome`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashApplyOutcome.html) whose `conflicts` lists each path left with conflict stages in the index as an [`operation::Conflict`](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.Conflict.html), the same paths `git ls-files -u` shows afterwards, with the same [`ConflictKind`](https://docs.rs/grit-lib/latest/grit_lib/operation/enum.ConflictKind.html) `status` reports for them. `has_conflicts()` is true exactly when a pop kept the entry. `RepositoryStash::apply_commit` applies any stash-shaped commit, such as one built by `RepositoryStash::create`, without touching `refs/stash`. Stash operations return [`StashError`](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.StashError.html): an index past the end of the stack is [`NotFound`](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.StashError.html#variant.NotFound), a malformed stash commit is [`CorruptStash`](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.StashError.html#variant.CorruptStash), apply/pop refuse to overwrite local tracked edits with [`WouldOverwriteLocalChanges`](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.StashError.html#variant.WouldOverwriteLocalChanges), and untracked collisions use [`CouldNotRestoreUntracked`](https://docs.rs/grit-lib/latest/grit_lib/stash/enum.StashError.html#variant.CouldNotRestoreUntracked). These arrive as [`Error::Stash`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Stash); repository, index or object failures underneath arrive as their own area variants.

Dropping an entry rewrites the `refs/stash` reflog without adding a new entry, so `drop`, `pop` and `branch` take no identity. `drop` returns that entry's W commit id so embedders can log it or recover with `apply_commit`.

```rust
use grit_lib::stash::StashApplyOptions;
use grit_lib::progress::{CancelToken, NullProgress};

let popped = repo
    .stash()
    .pop(0, &StashApplyOptions::default(), &mut NullProgress, &CancelToken::never())?;
for conflict in &popped.conflicts {
    println!(
        "conflict: {} ({}; stash@{{0}} was kept)",
        conflict.path,
        conflict.kind.as_str()
    );
}
```

## Example

```rust
//! Push a stash entry and list the stack through [`RepositoryStash`](https://grit-scm.com/docs/library/stash/grit_lib::repo_handles::RepositoryStash/index.md).
//!
//! Source for the library guide "Stash" page (included in the docs site).

use anyhow::Result;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::repo::Repository;
use grit_lib::stash::StashPushOptions;
use std::path::{Path, PathBuf};

const IDENT: &str = "Library Guide <guide@grit-scm.com> 1735689600 +0000";

fn open_repo(root: &Path) -> Result<Repository> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::from_process();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Ok(Repository::open(&git_dir, &opts)?)
}

fn main() -> Result<()> {
    let root = std::env::args()
        .nth(1)
        .map(PathBuf::from)
        .or_else(|| std::env::current_dir().ok())
        .ok_or_else(|| anyhow::anyhow!("missing repository path"))?;
    let repo = open_repo(&root)?;

    let pushed = repo.stash().push(
        &StashPushOptions::new(IDENT.parse()?).with_message(Some("library guide stash".into())),
        &mut grit_lib::progress::NullProgress,
        &grit_lib::progress::CancelToken::never(),
    )?;
    println!("stash_pushed={}", pushed.is_some());

    let entries = repo.stash().list()?;
    println!("stash_count={}", entries.len());
    for entry in entries {
        println!("stash {}", entry.message);
    }

    Ok(())
}
```

After a dirty file and `cargo run --bin guide_stash`, `git stash list` must show the entry. The test also runs `git fsck --strict`.

# https://grit-scm.com/docs/library/storage-backends/index.md

# Writing storage backends

> Implement object and ref stores, open a repository on them, test with conformance suites, and know what still needs a .git directory on disk.

Embedders replace grit’s default files layout with their own **object store**, **ref store**, or both. This page is the end-to-end guide: traits to implement, how to wire [`RepositoryOptions`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html), optional capabilities, performance hooks, and how to prove correctness with the shared conformance suites. For lookup order, alternates, pack ingest, and benchmark tables on custom primaries, see [Object stores](https://grit-scm.com/docs/library/storage-backends/object-stores.md/index.md).

## What to implement

### Object storage (read path)

[`ObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.ObjectStore.html) is the minimum surface:

| Method | Contract |
| ------ | -------- |
| `read` / `read_info` / `open_stream` | Return `Ok(None)` when the id is absent; propagate I/O or corruption errors (do not map outages to “missing”). |
| `contains` | Must match what `read` would return for the same id. |
| `hash_algo` | Must match `extensions.objectformat` / repository init. |
| `for_each_object` | List every stored id; release internal locks before calling the callback (callbacks often call back into the store). |
| `lookup_prefix` / `contains_many` | Override when a full scan per call is too expensive (see [Performance](#performance-checklist)). |

Optional streaming helpers: [`ObjectStore::read_into`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.ObjectStore.html#method.read_into) (default copies from `read`), [`ObjectStore::with_stream`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.with_stream) on the repository `Odb` handle for large blobs.

### Object storage (write path)

[`WritableObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.WritableObjectStore.html): idempotent `write`, plus `flush` / `rollback` when you batch transactions. Pack fetch, push, bundle install, and commits all end in `flush` on the primary.

### Pruning (optional)

[`PrunableObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.PrunableObjectStore.html): implement `remove`, `as_prunable`, and optionally `object_mtime` for grace-period prune. Without it, `gc`, `prune`, and `Odb::gc` return [`RepositoryError::UnsupportedObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html#variant.UnsupportedObjectStore) with operation `prune` — never touch `objects/` on disk silently.

### Ref storage

[`RefStore`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/trait.RefStore.html): `read_raw`, `resolve`, iteration (`for_each_ref` with the empty-prefix rule from [`RefStore`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/trait.RefStore.html)), reflog read/write, and **transactions** via `prepare` → `commit` / `abort`.

You do not reimplement Git’s ref rules: use [`refs::store::backend`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/backend/index.html) helpers (`check_transaction`, `apply_transaction`, `RefBatchState`, `SingleWriterGate` for in-process writers). Report backend failures as [`RefStoreError::Backend`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.RefStoreError.html#variant.Backend).

## Opening and initializing

### Inject stores when opening

[`RepositoryOptions::with_object_store`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_object_store) is the only supported way to set a custom primary object store. Add read layers, an attached commit-graph, or alternates with [`RepositoryOptions::with_odb_builder`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_odb_builder) ([`OdbBuilder`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.OdbBuilder.html)).

[`RepositoryOptions::with_ref_store`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_ref_store) replaces loose/packed/reftable refs under `refs/` and the on-disk `HEAD` file. Pair it with [`with_initial_branch`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_initial_branch) when `HEAD` should start on an unborn branch.

```rust
use std::sync::Arc;

use grit_lib::config::environment::RepositoryOptions;
use grit_lib::objects::odb::store::MemoryStore;
use grit_lib::objects::HashAlgo;
use grit_lib::refs::store::MemoryRefStore;
use grit_lib::repo::{InitOptions, Repository};

let dir = tempfile::tempdir()?;
let (repo, _) = Repository::init(
    dir.path(),
    &InitOptions::new()
        .with_initial_branch("main")
        .with_repository_options(
            RepositoryOptions::empty()
                .with_object_store(Arc::new(MemoryStore::new(HashAlgo::Sha1)))
                .with_ref_store(Arc::new(MemoryRefStore::new()))
                .with_work_tree(dir.path()),
        ),
)?;
# Ok::<(), grit_lib::error::Error>(())
```

### What `Repository::init` writes

[`Repository::init`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.init) with [`InitOptions::with_repository_options`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.InitOptions.html#method.with_repository_options) creates only what your stores do **not** own:

| Injected | On disk under the git directory |
| -------- | -------------------------------- |
| Object store only | Everything except `objects/` |
| Ref store only | Everything except `HEAD` and `refs/` |
| Both | `config` only (plus the work tree beside it when not bare) |

Object format comes from the store’s `hash_algo`; do not fight it with [`InitOptions::object_format`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.InitOptions.html#structfield.object_format) unless you mean to error with [`RepositoryError::ObjectFormatMismatch`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html#variant.ObjectFormatMismatch).

## Capability table

### `PrunableObjectStore`

| API | On a prunable custom primary |
| --- | --- |
| [`Maintenance::prune_loose_objects`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.prune_loose_objects) | Deletes unreachable objects past `gc.pruneExpire` |
| [`Maintenance::gc`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.gc) | Pack-refs + reflog expiry + prune (skips on-disk repack / commit-graph) |
| [`Odb::gc`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.gc) | Deletes all unreachable objects (no grace) |

### `FilesOnlyOperation` (typed refusal)

Operations that need the on-disk `objects/` layout return [`RepositoryError::UnsupportedObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.RepositoryError.html#variant.UnsupportedObjectStore) with a [`FilesOnlyOperation`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html) variant — match on the enum, not strings. Grit’s fallbacks on a custom primary:

| Operation | Fallback on custom primary |
| --------- | -------------------------- |
| Repack / `.pack` install | Pack stream ingested object-by-object ([`ingest_pack_into`](https://docs.rs/grit-lib/latest/grit_lib/objects/unpack_objects/fn.ingest_pack_into.html), [`ingest_received_pack`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.ingest_received_pack.html)) |
| Commit-graph file | Build in memory with [`Maintenance::build_commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.build_commit_graph); attach bytes via [`OdbBuilder::commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.OdbBuilder.html#method.commit_graph) |
| Promisor / partial clone ODB | Not supported (no silent filesystem promisor) |
| Prune / `gc` object deletion | Only with `PrunableObjectStore`; otherwise typed `prune` refusal |

The generated variant table lives on [Object stores](https://grit-scm.com/docs/library/storage-backends/object-stores.md/index.md#what-works-with-a-custom-primary) (`| Name | Variant | Description |
| --- | --- | --- |
| `gc` | [`Gc`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.Gc) | Garbage collection without a repository: [`Odb::gc`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.gc) on an `Odb` built standalone, with no git directory to find reachability roots in. |
| `prune` | [`Prune`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.Prune) | Deleting unreachable objects from a custom primary that cannot delete ([`WritableObjectStore::as_prunable`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/trait.WritableObjectStore.html#method.as_prunable) is `None`): [`Maintenance::prune_loose_objects`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.prune_loose_objects), [`refs::gc::prune_loose_unreachable`](https://docs.rs/grit-lib/latest/grit_lib/refs/gc/fn.prune_loose_unreachable.html), [`Odb::gc`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.gc), [`Maintenance::gc`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.gc). Implement [`PrunableObjectStore`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.PrunableObjectStore.html) to support them. |
| `repack` | [`Repack`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.Repack) | Repacking into `objects/pack/`: [`Maintenance::repack`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.repack) and [`Maintenance::repack_all`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.repack_all). |
| `commit_graph_write` | [`CommitGraphWrite`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.CommitGraphWrite) | Writing `objects/info/commit-graph`: [`Odb::write_commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.write_commit_graph) and [`Maintenance::write_commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.write_commit_graph). A custom store builds its graph in memory with [`Maintenance::build_commit_graph`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.build_commit_graph) instead. |
| `midx_write` | [`MidxWrite`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.MidxWrite) | Writing `objects/pack/multi-pack-index`: [`Maintenance::write_midx`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.write_midx). |
| `pack_store` | [`PackStore`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.PackStore) | The files backend’s pack and MIDX read cache: [`Odb::pack_store`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.pack_store). |
| `pack_install` | [`PackInstall`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.PackInstall) | Installing a pack file and its `.idx` under `objects/pack/`: [`index_pack::install_pack_bytes`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.install_pack_bytes.html) and [`index_pack::install_pack_path`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.install_pack_path.html). Use [`index_pack::ingest_received_pack`](https://docs.rs/grit-lib/latest/grit_lib/objects/index_pack/fn.ingest_received_pack.html) to write a pack into any primary. |
| `largest_pack_index` | [`LargestPackIndex`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.LargestPackIndex) | Finding the largest pack index in `objects/pack/`: [`Odb::largest_pack_index_path`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.largest_pack_index_path). |
| `loose_write` | [`LooseWrite`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.LooseWrite) | Writing loose object files into `objects/`: [`Odb::write_local`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.write_local), [`Odb::write_raw_local`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.write_raw_local) and [`Odb::write_loose_materialize`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.write_loose_materialize). [`Odb::write`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.write) works with any primary. |
| `files_source` | [`FilesSource`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.FilesSource) | The files-backed primary source itself: [`Odb::primary`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.primary). Use [`Odb::primary_writable`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/struct.Odb.html#method.primary_writable) for the primary of any kind. |
| `offload` | [`Offload`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.Offload) | Moving blobs to a large-object promisor: [`Maintenance::offload_blobs`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.offload_blobs), for the main repository and for the promisor repository. |
| `promisor_rewrite` | [`PromisorRewrite`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.PromisorRewrite) | Rewriting packs to leave out promised objects, as offload and dropping promised blobs do. |
| `partial_fetch` | [`PartialFetch`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.PartialFetch) | Fetching or cloning with an object filter (a partial clone) into a custom primary. |
| `receive_quarantine` | [`ReceiveQuarantine`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.ReceiveQuarantine) | The receive-pack quarantine directory under `objects/`. A custom primary receives pushes through an in-memory overlay instead. |
| `drop_large_blobs` | [`DropLargeBlobs`](https://docs.rs/grit-lib/latest/grit_lib/repo/error/enum.FilesOnlyOperation.html#variant.DropLargeBlobs) | Dropping promised blobs from promisor packs: [`Maintenance::drop_promised_blobs`](https://docs.rs/grit-lib/latest/grit_lib/maintenance/struct.Maintenance.html#method.drop_promised_blobs). |
`).

## Performance checklist

| Hook | Why |
| ---- | --- |
| [`read_into`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.ObjectStore.html#method.read_into) | Rev-list, merge-base, and change-id scans reuse one buffer per commit instead of allocating every `read`. |
| [`contains_many`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.ObjectStore.html#method.contains_many) | Write-tree and fetch/push negotiation ask about many ids at once; default is one `contains` per id. |
| [`lookup_prefix`](https://docs.rs/grit-lib/latest/grit_lib/objects/odb/store/trait.ObjectStore.html#method.lookup_prefix) | Short-id and `RevWalk::abbreviate`; default scans all objects. Use [`ObjectIdPrefix::lowest`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectIdPrefix.html#method.lowest) / [`highest`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.ObjectIdPrefix.html#method.highest) for sorted stores. |
| Attached commit-graph | Walks skip commit reads; see [Object stores — Commit-graphs for a custom store](https://grit-scm.com/docs/library/storage-backends/object-stores.md/index.md#commit-graphs-for-a-custom-store) and the benchmark table under `<!-- grit:benchmark-tables -->` on [Benchmarks](https://grit-scm.com/docs/library/benchmarks.md/index.md) for rev-list / merge-base rows. |

## Testing

Three workspace conformance crates exercise backends before you wire a full `Repository`:

| Suite | Crate module | What it checks |
| ----- | ------------ | -------------- |
| Object read/write | `grit_test_support::odb_conformance` | `run_read_suite`, `run_write_suite` on `ObjectStore` / `WritableObjectStore` |
| Ref store | `grit_test_support::refstore_conformance` | `run_suite` on `Arc<dyn RefStore>` |
| Repository | `grit_test_support::repository_conformance` | `BackendFixture` + `run_repository_suite`, `run_parity` for typed `RepositorySnapshot` parity |

Example pattern (object store):

```rust
use grit_test_support::odb_conformance::{run_read_suite, run_write_suite};

#[test]
fn my_store_passes_odb_conformance() {
    run_read_suite(|| seed_my_store(&FIXTURE_OBJECTS));
    run_write_suite(|| MyStore::new(HashAlgo::Sha1));
}
```

End-to-end SQLite + in-memory refs (parity against the files backend):

- Source: [`grit-examples/tests/sqlite_repository_conformance.rs`](https://github.com/gitbutlerapp/grit/blob/main/grit-examples/tests/sqlite_repository_conformance.rs)
- Library tests: [`grit-lib/tests/repository_conformance_memory.rs`](https://github.com/gitbutlerapp/grit/blob/main/grit-lib/tests/repository_conformance_memory.rs), [`repository_conformance_files.rs`](https://github.com/gitbutlerapp/grit/blob/main/grit-lib/tests/repository_conformance_files.rs)

After changing integration tests under `grit-examples/tests/`, run `python3 scripts/sync_integration_tests.py`.

## What still needs a `.git` directory on disk

When **both** stores are injected, [`Repository::open`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.open) does not require a populated git directory; config can come from [`Environment::push_config_override`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.Environment.html#method.push_config_override) only. Even then, several subsystems still read or write paths under the git directory (or require a work tree):

| Area | Without on-disk git layout |
| ---- | --------------------------- |
| Objects, refs, config (injected) | Fully served by your stores + environment |
| Log, rev-parse, merge trees, notes, bundles to `Write` | Work through stores |
| Fetch (local) | Works; pack spool uses temp files; `FETCH_HEAD` not written |
| Index, staging, `COMMIT_EDITMSG`, merge/rebase state | Need git-dir files |
| Work-tree commands (status, checkout, stash) | Need index + work tree |
| Linked worktrees, rerere, sparse-checkout | Need their admin/state files |
| Hooks expecting another `git` to read refs/objects | Not supported for purely injected stores |
| `gc` / repack / on-disk commit-graph | Typed `UnsupportedObjectStore` unless prunable / in-memory graph (see above) |

The same matrix appears in [Object stores — No git directory at all](https://grit-scm.com/docs/library/storage-backends/object-stores.md/index.md#no-git-directory-at-all). Injecting **only** the object store leaves refs and reflogs on disk as usual.

## Example: SQLite object database

`grit_examples::sqlite_odb::SqliteOdbStore` keeps zlib-compressed store bytes in SQLite (one row per object id). The runnable demo commits through a SQLite primary, walks history, and exports loose objects for system `git fsck`:

```rust
//! SQLite object store wired through [`RepositoryOptions::with_object_store`](https://grit-scm.com/docs/library/storage-backends/grit_lib::config::environment::RepositoryOptions::with_object_store/index.md).
//!
//! Writes a small commit graph in SQLite, walks history with [`rev_list`],
//! then exports objects as loose files for interoperability with system Git.

use std::env;
use std::path::PathBuf;

use grit_examples::sqlite_odb;

fn main() -> grit_lib::error::Result<()> {
    let (root, _tmpdir) = match env::args().nth(1) {
        Some(path) => (PathBuf::from(path), None),
        None => {
            let dir = tempfile::tempdir().map_err(grit_lib::error::Error::Io)?;
            let root = dir.path().to_path_buf();
            (root, Some(dir))
        }
    };
    let log = sqlite_odb::run_sqlite_object_store_demo(&root)?;
    for oid in log {
        println!("{oid}");
    }
    Ok(())
}
```

```bash
cargo run -p grit-examples --example sqlite-object-store
```

Run the conformance-backed integration tests with:

```bash
cargo test -p grit-examples --features full-tests sqlite_repository_conformance
```

## Related pages

- [Object stores](https://grit-scm.com/docs/library/storage-backends/object-stores.md/index.md) — `Odb` layering, alternates, pack ingest, benchmarks
- [Refs](https://grit-scm.com/docs/library/storage-backends/refs.md/index.md) — `References` handle, reflog, branch tracking
- [Embedding](https://grit-scm.com/docs/library/storage-backends/embedding.md/index.md) — `Environment`, diagnostics, subprocess injection

# https://grit-scm.com/docs/library/tree-sha256/index.md

# Tree SHA-256

> Content digest of a revision's tree for signed tags and verification.

The [tree-sha256](https://github.com/schacon/tree-sha256) digest hashes file and submodule **contents** with SHA-256 (not Git's SHA-1 object names). Grit exposes it on [`Repository::tree_sha256`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.tree_sha256).

## Compute a digest

```rust
use grit_lib::repo::{InitOptions, Repository};
use grit_lib::tree_sha256::TreeSha256Options;

# fn main() -> grit_lib::error::Result<()> {
let dir = tempfile::tempdir()?;
let (repo, _) = Repository::init(dir.path(), &InitOptions::default())?;
# let head = repo.odb().write_loose_materialize(
#     grit_lib::objects::ObjectKind::Commit,
#     b"tree 0000000000000000000000000000000000000000\n\n",
# )?;
let report = repo.tree_sha256(head, &TreeSha256Options::default())?;
println!("{}", report.digest);
# Ok(())
# }
```

[`TreeSha256Report`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256Report.html) includes counts and any submodule paths recorded as `cycle:` or `excluded:` (see the upstream spec).

## Example program

```rust
//! Print the tree-sha256 digest for `HEAD` (or the first argument).
//!
//! Source for the library guide "Tree SHA-256" page.

use grit_lib::error::Error;
use grit_lib::revwalk::{Peel, ResolveOptions};

use grit_lib::tree_sha256::TreeSha256Options;

fn main() -> Result<(), Error> {
    let cwd = std::env::current_dir().map_err(Error::Io)?;
    let env = grit_lib::config::environment::Environment::from_vars(std::env::vars_os(), cwd);
    let options = grit_lib::config::environment::RepositoryOptions::with_environment(env);
    let repo = grit_lib::repo::Repository::discover(None, &options)?;
    let rev = std::env::args().nth(1).unwrap_or_else(|| "HEAD".into());
    let oid = repo
        .revwalk()
        .resolve(&rev, &ResolveOptions::default().with_peel(Peel::Commit))?;
    let report = repo.tree_sha256(oid, &TreeSha256Options::default())?;
    println!("{}", report.digest);
    println!("files={} submodules={}", report.files, report.submodules);
    Ok(())
}
```

## Missing submodules

When a gitlink submodule is not checked out or its commit is absent, hashing returns [`TagError::TreeSha256MissingSubmodules`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/enum.TagError.html#variant.TreeSha256MissingSubmodules) listing every path.

## Tag header claim

Annotated tags can carry a [`TreeSha256Claim`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256Claim.html) in extra headers (immediately after `tagger`, before any other custom headers):

- one `tree-sha256-excluded <path>` line per excluded submodule (sorted when written)
- one `tree-sha256 <64-hex>` line with **exactly** 64 hex digits (no surrounding whitespace)

Read a claim with [`TreeSha256Claim::from_tag`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256Claim.html#method.from_tag) on [`TagData`](https://docs.rs/grit-lib/latest/grit_lib/objects/struct.TagData.html), or attach one with [`TreeSha256Claim::apply_to_tag`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256Claim.html#method.apply_to_tag). Header names are [`TREE_SHA256_HEADER`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/constant.TREE_SHA256_HEADER.html) and [`TREE_SHA256_EXCLUDED_HEADER`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/constant.TREE_SHA256_EXCLUDED_HEADER.html).

Excluded paths in [`TreeSha256Claim::excluded`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256Claim.html#structfield.excluded) must be non-empty and must not contain NUL or newline when calling `apply_to_tag` (the same rules enforced when reading tags).

## Verify a signed tag

[`Repository::verify_tag`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.verify_tag) reads an annotated tag object by id (not via a ref), checks its appended signature with [`TagVerifyOptions::gpg`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TagVerifyOptions.html#structfield.gpg), and recomputes the `tree-sha256` claim when the header is present. Signature verification and digest hashing run on separate threads.

Excluded submodule paths recorded in `tree-sha256-excluded` headers are hashed with [`TreeSha256Options::exclude_exact`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256Options.html#structfield.exclude_exact) only (no globs). Paths that are not gitlinks in the tagged tree are reported in [`TreeSha256Verdict::bogus_excluded`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256Verdict.html#structfield.bogus_excluded) and fail [`TagVerification::is_ok`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TagVerification.html#method.is_ok). Real excluded submodules are listed in [`TreeSha256Verdict::excluded`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TreeSha256Verdict.html#structfield.excluded) but do not fail verification.

```rust
use grit_lib::commit::signing::GpgConfig;
use grit_lib::repo::Repository;
use grit_lib::tree_sha256::TagVerifyOptions;

# fn main() -> grit_lib::error::Result<()> {
# let repo: Repository = todo!();
# let tag_oid = todo!();
let gpg = GpgConfig::from_config(repo.config().snapshot()?.as_ref())?
    .with_command_runner(repo.command_runner());
let report = repo.verify_tag(tag_oid, &TagVerifyOptions::new(gpg))?;
assert!(report.is_ok());
# Ok(())
# }
```

To verify by tag name, as `grit tag --verify` does, call [`verify_tag_by_name`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.verify_tag). It resolves `refs/tags/<name>` through the repository's ref store (loose, packed or reftable), reads the tag object once, and returns a [`VerifiedTag`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/struct.VerifiedTag.html) with the tag object id, the `object` header target and the [`TagVerification`](https://docs.rs/grit-lib/latest/grit_lib/tree_sha256/struct.TagVerification.html). A bad name, a missing tag, and a lightweight tag (one with no tag object to verify) are the typed errors `TagError::InvalidName`, `TagError::NotFound` and [`TagError::Lightweight`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/tag/enum.TagError.html#variant.Lightweight).

## Example program (verify)

```rust
//! Verify a signed tag's SSH/OpenPGP signature and optional `tree-sha256` header.
//!
//! Source for the library guide "Tree SHA-256" verification section.

use anyhow::{Context, Result};
use grit_lib::commit::signing::GpgConfig;
use grit_lib::revwalk::ResolveOptions;
use grit_lib::tree_sha256::TagVerifyOptions;

fn main() -> Result<()> {
    let cwd = std::env::current_dir()?;
    let env = grit_lib::config::environment::Environment::from_vars(std::env::vars_os(), cwd);
    let options = grit_lib::config::environment::RepositoryOptions::with_environment(env);
    let repo = grit_lib::repo::Repository::discover(None, &options)?;
    let tag = std::env::args()
        .nth(1)
        .context("usage: guide_tree_sha256_verify <tag>")?;
    let oid = repo.revwalk().resolve(&tag, &ResolveOptions::default())?;
    let gpg = GpgConfig::from_config(repo.config().snapshot()?.as_ref())?
        .with_command_runner(repo.command_runner());
    let report = repo.verify_tag(oid, &TagVerifyOptions::new(gpg))?;
    println!("signature: {:?}", report.signature);
    if let Some(v) = &report.tree_sha256 {
        println!("claimed: {}", v.claimed);
        println!("computed: {}", v.computed);
    }
    if report.is_ok() {
        println!("OK");
    } else {
        std::process::exit(1);
    }
    Ok(())
}
```

# https://grit-scm.com/docs/library/workspace-snapshot/index.md

# workspace-snapshot

# Workspace snapshot

Front ends that record an operation log need to undo more than a commit oid: conflict stages, worktree bytes (including conflict markers), named refs, `HEAD`, and merge/rebase sentinels must round-trip together.

[`Repository::workspace_snapshot`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.workspace_snapshot) exposes capture and restore. Stash [`create`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryStash.html#method.create) still refuses an unmerged index; use a workspace snapshot instead.

## Capture

[`WorkspaceCaptureOptions`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/workspace_snapshot/struct.WorkspaceCaptureOptions.html) lists refs to store as [`RawRef`](https://docs.rs/grit-lib/latest/grit_lib/refs/store/enum.RawRef.html) values and whether untracked paths belong in the worktree tree. [`capture_workspace_snapshot`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.workspace_snapshot) writes:

- [`HeadState`](https://docs.rs/grit-lib/latest/grit_lib/state/enum.HeadState.html)
- index file bytes (all conflict stages preserved)
- a worktree tree built from on-disk file contents
- operation sentinel files under `.git` (`MERGE_*`, `sequencer/`, `rebase-merge/`, …)

## Restore

[`restore_workspace_snapshot`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryWorkspaceSnapshot.html#method.restore) updates refs and symbolic `HEAD` in one transaction, writes the index bytes, checks out the worktree tree, then restores sentinels.

Before refs move, restore builds a tree from paths in the pre-restore index (all stages) and the snapshot worktree tree, hashing only files that exist on disk. Checkout diffs that tree against the snapshot worktree tree so undoing a branch switch or uncommitted deletions restores or removes paths even when they matched `HEAD` at capture. Untracked files that appear after capture and are not in the index or snapshot tree are left alone when `include_untracked` was false at capture.

## Clearing operation state

[`Operations::clear`](https://docs.rs/grit-lib/latest/grit_lib/operation/struct.Operations.html#method.clear) (`repo.operation().clear()`) removes merge/rebase/cherry-pick sentinels without moving `HEAD` or the worktree (unlike [`abort_branch_merge`](https://docs.rs/grit-lib/latest/grit_lib/merge/struct.Merge.html#method.abort_sequence)).

## Stash apply helper

[`StashApplyOptions::overwrite_identical_untracked`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashApplyOptions.html#structfield.overwrite_identical_untracked) lets apply succeed when an untracked file on disk already matches the stashed untracked parent (for example after `reset --hard` left the file in place). The CLI default stays `false`.

[`StashPushOptions::new`](https://docs.rs/grit-lib/latest/grit_lib/stash/struct.StashPushOptions.html#method.new) builds push options with only a committer identity required.

## Persistence and object lifetime

Front ends that run one process per command must store a captured snapshot and reload it in a later process. With the `serde-models` feature, [`WorkspaceSnapshot`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/workspace_snapshot/struct.WorkspaceSnapshot.html) implements `serde::Serialize` and `serde::Deserialize`. Serialize with a **binary** format (for example Postcard or Bincode): `index_bytes` and the values in `operation_state` are raw bytes, not JSON-friendly text. `index_mtime` is encoded as optional Unix seconds and nanoseconds.

[`capture_workspace_snapshot`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.workspace_snapshot) is non-mutating and does **not** keep objects alive. The worktree tree and any conflict-marker or untracked blobs it references are loose objects with no ref until you pin them. After `git gc --prune=now` or grit prune they become unreachable and restore will fail.

Call [`pin_workspace_snapshot`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryWorkspaceSnapshot.html#method.pin) (or [`RepositoryWorkspaceSnapshot::pin`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryWorkspaceSnapshot.html#method.pin)) with a caller-chosen id after capture. That writes `refs/grit/workspace-snapshots/<id>` pointing directly at [`WorkspaceSnapshot::worktree_tree`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/workspace_snapshot/struct.WorkspaceSnapshot.html#structfield.worktree_tree). The ref is outside `refs/heads/`, so a tree oid is valid and both Git and grit garbage collection retain the tree and reachable blobs. Keep the pin until the undo entry is discarded, then [`unpin_workspace_snapshot`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryWorkspaceSnapshot.html#method.unpin) so gc can reclaim the objects.

# https://grit-scm.com/docs/library/worktree/index.md

# Worktree

> Linked worktrees, ignore rules, attributes, and pathspec helpers under the worktree domain.

Working-tree behavior lives under [`worktree`](https://docs.rs/grit-lib/latest/grit_lib/worktree/index.html): ignore/attributes (`worktree::ignore`, `worktree::attributes`), pathspecs (`worktree::pathspec`), and checkout helpers. Porcelain commands (`status`, `add`, `checkout`, …) compose these modules with the index and ODB.

## Reftable interoperability

Linked worktree creation and branch switching use the repository's selected ref backend.
In a reftable repository, each worktree has its own `reftable/tables.list` stack for
`HEAD`, while branch tips remain in the shared stack. The admin directory's `HEAD`
file is a discovery placeholder; the symbolic branch or detached commit is stored
in reftable. Worktrees created by either grit or system Git can be reopened and
switched by the other tool without converting ref storage.

`AddLinkedWorktreeOptions::no_checkout` creates the same ref metadata while leaving
the index and tracked files absent. Git can resolve that worktree's `HEAD` immediately;
its status shows the missing tracked files until checkout materializes them.

### Add and switch benchmark

Local Linux x86_64 measurements against system Git 2.55.0, with release-profile
Grit builds before and after the HEAD fix. Each repository has 2,000 files, 2,000
refs and 31 commits. Add creates a detached worktree; switch alternates attached
branches across distinct commits in a Git-created linked worktree. Reftable stacks
are compacted before each build's run. Values are medians of 15 runs after two
warmups: wall milliseconds / peak RSS in KiB (`/usr/bin/time -v`). Compaction
compares `grit gc pack-refs` with `git pack-refs --all`.

| Operation | Git | Grit before | Grit after |
| --- | ---: | ---: | ---: |
| Files: add | 95.34 / 5,964 | 93.81 / 15,812 | 92.55 / 17,028 |
| Files: switch | 6.83 / 6,048 | 7.75 / 15,108 | 7.28 / 16,364 |
| Reftable: add | 98.57 / 5,980 | 93.51 / 16,224 | 94.87 / 17,192 |
| Reftable: switch | 7.69 / 6,332 | 12.18 / 15,672 | 11.89 / 16,932 |
| Reftable: compact | 2.33 / 4,540 | 9.57 / 13,048 | 9.41 / 13,384 |

The original reftable add/switch timings produced incorrect Git-visible HEAD
state. Correct initialization writes a per-worktree table, adding about 1.4 ms to
add in this fixture; switch and compaction are slightly faster. The release build's
measured peak RSS rises by about 1.0–1.2 MiB for add/switch and 0.3 MiB for compaction.

## Matching paths against pathspecs

Build a [`Pathspec`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html) once with [`Repository::pathspec`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.pathspec) and [`PathspecOptions`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.PathspecOptions.html) (global flags from [`PathspecGlobalFlags::from_environment`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.PathspecGlobalFlags.html#method.from_environment), optional `--pathspec-from-file` via [`PathspecFile`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.PathspecFile.html)). Call [`Pathspec::matches`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html#method.matches), [`matches_entry`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html#method.matches_entry), or [`matches_change`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html#method.matches_change) for each path. [`Pathspec::is_entire_tree`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html#method.is_entire_tree) is true when no argv paths were given.

[`Repository::paths_match_pathspecs`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.paths_match_pathspecs) takes a [`Pathspec`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html) and answers whether one repository-relative path matches. Attribute magic (`:(attr:...)`) is evaluated when you build the pathspec through the repository API; malformed `attr:` clauses fail with [`WorktreeError::InvalidAttrPathspec`](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.WorktreeError.html#variant.InvalidAttrPathspec). [`Pathspec::matches_change`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html#method.matches_change) also checks the old path of a rename. For argv-only helpers without a repository handle, [`Pathspec::scoped`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html#method.scoped) and [`Pathspec::matches_path`](https://docs.rs/grit-lib/latest/grit_lib/worktree/pathspec/struct.Pathspec.html#method.matches_path) cover glob, exclude, icase, and literal magic; attribute specs still need a repository-built pathspec.

## Ignore rules

[`IgnoreMatcher::from_repository`](https://docs.rs/grit-lib/latest/grit_lib/worktree/ignore/struct.IgnoreMatcher.html#method.from_repository) loads `.git/info/exclude` and `core.excludesfile`, then reads each directory's `.gitignore` the first time a path under it is queried. It applies Git's precedence: a nested `.gitignore` beats its parents, and the last matching line wins. [`is_path_ignored`](https://docs.rs/grit-lib/latest/grit_lib/worktree/ignore/struct.IgnoreMatcher.html#method.is_path_ignored) answers yes or no for hot walks, and [`check_path`](https://docs.rs/grit-lib/latest/grit_lib/worktree/ignore/struct.IgnoreMatcher.html#method.check_path) also returns the deciding pattern. Status, staging, auto-stage commits and clean all use the same matcher. With `core.ignorecase=true`, patterns and nested `.gitignore` directories match without regard to ASCII case, as in Git: `Build/` ignores `build/` and `*.LOG` ignores `debug.log`. [`with_ignore_case`](https://docs.rs/grit-lib/latest/grit_lib/worktree/ignore/struct.IgnoreMatcher.html#method.with_ignore_case) overrides the setting. Tracked paths are also found without regard to case there, so status, clean and staging never treat `build/` as ignored while `Build/t` is tracked. The matcher's own tracked-path exemption stays exact-case, like `git check-ignore`.

## Quoted attribute patterns

Double-quoted patterns in `.gitattributes` accept C-style escapes for tabs, newlines,
quotes, backslashes and other control characters, plus three-digit octal byte escapes
(`\000` through `\377`). Octal escapes can encode the bytes of UTF-8 names.
These patterns work when attributes are read from the worktree, index or a commit tree.

## Linked worktrees (handle)

`Repository::worktrees` returns `Worktrees`: list main and linked checkouts, add/remove/move/repair/lock linked worktrees with the same on-disk layout Git uses (`worktrees/` admin files, `gitdir` links). [`RepositoryWorktrees::add`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryWorktrees.html#method.add) runs the `post-checkout` hook from the new worktree after a successful checkout (null old id, start commit, flag `1`), matching Git; `--no-checkout` and orphan branches skip it. [`AddLinkedWorktreeOptions`](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.AddLinkedWorktreeOptions.html) uses [`WorktreeBranch`](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.WorktreeBranch.html) for branch modes (`Create`, `CreateOrReset`, `Existing`, `Detach`), optional lock-before-checkout, `--no-checkout`, and `--track`. [`RepositoryWorktrees::move_linked`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryWorktrees.html#method.move_linked) and [`RepositoryWorktrees::repair`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryWorktrees.html#method.repair) rewrite gitfile links atomically; repairs return [`WorktreeRepair`](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.WorktreeRepair.html) rows; [`RepositoryWorktrees::prune`](https://docs.rs/grit-lib/latest/grit_lib/repo_handles/struct.RepositoryWorktrees.html#method.prune) accepts [`PruneWorktreesOptions`](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.PruneWorktreesOptions.html) and returns [`PrunedWorktreeEntry`](https://docs.rs/grit-lib/latest/grit_lib/worktree/struct.PrunedWorktreeEntry.html) rows with a reason string.

Add, list and remove also work on a repository opened with an injected ref store or object store ([`RepositoryOptions::with_ref_store`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_ref_store) / [`with_object_store`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_object_store)). Branches are created, read and rolled back in the injected store. The linked worktree's own `HEAD` lives in its admin directory (`worktrees/<id>/HEAD`), because the store holds only the main worktree's `HEAD`. Its branch tip is still resolved through the store, so `WorktreeEntry::head` matches what a files repository reports. Bareness comes from [`Repository::is_bare`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html#method.is_bare), so a git directory kept outside the work tree is not mistaken for a bare repository.

To work in a linked worktree on the same injected stores, open the worktree admin directory with [`Repository::open`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) (`<common git dir>/worktrees/<id>`), [`RepositoryOptions::with_work_tree`](https://docs.rs/grit-lib/latest/grit_lib/config/environment/struct.RepositoryOptions.html#method.with_work_tree) set to the linked checkout path, and the same `with_ref_store` / `with_object_store` (and `with_odb_builder`) values as the main handle. When both stores are on disk, [`Repository::discover`](https://docs.rs/grit-lib/latest/grit_lib/repo/struct.Repository.html) from the linked path is enough. The handle reads and writes the worktree's own `HEAD` (`worktrees/<id>/HEAD`) and `HEAD` reflog (`worktrees/<id>/logs/HEAD`); every other ref and reflog stays in the injected store. A commit there moves the branch that file names, a detach or switch rewrites only that file, and the main worktree's branch, `HEAD` and `HEAD` reflog are left alone, as in a files repository.

Refusals are typed. Linked worktree failures arrive as [`Error::Worktree`](https://docs.rs/grit-lib/latest/grit_lib/error/enum.Error.html#variant.Worktree) carrying [`WorktreeError::Linked`](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.WorktreeError.html#variant.Linked) with a [`LinkedWorktreeError`](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.LinkedWorktreeError.html): `NotRegistered`, `MainWorktree` (with the refused [`LinkedWorktreeOperation`](https://docs.rs/grit-lib/latest/grit_lib/worktree/enum.LinkedWorktreeOperation.html)), `Locked`, `AlreadyLocked`, `NotLocked`, `HasLocalChanges`, `HasSubmodules`, `PathRegistered`, `PathRegisteredMissing`, `PathExists`, `BareRepository` and so on. Branch problems during add use the same [`BranchError`](https://docs.rs/grit-lib/latest/grit_lib/porcelain/branch/enum.BranchError.html) variants as branch creation (`InvalidName`, `NotFound`, `AlreadyExists`). A branch that is already checked out in another worktree is reported as `Error::BranchCheckedOutInWorktree`, and a start point that is not a commit as `Error::UnexpectedObjectKind`.

## Example

This program lists every worktree path grit sees for an open repository:

```rust
//! List linked worktrees and match Git's worktree admin output.
//!
//! Source for the library guide "Worktree" page (included in the docs site).

use anyhow::Result;
use grit_lib::config::environment::RepositoryOptions;
use grit_lib::repo::Repository;
use std::path::{Path, PathBuf};

fn open_repo(root: &Path) -> Result<Repository> {
    let git_dir = if root.join(".git").is_dir() {
        root.join(".git")
    } else {
        root.to_path_buf()
    };
    let work_tree = if root.join(".git").is_dir() {
        Some(root)
    } else {
        None
    };
    let mut opts = RepositoryOptions::from_process();
    if let Some(wt) = work_tree {
        opts = opts.with_work_tree(wt);
    }
    Ok(Repository::open(&git_dir, &opts)?)
}

fn main() -> Result<()> {
    let root = std::env::args()
        .nth(1)
        .map(PathBuf::from)
        .or_else(|| std::env::current_dir().ok())
        .ok_or_else(|| anyhow::anyhow!("missing repository path"))?;
    let repo = open_repo(&root)?;

    let rows = repo.worktrees().list()?;
    println!("worktree_count={}", rows.len());
    for entry in rows {
        println!("worktree {}", entry.path.display());
    }

    Ok(())
}
```

Create a linked worktree with Git, then compare counts:

```bash
git worktree add ../linked -b feature
cargo run --bin guide_worktree .
git worktree list
```

The integration test adds a linked worktree with system Git and compares `worktree_count` to `git worktree list --porcelain`.
