···23232424If you are working with a normal on-disk repository, start with
2525`repository.Open(...)`. It opens the repository and wires together the refs
2626-storage, object storage, and fetcher. Note that it requires either a
2727-bare repository or a `.git` directory. Then,
2626+storage, object storage, fetcher, (optional) commit-graph, commit queries, and
2727+reachability helpers. Note that it requires either a bare repository or a
2828+`.git` directory. Then,
28292930* `repo.Refs()` is for branch names, tags, `HEAD`, and ref updates.
3031 * Use it when you are starting from names rather than object IDs.
···4748 * However, checking an object ID's size and type are somewhat common
4849 operations that should be done here.
49505151+* `repo.CommitQueries()` is the main graph-query API.
5252+ * Use it when you need ancestor checks or merge-base computation.
5353+5454+* `repo.Reachability()` is the graph-traversal API.
5555+ * Use it when you need to walk reachable commits or objects, or to perform
5656+ connectivity checks.
5757+5858+* `repo.CommitGraph()` exposes the low-level commit-graph reader.
5959+ * Not all repositories have commit graphs, so it may be nil.
6060+ * Most callers should prefer `repo.CommitQueries()` or `repo.Reachability()`
6161+ unless they specifically need direct commit-graph access.
6262+5063Note that:
51645265* `object` contains parsed Git object values such as blobs, trees, commits, and
···6376* If you want typed objects or path-based access, use `repo.Fetcher()`.
6477* If you need raw object lookup by ID, object headers, or object streams, use
6578 `repo.Objects()`.
7979+* If you need ancestor checks or merge bases, use `repo.CommitQueries()`.
8080+* If you need commit or object graph traversal, use `repo.Reachability()`.
66816767-Some useful operations are separate and are meant to be constructed over the
6868-stores that `Repository` already exposes:
6969-7070-* To check whether one revision is an ancestor of another, or to compute merge
7171- bases, construct a `commitquery.Query` over `repo.Objects()`. If you already
7272- have a commit-graph reader, pass it in as well for performance.
7373-7474-* To walk commits or all reachable objects from a set of starting points,
7575- construct a `reachability.Reachability` over `repo.Objects()`. This is useful
7676- for tasks such as connectivity checks and computing the object set that a
7777- fetch or push needs to account for.
8282+Some operations remain available if you want to work below those accessors:
78837984* To accept pushes on the server side, construct `network/receivepack` or
8085 `network/receivepack/service` with the repository's ref store, object store,
8181- and object ID algorithm.
8686+ commit-graph reader, and object ID algorithm.
8287 * Push handling also needs the repository's object storage root so incoming
8388 objects can be quarantined and later promoted.
8489 * `Repository` does not currently expose that root directly (we'll consider
8590 possible solutions sometime later), so a push server usually keeps the
8691 repository path or object root handle alongside the `Repository` value.
8787- * Hook-based checks are just Go functions; then, a fast-forward check can use
8888- `commitquery` over the existing and quarantined object stores. Some hooks
8989- are provided.
9292+ * Hook-based checks are just Go functions; for example, a fast-forward check
9393+ can use `commitquery.Queries` over the existing and quarantined object
9494+ stores. Some hooks are provided.
90959196## Alternatives
9297