gix_worktree/lib.rs
1//! A crate with utility types for use by other crates that implement specifics.
2//!
3//! Unless specified differently, all operations need an index file (e.g. `.git/index`) as driver.
4//!
5//! ## Feature Flags
6#![cfg_attr(
7 all(doc, feature = "document-features"),
8 doc = ::document_features::document_features!()
9)]
10#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))]
11#![deny(missing_docs, rust_2018_idioms, unsafe_code)]
12use bstr::BString;
13/// Provides types needed for using [`stack::Platform::matching_attributes()`].
14#[cfg(feature = "attributes")]
15pub use gix_attributes as attributes;
16/// A way to access the [`Case`](glob::pattern::Case) enum which used throughout this API.
17pub use gix_glob as glob;
18/// Provides types needed for using [`stack::Platform::excluded_kind()`].
19pub use gix_ignore as ignore;
20/// Provides types needed for using [`Stack::at_path()`] and [`Stack::at_entry()`].
21pub use gix_index as index;
22/// Provides types needed for using [`Stack::at_path()`] and [`Stack::at_entry()`].
23pub use gix_object as object;
24/// Provides types needed for using [`stack::State::for_checkout()`].
25#[cfg(feature = "attributes")]
26pub use gix_validate as validate;
27
28/// A cache for efficiently executing operations on directories and files which are encountered in sorted order.
29/// That way, these operations can be re-used for subsequent invocations in the same directory.
30///
31/// This cache can be configured to create directories efficiently, read git-ignore files and git-attribute files,
32/// in any combination.
33///
34/// A cache for directory creation to reduce the amount of stat calls when creating
35/// directories safely, that is without following symlinks that might be on the way.
36///
37/// As a special case, it offers a 'prefix' which (by itself) is assumed to exist and may contain symlinks.
38/// Everything past that prefix boundary must not contain a symlink. We do this by allowing any input path.
39///
40/// Another added benefit is its ability to store the path of full path of the entry to which leading directories
41/// are to be created to avoid allocating memory.
42///
43/// For this to work, it remembers the last 'good' path to a directory and assumes that all components of it
44/// are still valid, too.
45/// As directories are created, the cache will be adjusted to reflect the latest seen directory.
46///
47/// The caching is only useful if consecutive calls to create a directory are using a sorted list of entries.
48#[derive(Clone)]
49pub struct Stack {
50 stack: gix_fs::Stack,
51 /// tells us what to do as we change paths.
52 state: stack::State,
53 /// A buffer used when reading attribute or ignore files or their respective objects from the object database.
54 buf: Vec<u8>,
55 /// If case folding should happen when looking up attributes or exclusions.
56 case: gix_glob::pattern::Case,
57 /// A lookup table for object ids to read from in some situations when looking up attributes or exclusions.
58 id_mappings: Vec<PathIdMapping>,
59 statistics: stack::Statistics,
60}
61
62pub(crate) type PathIdMapping = (BString, gix_hash::ObjectId);
63
64///
65pub mod stack;