gix_status/lib.rs
1//! This crate includes the various diffs `git` can do between different representations
2//! of the repository state, like comparisons between…
3//!
4//! * index and working tree
5//! * *tree and index*
6//!
7//! …while also being able to check if the working tree is dirty, quickly, by instructing the operation to stop once the first
8//! change was found.
9//!
10//! ### Tree-Index Status
11//!
12//! This status is not actually implemented here as it's not implemented directly. Instead, one creates an Index from a tree
13//! and then diffs two indices with `gix_diff::index(index_from_tree, usually_dot_git_index)`. This adds about 15% to the runtime
14//! and comes at the cost of another index in memory.
15//! Once there are generators implementing depth-first tree iteration should become trivial, but for now it's very hard if one
16//! wants to return referenced state of the iterator (which is not possible).
17//!
18//! ### Difference to `gix-diff`
19//!
20//! Technically, `status` is just another form of diff between different kind of sides, i.e. an index and a working tree.
21//! This is the difference to `gix-diff`, which compares only similar items.
22//!
23//! ### Feature Flags
24#![cfg_attr(
25 all(doc, feature = "document-features"),
26 doc = ::document_features::document_features!()
27)]
28#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))]
29#![deny(missing_docs, rust_2018_idioms, unsafe_code)]
30
31#[cfg(target_has_atomic = "64")]
32use std::sync::atomic::AtomicU64;
33
34#[cfg(not(target_has_atomic = "64"))]
35use portable_atomic::AtomicU64;
36
37pub mod index_as_worktree;
38pub use index_as_worktree::function::index_as_worktree;
39
40#[cfg(feature = "worktree-rewrites")]
41pub mod index_as_worktree_with_renames;
42#[cfg(feature = "worktree-rewrites")]
43pub use index_as_worktree_with_renames::function::index_as_worktree_with_renames;
44
45/// A stack that validates we are not going through a symlink in a way that is read-only.
46///
47/// It can efficiently validate paths when these are queried in sort-order, which leads to each component
48/// to only be checked once.
49pub struct SymlinkCheck {
50 inner: gix_fs::Stack,
51}
52
53mod stack;
54
55fn is_dir_to_mode(is_dir: bool) -> gix_index::entry::Mode {
56 if is_dir {
57 gix_index::entry::Mode::DIR
58 } else {
59 gix_index::entry::Mode::FILE
60 }
61}