Ancora.Git.BatchPort (ancora v1.0.0-rc.1)

Copy Markdown View Source

One git cat-file --batch port per run.

The port is owned by Ancora.Derive.RunContext, never registered, and is spawned without :stderr_to_stdout so git stderr cannot interleave with blob payloads. Framing is <oid> <type> <size>\n<payload>\n.

Summary

Functions

Closes the port and drains leftover messages.

Requests one object (<oid> or <rev>:<path>) and waits for its frame.

Opens an unregistered git cat-file --batch port against root.

Parses a captured git cat-file --batch byte stream into complete records.

Fetches each spec serially through the port, in request order.

Types

record()

@type record() :: %{
  oid: String.t(),
  type: String.t(),
  size: non_neg_integer(),
  payload: binary()
}

t()

@type t() :: %Ancora.Git.BatchPort{port: port(), root: Path.t()}

Functions

close(port)

@spec close(t() | port() | nil) :: :ok

Closes the port and drains leftover messages.

fetch(batch_port, spec, opts \\ [])

@spec fetch(t(), String.t(), keyword()) :: {:ok, record()} | {:error, term()}

Requests one object (<oid> or <rev>:<path>) and waits for its frame.

open(root)

@spec open(Path.t()) :: {:ok, t()} | {:error, term()}

Opens an unregistered git cat-file --batch port against root.

parse_stream(buffer)

@spec parse_stream(binary()) ::
  {:ok, [record() | {:missing, String.t()}], binary()} | {:error, term()}

Parses a captured git cat-file --batch byte stream into complete records.

Returns {:ok, records, rest} where rest is any trailing incomplete bytes.

prefetch(batch, specs, opts \\ [])

@spec prefetch(t(), [String.t()], keyword()) :: [
  {String.t(), {:ok, record()} | {:error, term()}}
]

Fetches each spec serially through the port, in request order.