use std::{cell::RefCell, path::PathBuf};
use gix_hash::ObjectId;
use crate::{head, remote};
#[derive(Debug, Clone)]
pub struct Worktree<'repo> {
pub(crate) parent: &'repo Repository,
pub(crate) path: &'repo std::path::Path,
}
#[derive(Clone)]
pub struct Head<'repo> {
pub kind: head::Kind,
pub(crate) repo: &'repo Repository,
}
#[derive(Clone, Copy)]
pub struct Id<'r> {
pub(crate) inner: ObjectId,
pub(crate) repo: &'r Repository,
}
#[derive(Clone)]
pub struct Object<'repo> {
pub id: ObjectId,
pub kind: gix_object::Kind,
pub data: Vec<u8>,
pub(crate) repo: &'repo Repository,
}
impl<'a> Drop for Object<'a> {
fn drop(&mut self) {
self.repo.reuse_buffer(&mut self.data);
}
}
#[derive(Clone)]
pub struct Blob<'repo> {
pub id: ObjectId,
pub data: Vec<u8>,
pub(crate) repo: &'repo Repository,
}
impl<'a> Drop for Blob<'a> {
fn drop(&mut self) {
self.repo.reuse_buffer(&mut self.data);
}
}
#[derive(Clone)]
pub struct Tree<'repo> {
pub id: ObjectId,
pub data: Vec<u8>,
pub(crate) repo: &'repo Repository,
}
impl<'a> Drop for Tree<'a> {
fn drop(&mut self) {
self.repo.reuse_buffer(&mut self.data);
}
}
#[derive(Clone)]
pub struct Tag<'repo> {
pub id: ObjectId,
pub data: Vec<u8>,
pub(crate) repo: &'repo Repository,
}
impl<'a> Drop for Tag<'a> {
fn drop(&mut self) {
self.repo.reuse_buffer(&mut self.data);
}
}
#[derive(Clone)]
pub struct Commit<'repo> {
pub id: ObjectId,
pub data: Vec<u8>,
pub(crate) repo: &'repo Repository,
}
impl<'a> Drop for Commit<'a> {
fn drop(&mut self) {
self.repo.reuse_buffer(&mut self.data);
}
}
#[derive(Clone)]
pub struct ObjectDetached {
pub id: ObjectId,
pub kind: gix_object::Kind,
pub data: Vec<u8>,
}
#[derive(Clone)]
pub struct Reference<'r> {
pub inner: gix_ref::Reference,
pub(crate) repo: &'r Repository,
}
pub struct Repository {
pub refs: crate::RefStore,
pub objects: crate::OdbHandle,
pub(crate) work_tree: Option<PathBuf>,
pub(crate) common_dir: Option<PathBuf>,
pub(crate) bufs: RefCell<Vec<Vec<u8>>>,
pub(crate) config: crate::config::Cache,
pub(crate) options: crate::open::Options,
#[cfg(feature = "index")]
pub(crate) index: crate::worktree::IndexStorage,
#[cfg(feature = "attributes")]
pub(crate) modules: crate::submodule::ModulesFileStorage,
pub(crate) shallow_commits: crate::shallow::CommitsStorage,
}
#[derive(Clone)]
pub struct ThreadSafeRepository {
pub refs: crate::RefStore,
pub objects: gix_features::threading::OwnShared<gix_odb::Store>,
pub work_tree: Option<PathBuf>,
pub common_dir: Option<PathBuf>,
pub(crate) config: crate::config::Cache,
pub(crate) linked_worktree_options: crate::open::Options,
#[cfg(feature = "index")]
pub(crate) index: crate::worktree::IndexStorage,
#[cfg(feature = "attributes")]
pub(crate) modules: crate::submodule::ModulesFileStorage,
pub(crate) shallow_commits: crate::shallow::CommitsStorage,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Remote<'repo> {
pub(crate) name: Option<remote::Name<'static>>,
pub(crate) url: Option<gix_url::Url>,
pub(crate) url_alias: Option<gix_url::Url>,
pub(crate) push_url: Option<gix_url::Url>,
pub(crate) push_url_alias: Option<gix_url::Url>,
pub(crate) fetch_specs: Vec<gix_refspec::RefSpec>,
pub(crate) push_specs: Vec<gix_refspec::RefSpec>,
pub(crate) fetch_tags: remote::fetch::Tags,
pub(crate) repo: &'repo Repository,
}
#[derive(Clone)]
#[cfg(feature = "attributes")]
pub struct Pathspec<'repo> {
pub(crate) repo: &'repo Repository,
pub(crate) stack: Option<gix_worktree::Stack>,
pub(crate) search: gix_pathspec::Search,
}
#[derive(Clone)]
#[cfg(feature = "attributes")]
pub struct PathspecDetached {
pub stack: Option<gix_worktree::Stack>,
pub search: gix_pathspec::Search,
pub odb: gix_odb::HandleArc,
}
#[derive(Clone)]
#[cfg(feature = "attributes")]
pub struct Submodule<'repo> {
pub(crate) state: std::rc::Rc<crate::submodule::SharedState<'repo>>,
pub(crate) name: crate::bstr::BString,
}
#[cfg(any(feature = "attributes", feature = "excludes"))]
pub struct AttributeStack<'repo> {
pub(crate) repo: &'repo Repository,
pub(crate) inner: gix_worktree::Stack,
}