Skip to main content

SparseCheckout

Struct SparseCheckout 

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

The active sparse-checkout definition of a repository, compiled once for path checks.

Checkout-updating operations (reset --hard, switch, merge, pull, restore, …) load this once per operation: paths it excludes are recorded in the index with the skip-worktree bit instead of being written to the work tree, like Git’s sparse checkout.

SparseCheckout::load returns None when core.sparseCheckout is off or info/sparse-checkout does not exist, so non-sparse repositories pay only a config lookup.

Implementations§

Source§

impl SparseCheckout

Source

pub fn load(repo: &Repository) -> Result<Option<Self>>

Load the sparse-checkout definition of repo from its config and info/sparse-checkout.

Reads core.sparseCheckout and core.sparseCheckoutCone from the repository’s cached configuration; the pattern file is only read when sparse checkout is enabled.

§Returns

Ok(None) when sparse checkout is disabled or the pattern file is missing.

§Errors

crate::error::Error::Config when either key holds an invalid boolean, and crate::error::Error::Io when the pattern file exists but cannot be read.

Source

pub fn from_config(git_dir: &Path, config: &ConfigSet) -> Result<Option<Self>>

Like SparseCheckout::load, with an explicit git directory and configuration.

§Parameters
  • git_dir — directory holding info/sparse-checkout (the per-worktree git dir).
  • config — configuration providing core.sparseCheckout / core.sparseCheckoutCone.
§Errors

Same as SparseCheckout::load.

Source

pub fn parse(content: &str, cone: bool) -> Self

Compile sparse-checkout file content.

§Parameters
  • content — text of info/sparse-checkout.
  • cone — the value of core.sparseCheckoutCone; a file that is not a valid cone definition falls back to non-cone matching.
Source

pub fn includes(&self, path: &str) -> bool

Whether the repository-relative file path (/-separated) belongs in the work tree.

Source

pub fn includes_index_path(&self, path: &[u8]) -> bool

Like SparseCheckout::includes, for a raw index path.

Source

pub fn mark_index_entries(&self, index: &mut Index, work_tree: Option<&Path>)

Set skip-worktree on every stage-0 entry of index that is outside the definition and clear it on the others; bumps the index to version 3 when any bit is set.

§Parameters
  • index — index to update in place.
  • work_tree — when set, on-disk directories can match directory-only non-cone patterns.
Source

pub fn carry_skip_worktree(&self, index: &mut Index, previous: &Index)

Carry sparse state into index, an index rebuilt from a tree without touching the work tree (mixed reset, merge abort, stash): a stage-0 entry gets skip-worktree when previous marks the same path skip-worktree, or when previous has no entry for the path and the path is outside the definition.

§Parameters
  • index — the rebuilt index, updated in place.
  • previous — the index the rebuild replaces.

Trait Implementations§

Source§

impl Clone for SparseCheckout

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SparseCheckout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.