Skip to main content

GitRepository

Struct GitRepository 

Source
pub struct GitRepository { /* private fields */ }
Expand description

Read-only Repository over an existing git directory.

Implementations§

Source§

impl GitRepository

Source

pub fn open(git_dir: &Path, oak_sidecar_dir: &Path) -> Result<Self>

Open an existing git repository at git_dir (the .git folder, or a bare repo). oak_sidecar_dir is the directory where Oak-only state files live (created on demand).

Trait Implementations§

Source§

impl Repository for GitRepository

Source§

fn store_blob(&self, _blob: &Blob) -> Result<()>

store_blob is unsupported because Oak’s Blob carries a precomputed BLAKE3 hash, and writing it as a git blob would assign a different OID. Callers must use Repository::put_blob instead, which returns the canonical git OID.

Source§

fn store_manifest(&self, _manifest: &Manifest) -> Result<()>

Unsupported for the same reason as store_blob — Oak’s manifest hash is BLAKE3 over a flat encoding, but git trees are nested with their own OID derivation. Callers must use Repository::put_manifest.

Source§

fn get_tree(&self, hash: &Hash) -> Result<Option<Tree>>

Read the direct children of one git tree as an Oak Tree. Submodules are skipped (matching read_tree_recursive).

Source§

fn store_tree(&self, _tree: &Tree) -> Result<()>

Unsupported for the same reason as store_blob: the Tree’s hash is Oak’s BLAKE3, but a git tree object would assign its own OID. Use [put_tree] instead, which returns the git OID.

Source§

fn store_branch(&self, branch: &Branch) -> Result<()>

Create the git ref for a new branch, pointing at the current HEAD, and record Oak’s branch metadata (description / parent_branch / status / created_at) in the sidecar TOML at <git_dir>/oak/branches.toml.

The git ref is what actually makes the branch usable; the sidecar just preserves Oak-only fields so oak branch show / branch list aren’t lossy.

Source§

fn hash_blob_content(&self, content: &[u8]) -> Hash

The hash this backend would assign content via Self::put_blob, computed without storing anything. Read-only paths (oak status, restore previews) compare working files against manifest entries with this; BLAKE3 by default, the git blob OID on the git backend.
Source§

fn put_blob(&self, content: Vec<u8>) -> Result<Hash>

Hash and store a blob’s content. Returns the backend’s canonical hash.
Source§

fn get_blob(&self, hash: &Hash) -> Result<Option<Blob>>

Source§

fn has_blob(&self, hash: &Hash) -> Result<bool>

Source§

fn put_manifest(&self, entries: Vec<ManifestEntry>) -> Result<Hash>

Build and store a manifest from the given entries. Returns the backend’s canonical hash for the manifest (a tree OID on the git backend).
Source§

fn get_manifest(&self, hash: &Hash) -> Result<Option<Manifest>>

Source§

fn put_tree(&self, entries: Vec<ManifestEntry>) -> Result<Hash>

Build a nested tree from a flat list of entries and store every tree object produced. Returns the root tree hash. Default impl uses crate::build_tree and the per-tree store_tree.
Source§

fn walk_tree(&self, root: &Hash) -> Result<Vec<ManifestEntry>>

Walk the tree rooted at root and return its flat entry list.
Source§

fn get_branch(&self, name: &str) -> Result<Option<Branch>>

Source§

fn list_branches(&self) -> Result<Vec<Branch>>

Source§

fn update_branch_status(&self, name: &str, status: BranchStatus) -> Result<()>

Source§

fn close_branch( &self, name: &str, close_reason: Option<CloseReason>, ) -> Result<()>

Close a branch and optionally record an explicit close reason.
Source§

fn update_branch_close_reason( &self, name: &str, close_reason: CloseReason, ) -> Result<()>

Source§

fn update_branch_description(&self, name: &str, description: &str) -> Result<()>

Source§

fn get_branch_head(&self, name: &str) -> Result<Option<Hash>>

Source§

fn set_branch_head(&self, name: &str, hash: &Hash) -> Result<()>

Source§

fn store_commit(&self, _commit: &Commit) -> Result<()>

Source§

fn put_commit( &self, branch_name: String, parent_hash: Option<Hash>, merge_parent_hash: Option<Hash>, manifest_hash: Hash, author: String, message: Option<String>, timestamp: DateTime<Utc>, files: Vec<FileChange>, ) -> Result<Hash>

Build and store a commit. Returns the backend’s canonical commit hash. Read more
Source§

fn get_commit(&self, hash: &Hash) -> Result<Option<Commit>>

Source§

fn has_commit(&self, hash: &Hash) -> Result<bool>

Source§

fn get_commits_for_branch(&self, branch_name: &str) -> Result<Vec<Commit>>

Source§

fn get_commits_since( &self, branch_name: &str, since: Option<&Hash>, ) -> Result<Vec<Commit>>

Source§

fn get_all_commits(&self) -> Result<Vec<Commit>>

Source§

fn get_metadata(&self, key: MetadataKey) -> Result<Option<String>>

Source§

fn set_metadata(&self, key: MetadataKey, value: &str) -> Result<()>

Source§

fn store_chunk(&self, _hash: &Hash, _content: &[u8]) -> Result<()>

Source§

fn get_chunk(&self, _hash: &Hash) -> Result<Option<Vec<u8>>>

Source§

fn has_chunk(&self, _hash: &Hash) -> Result<bool>

Source§

fn store_blob_chunks( &self, _blob_hash: &Hash, _chunks: &[ChunkInfo], ) -> Result<()>

Source§

fn get_blob_chunks(&self, _blob_hash: &Hash) -> Result<Option<Vec<ChunkInfo>>>

Source§

fn has_blobs(&self, hashes: &[&Hash]) -> Result<Vec<bool>>

Repository::has_blob for many hashes, in order. Backends override it to answer a whole manifest’s presence check with one prepared statement instead of one round trip per entry.
Source§

fn get_blob_size(&self, hash: &Hash) -> Result<Option<u64>>

Source§

fn has_tree(&self, hash: &Hash) -> Result<bool>

Source§

fn resolve_path_in_tree( &self, root: &Hash, path: &str, ) -> Result<Option<TreeEntry>>

Resolve a /-separated path to a TreeEntry within the tree at root.
Source§

fn subtree_at_path(&self, root: &Hash, path: &str) -> Result<Option<Hash>>

Return the hash of the subtree at path (must be a directory). An empty path returns Some(root).
Source§

fn list_branches_isolated( &self, ) -> Result<Vec<Result<Branch, UnreadableBranch>>>

Like Self::list_branches, but one stored row whose metadata cannot be decoded becomes an Err(UnreadableBranch) entry instead of failing the whole listing (fb-118). Batch assessment uses this so a single corrupt row cannot hide every other branch.
Source§

fn set_branch_parent(&self, name: &str, parent: Option<&str>) -> Result<()>

Re-parent an existing branch (restacking it). Unlike store_branch, which never touches an existing row, this overwrites parent_branch.
Source§

fn edit_branch_description(&self, name: &str, description: &str) -> Result<()>

Record user-authored text separately from server/import metadata updates.
Source§

fn description_publication_generation(&self) -> Result<Option<i64>>

Capture before reading description text for publication. Backends without local synchronization tracking return no token and do not acknowledge.
Source§

fn acknowledge_branch_description( &self, name: &str, description: Option<&str>, generation: Option<i64>, ) -> Result<()>

Acknowledge exact text and generation, without clearing a newer/ABA edit.
Source§

fn rename_branch(&self, old_name: &str, new_name: &str) -> Result<()>

Source§

fn delete_branch(&self, name: &str) -> Result<()>

Remove a branch row and its head pointer from local storage. Commits authored on the branch are untouched — commits.branch_name is a soft label. Deleting a branch that doesn’t exist is a no-op.
Source§

fn reconcile_remote_merge_branch_state( &self, closed_branch: &str, new_branch: &Branch, seed_head: &Hash, ) -> Result<()>

Atomically close a remotely-merged branch, create the fresh current branch, and point branch/HEAD metadata at seed_head. Read more
Source§

fn repair_commit_fields(&self, verified: &Commit) -> Result<bool>

Repair the commit row stored under verified.hash when its stored fields don’t reproduce that hash. store_commit keeps the first row it sees, so a row written with a placeholder author and the client’s clock (older oak merge binaries did this for the server’s squash commit) would otherwise never self-verify. Read more
Source§

fn merge_child_exists(&self, branch_head: &Hash) -> Result<bool>

Fast negative check for “does any local commit claim this commit as its merge parent?” SQLite backs this with an index on commits.merge_parent_hash; the default implementation is only for backends without a native query path.
Source§

fn count_commits_for_branch(&self, branch_name: &str) -> Result<usize>

Number of commits authored directly on branch_name — rows whose branch_name column equals this branch. In Oak’s branch-per-session model a feature branch is seeded at its parent’s head with none of its own commits; each oak commit adds one, and a squash-merge moves you onto a fresh branch with zero again. So this count is exactly the branch’s local work not yet merged into its parent. Purely local — it never consults the server. Defaults to counting Repository::get_commits_for_branch; backends override it with a cheaper COUNT(*).
Source§

fn insert_metadata_if_absent( &self, key: MetadataKey, value: &str, ) -> Result<bool>

Write value only when key has no value yet; returns whether it was written. Backends that can should make this a single atomic statement so a concurrent writer’s value is never overwritten.
Source§

fn load_stat_cache(&self) -> Result<HashMap<String, StatCacheEntry>>

Load the entire stat cache as a path -> entry map.
Source§

fn update_stat_cache( &self, upserts: &[(String, StatCacheEntry)], removed: &[String], ) -> Result<()>

Apply a batch of stat-cache changes: upsert upserts (path + entry) and delete the paths in removed. Implementations should run this as one transaction. An empty batch must be a no-op so an unchanged oak status performs zero writes.
Source§

fn put_blob_sources(&self, sources: Vec<BlobSource>) -> Result<Vec<Hash>>

Hash and store many blobs, returning each source’s canonical hash in input order. Each source’s read is invoked exactly once, possibly on a worker thread, to obtain the bytes to store. Semantically identical to a Repository::put_blob loop (which is the default impl), but it lets a backend overlap producing one blob’s content (e.g. reading a file) with hashing/encoding/storing another’s instead of forcing all-produce-then-all-hash barriers — which is what makes a snapshot of a few large files fast.
Source§

fn put_commit_and_advance_refs( &self, branch_name: String, parent_hash: Option<Hash>, merge_parent_hash: Option<Hash>, entries: Vec<ManifestEntry>, author: String, message: Option<String>, timestamp: DateTime<Utc>, files: Vec<FileChange>, ) -> Result<Hash>

Build/store a manifest, create a commit for it, and advance the branch head plus legacy HEAD to that commit. Backends that can transactionally publish the whole transition should override this method.
Source§

fn put_tree_commit_and_advance_refs( &self, branch_name: String, parent_hash: Option<Hash>, merge_parent_hash: Option<Hash>, root: Hash, trees: &[Tree], author: String, message: Option<String>, timestamp: DateTime<Utc>, files: Vec<FileChange>, ) -> Result<Hash>

Self::put_commit_and_advance_refs for a snapshot that already exists as trees — a tree-level merge’s result — so the whole tree is never rebuilt from a flat entry list. root is the commit’s root tree; trees are the ones not stored yet (every other tree under root must already be). Backends that can publish the whole transition in one transaction should override this method.
Source§

fn get_head(&self) -> Result<Option<Hash>>

Source§

fn set_head(&self, hash: &Hash) -> Result<()>

Source§

fn get_remote_url(&self) -> Result<Option<String>>

Source§

fn get_current_branch_name(&self) -> Result<Option<String>>

Source§

fn set_current_branch(&self, name: &str) -> Result<()>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.