Skip to content

Commit

Permalink
Merge branch 'worktree-organization'
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 20, 2023
2 parents ef54aab + e5717e1 commit 8d0d8e0
Show file tree
Hide file tree
Showing 93 changed files with 425 additions and 253 deletions.
42 changes: 38 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ members = [
"gix-index",
"gix-bitmap",
"gix-worktree",
"gix-worktree-state",
"gix-status",
"gix-revision",
"gix-packetline",
"gix-packetline-blocking",
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ is usable to some extent.
* [gix-worktree-stream](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-worktree-stream)
* [gix-archive](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-archive)
* [gix-submodule](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-submodule)
* [gix-status](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-status)
* [gix-worktree-state](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-worktree-state)
* `gitoxide-core`
* **very early** _(possibly without any documentation and many rough edges)_
* [gix-date](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-date)
Expand Down
48 changes: 28 additions & 20 deletions crate-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,28 +453,36 @@ Make it the best-performing implementation and the most convenient one.
### gix-glob
* [x] parse pattern
* [x] a type for pattern matching of paths and non-paths, optionally case-insensitively.

### gix-worktree

### gix-status
* [x] differences between index and worktree to turn index into worktree
* [ ] differences between tree and index to turn tree into index
* [ ] untracked files
* [ ] fast answer to 'is it dirty'.
*
### gix-worktree-state
* handle the working **tree/checkout**
- [x] checkout an index of files, executables and symlinks just as fast as git
- [x] forbid symlinks in directories
- [ ] handle submodules
- [ ] handle sparse directories
- [ ] handle sparse index
- [x] linear scaling with multi-threading up to IO saturation
- supported attributes to affect working tree and index contents
- [ ] eol
- [ ] working-tree-encoding
- …more
- **filtering**
- [ ] `text`
- [ ] `ident`
- [ ] filter processes
- [ ] single-invocation clean/smudge filters
* manage multiple worktrees
- [x] checkout an index of files, executables and symlinks just as fast as git
- [x] forbid symlinks in directories
- [ ] handle submodules
- [ ] handle sparse directories
- [ ] handle sparse index
- [x] linear scaling with multi-threading up to IO saturation
- supported attributes to affect working tree and index contents
- [x] eol
- [x] working-tree-encoding
- …more
- **filtering**
- [x] `text`
- [x] `ident`
- [x] filter processes
- [x] single-invocation clean/smudge filters
* access to per-path information, like `.gitignore` and `.gitattributes` in a manner well suited for efficient lookups
* [x] _exclude_ information
* [ ] attributes
* [x] _exclude_ information
* [x] attributes

### gix-worktree
* [x] A stack to to efficiently generate attribute lists for matching paths against.

### gix-revision
* [x] `describe()` (similar to `git name-rev`)
Expand Down
Binary file added etc/gix-components.monopic
Binary file not shown.
3 changes: 3 additions & 0 deletions etc/gix-components.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
╔════════════════╗
║ gix-submodule ║
╚════════════════╝
4 changes: 2 additions & 2 deletions gitoxide-core/src/hours/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ pub fn spawn_tree_delta_threads<'scope>(
repo.index_or_load_from_head().map_err(Into::into).and_then(|index| {
repo.attributes(
&index,
gix::worktree::cache::state::attributes::Source::IdMapping,
gix::worktree::cache::state::ignore::Source::IdMapping,
gix::worktree::stack::state::attributes::Source::IdMapping,
gix::worktree::stack::state::ignore::Source::IdMapping,
None,
)
.map_err(Into::into)
Expand Down
8 changes: 4 additions & 4 deletions gitoxide-core/src/index/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use anyhow::bail;
use gix::{odb::FindExt, worktree::checkout, Progress};
use gix::{odb::FindExt, worktree::state::checkout, Progress};

use crate::{
index,
Expand Down Expand Up @@ -55,7 +55,7 @@ pub fn checkout_exclusive(
progress.info(format!("Skipping {num_skipped} DIR/SYMLINK/COMMIT entries"));
}

let opts = gix::worktree::checkout::Options {
let opts = gix::worktree::state::checkout::Options {
fs: gix::fs::Capabilities::probe(dest_directory),

destination_is_initially_empty: true,
Expand Down Expand Up @@ -86,7 +86,7 @@ pub fn checkout_exclusive(
delayed_paths_unknown,
delayed_paths_unprocessed,
} = match repo {
Some(repo) => gix::worktree::checkout(
Some(repo) => gix::worktree::state::checkout(
&mut index,
dest_directory,
{
Expand All @@ -109,7 +109,7 @@ pub fn checkout_exclusive(
should_interrupt,
opts,
),
None => gix::worktree::checkout(
None => gix::worktree::state::checkout(
&mut index,
dest_directory,
|_, buf| {
Expand Down
8 changes: 4 additions & 4 deletions gitoxide-core/src/repository/attributes/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ pub(crate) mod function {

pub(crate) fn attributes_cache(
repo: &gix::Repository,
) -> anyhow::Result<(gix::worktree::Cache, IndexPersistedOrInMemory)> {
) -> anyhow::Result<(gix::worktree::Stack, IndexPersistedOrInMemory)> {
let index = repo.index_or_load_from_head()?;
let cache = repo.attributes(
&index,
if repo.is_bare() {
gix::worktree::cache::state::attributes::Source::IdMapping
gix::worktree::stack::state::attributes::Source::IdMapping
} else {
gix::worktree::cache::state::attributes::Source::WorktreeThenIdMapping
gix::worktree::stack::state::attributes::Source::WorktreeThenIdMapping
},
gix::worktree::cache::state::ignore::Source::IdMapping,
gix::worktree::stack::state::ignore::Source::IdMapping,
None,
)?;
Ok((cache, index))
Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/repository/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub(crate) mod function {
}
};

if let Some(gix::worktree::checkout::Outcome { collisions, errors, .. }) = outcome {
if let Some(gix::worktree::state::checkout::Outcome { collisions, errors, .. }) = outcome {
if !(collisions.is_empty() && errors.is_empty()) {
let mut messages = Vec::new();
if !errors.is_empty() {
Expand Down
14 changes: 7 additions & 7 deletions gitoxide-core/src/repository/index/entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ pub(crate) mod function {
match attrs {
Attributes::WorktreeAndIndex => {
if repo.is_bare() {
gix::worktree::cache::state::attributes::Source::IdMapping
gix::worktree::stack::state::attributes::Source::IdMapping
} else {
gix::worktree::cache::state::attributes::Source::WorktreeThenIdMapping
gix::worktree::stack::state::attributes::Source::WorktreeThenIdMapping
}
}
Attributes::Index => gix::worktree::cache::state::attributes::Source::IdMapping,
Attributes::Index => gix::worktree::stack::state::attributes::Source::IdMapping,
},
match attrs {
Attributes::WorktreeAndIndex => {
if repo.is_bare() {
gix::worktree::cache::state::ignore::Source::IdMapping
gix::worktree::stack::state::ignore::Source::IdMapping
} else {
gix::worktree::cache::state::ignore::Source::WorktreeThenIdMappingIfNotSkipped
gix::worktree::stack::state::ignore::Source::WorktreeThenIdMappingIfNotSkipped
}
}
Attributes::Index => gix::worktree::cache::state::ignore::Source::IdMapping,
Attributes::Index => gix::worktree::stack::state::ignore::Source::IdMapping,
},
None,
)
Expand Down Expand Up @@ -203,7 +203,7 @@ pub(crate) mod function {
pub excluded: usize,
pub with_attributes: usize,
pub max_attributes_per_path: usize,
pub cache: Option<gix::worktree::cache::Statistics>,
pub cache: Option<gix::worktree::stack::Statistics>,
}

#[cfg(feature = "serde")]
Expand Down
10 changes: 5 additions & 5 deletions gix-archive/tests/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod from_tree {
use gix_object::tree::EntryMode;
use gix_odb::FindExt;
use gix_testtools::bstr::ByteSlice;
use gix_worktree::cache::state::attributes::Source;
use gix_worktree::stack::state::attributes::Source;

use crate::hex_to_id;

Expand Down Expand Up @@ -284,7 +284,7 @@ mod from_tree {
Ok(())
}

fn basic() -> gix_testtools::Result<(PathBuf, gix_hash::ObjectId, gix_odb::HandleArc, gix_worktree::Cache)> {
fn basic() -> gix_testtools::Result<(PathBuf, gix_hash::ObjectId, gix_odb::HandleArc, gix_worktree::Stack)> {
let dir = gix_testtools::scripted_fixture_read_only("basic.sh")?;

let head = {
Expand All @@ -295,14 +295,14 @@ mod from_tree {

let mut collection = Default::default();
let mut buf = Default::default();
let attributes = gix_worktree::cache::state::Attributes::new(
let attributes = gix_worktree::stack::state::Attributes::new(
gix_attributes::Search::new_globals(None::<PathBuf>, &mut buf, &mut collection)?,
None,
Source::WorktreeThenIdMapping,
collection,
);
let state = gix_worktree::cache::State::AttributesStack(attributes);
let cache = gix_worktree::Cache::new(&dir, state, Case::Sensitive, Default::default(), Default::default());
let state = gix_worktree::stack::State::AttributesStack(attributes);
let cache = gix_worktree::Stack::new(&dir, state, Case::Sensitive, Default::default(), Default::default());
Ok((dir, head, odb.into_arc()?, cache))
}

Expand Down
12 changes: 11 additions & 1 deletion gix-diff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ rust-version = "1.65"
autotests = false

[features]
default = ["blob"]
## Enable diffing of blobs using imara-diff.
blob = ["dep:imara-diff"]
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
serde = ["dep:serde", "gix-hash/serde", "gix-object/serde"]
## Make it possible to compile to the `wasm32-unknown-unknown` target.
Expand All @@ -23,6 +26,13 @@ doctest = false
gix-hash = { version = "^0.11.4", path = "../gix-hash" }
gix-object = { version = "^0.34.0", path = "../gix-object" }
thiserror = "1.0.32"
imara-diff = "0.1.3"
imara-diff = { version = "0.1.3", optional = true }
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]}
getrandom = { version = "0.2.8", optional = true, default-features = false, features = ["js"] }

document-features = { version = "0.2.0", optional = true }

[package.metadata.docs.rs]
all-features = true
features = ["document-features"]
rustdoc-args = ["--cfg", "docsrs"]
7 changes: 7 additions & 0 deletions gix-diff/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
//! Algorithms for diffing various git object types and for generating patches, highly optimized for performance.
//! ## Feature Flags
#![cfg_attr(
feature = "document-features",
cfg_attr(doc, doc = ::document_features::document_features!())
)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![deny(missing_docs, rust_2018_idioms)]
#![forbid(unsafe_code)]

///
pub mod tree;

///
#[cfg(feature = "blob")]
pub mod blob;
16 changes: 8 additions & 8 deletions gix-filter/tests/pipeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ fn default() -> crate::Result {
Ok(())
}

fn attribute_cache(name: &str) -> gix_testtools::Result<gix_worktree::Cache> {
fn attribute_cache(name: &str) -> gix_testtools::Result<gix_worktree::Stack> {
let dir = gix_testtools::scripted_fixture_read_only("pipeline_repos.sh")?.join(name);
Ok(gix_worktree::Cache::new(
Ok(gix_worktree::Stack::new(
dir,
gix_worktree::cache::State::for_add(
gix_worktree::cache::state::Attributes::new(
gix_worktree::stack::State::for_add(
gix_worktree::stack::state::Attributes::new(
Default::default(),
None,
gix_worktree::cache::state::attributes::Source::WorktreeThenIdMapping,
gix_worktree::stack::state::attributes::Source::WorktreeThenIdMapping,
Default::default(),
),
gix_worktree::cache::state::Ignore::new(
gix_worktree::stack::state::Ignore::new(
Default::default(),
Default::default(),
None,
gix_worktree::cache::state::ignore::Source::WorktreeThenIdMappingIfNotSkipped,
gix_worktree::stack::state::ignore::Source::WorktreeThenIdMappingIfNotSkipped,
),
),
Case::Sensitive,
Expand All @@ -49,7 +49,7 @@ fn pipeline(
gix_filter::pipeline::CrlfRoundTripCheck,
eol::Configuration,
),
) -> gix_testtools::Result<(gix_worktree::Cache, gix_filter::Pipeline)> {
) -> gix_testtools::Result<(gix_worktree::Stack, gix_filter::Pipeline)> {
let cache = attribute_cache(name)?;
let (drivers, encodings_with_roundtrip_check, crlf_roundtrip_check, eol_config) = init();
let pipe = gix_filter::Pipeline::new(
Expand Down
File renamed without changes.
Loading

0 comments on commit 8d0d8e0

Please sign in to comment.