Exgit.Pack.Index (exgit v0.1.0)

Copy Markdown View Source

Pack-index (.idx) writer and reader for git pack-index v2.

write/2 produces a v2-format index (magic \xff\x74\x4f\x63, version 2) from a list of {sha, crc32, offset} entries and verifies clean with git verify-pack. read/1 parses a v2 index and returns a struct for O(log N) SHA lookups.

v1 indexes (pre-2008 git) are not supported; v2 has been git's default since git 1.6.

Summary

Types

entry()

@type entry() ::
  {sha :: binary(), crc32 :: non_neg_integer(), offset :: non_neg_integer()}

Functions

lookup(index_data, sha)

@spec lookup(binary(), binary()) :: {:ok, non_neg_integer()} | :error

read(data)

@spec read(binary()) :: {:ok, [entry()], binary()} | {:error, term()}

write(entries, pack_checksum)

@spec write([entry()], binary()) :: binary()