Skip to content

Commit

Permalink
adapt to changes in gix-worktree
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 20, 2023
1 parent 5d5f286 commit e5717e1
Show file tree
Hide file tree
Showing 29 changed files with 109 additions and 105 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

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
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
4 changes: 2 additions & 2 deletions gix-status/src/index_as_worktree/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bstr::BStr;

/// The error returned by [`status()`][crate::status()].
/// The error returned by [`status()`](crate::index_as_worktree()).
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
Expand Down Expand Up @@ -40,7 +40,7 @@ pub enum Change<T = ()> {
/// Indicates that one of the stat changes was an executable bit change
/// which is a significant change itself.
executable_bit_changed: bool,
/// The output of the [`CompareBlobs`][crate::status::content::CompareBlobs] run on this entry.
/// The output of the [`CompareBlobs`](crate::index_as_worktree::content::CompareBlobs) run on this entry.
/// If there is no content change and only the executable bit
/// changed than this is `None`.
content_change: Option<T>,
Expand Down
4 changes: 2 additions & 2 deletions gix-worktree-state/src/checkout/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bstr::{BStr, BString};
use gix_hash::oid;

use crate::{checkout, checkout::entry};
use gix_worktree::Cache;
use gix_worktree::Stack;

mod reduce {
use std::marker::PhantomData;
Expand Down Expand Up @@ -92,7 +92,7 @@ pub struct Outcome<'a> {
#[derive(Clone)]
pub struct Context<Find: Clone> {
pub find: Find,
pub path_cache: Cache,
pub path_cache: Stack,
pub filters: gix_filter::Pipeline,
pub buf: Vec<u8>,
pub options: Options,
Expand Down
4 changes: 2 additions & 2 deletions gix-worktree-state/src/checkout/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use gix_hash::oid;
use gix_index::{entry::Stat, Entry};
use io_close::Close;

use gix_worktree::Cache;
use gix_worktree::Stack;

pub struct Context<'a, Find> {
pub find: &'a mut Find,
pub path_cache: &'a mut Cache,
pub path_cache: &'a mut Stack,
pub filters: &'a mut gix_filter::Pipeline,
pub buf: &'a mut Vec<u8>,
}
Expand Down
6 changes: 3 additions & 3 deletions gix-worktree-state/src/checkout/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use gix_features::{interrupt, parallel::in_parallel_with_finalize, progress::Pro
use gix_hash::oid;

use crate::checkout::chunk;
use gix_worktree::{cache, Cache};
use gix_worktree::{stack, Stack};

/// Checkout the entire `index` into `dir`, and resolve objects found in index entries with `find` to write their content to their
/// respective path in `dir`.
Expand Down Expand Up @@ -66,12 +66,12 @@ where
None,
);

let state = cache::State::for_checkout(options.overwrite_existing, std::mem::take(&mut options.attributes));
let state = stack::State::for_checkout(options.overwrite_existing, std::mem::take(&mut options.attributes));
let attribute_files = state.id_mappings_from_index(index, paths, case);
let mut ctx = chunk::Context {
buf: Vec::new(),
options: (&options).into(),
path_cache: Cache::new(dir, state, case, Vec::with_capacity(512), attribute_files),
path_cache: Stack::new(dir, state, case, Vec::with_capacity(512), attribute_files),
filters: options.filters,
find,
};
Expand Down
2 changes: 1 addition & 1 deletion gix-worktree-state/src/checkout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct Options {
/// Control how stat comparisons are made when checking if a file is fresh.
pub stat_options: stat::Options,
/// A stack of attributes to use with the filesystem cache to use as driver for filters.
pub attributes: gix_worktree::cache::state::Attributes,
pub attributes: gix_worktree::stack::state::Attributes,
/// The filter pipeline to use for applying mandatory filters before writing to the worktree.
pub filters: gix_filter::Pipeline,
/// Control how long-running processes may use the 'delay' capability.
Expand Down
16 changes: 8 additions & 8 deletions gix-worktree-state/tests/state/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use gix_features::progress;
use gix_object::bstr::ByteSlice;
use gix_odb::FindExt;
use gix_testtools::tempfile::TempDir;
use gix_worktree::checkout::Collision;
use gix_worktree_state::checkout::Collision;
use once_cell::sync::Lazy;

use crate::fixture_path;
Expand Down Expand Up @@ -454,26 +454,26 @@ pub fn dir_structure<P: AsRef<std::path::Path>>(path: P) -> Vec<std::path::PathB
}

fn checkout_index_in_tmp_dir(
opts: gix_worktree::checkout::Options,
opts: gix_worktree_state::checkout::Options,
name: &str,
) -> crate::Result<(PathBuf, TempDir, gix_index::File, gix_worktree::checkout::Outcome)> {
) -> crate::Result<(PathBuf, TempDir, gix_index::File, gix_worktree_state::checkout::Outcome)> {
checkout_index_in_tmp_dir_opts(opts, name, |_d| true, |_| Ok(()))
}

fn checkout_index_in_tmp_dir_opts(
opts: gix_worktree::checkout::Options,
opts: gix_worktree_state::checkout::Options,
name: &str,
mut allow_return_object: impl FnMut(&gix_hash::oid) -> bool + Send + Clone,
prep_dest: impl Fn(&Path) -> std::io::Result<()>,
) -> crate::Result<(PathBuf, TempDir, gix_index::File, gix_worktree::checkout::Outcome)> {
) -> crate::Result<(PathBuf, TempDir, gix_index::File, gix_worktree_state::checkout::Outcome)> {
let source_tree = fixture_path(name);
let git_dir = source_tree.join(".git");
let mut index = gix_index::File::at(git_dir.join("index"), gix_hash::Kind::Sha1, Default::default())?;
let odb = gix_odb::at(git_dir.join("objects"))?.into_inner().into_arc()?;
let destination = gix_testtools::tempfile::tempdir_in(std::env::current_dir()?)?;
prep_dest(destination.path()).expect("preparation must succeed");

let outcome = gix_worktree::checkout(
let outcome = gix_worktree_state::checkout(
&mut index,
destination.path(),
move |oid, buf| {
Expand Down Expand Up @@ -501,8 +501,8 @@ fn probe_gitoxide_dir() -> crate::Result<gix_fs::Capabilities> {
))
}

fn opts_from_probe() -> gix_worktree::checkout::Options {
gix_worktree::checkout::Options {
fn opts_from_probe() -> gix_worktree_state::checkout::Options {
gix_worktree_state::checkout::Options {
fs: probe_gitoxide_dir().unwrap(),
destination_is_initially_empty: true,
thread_limit: gix_features::parallel::num_threads(None).into(),
Expand Down
10 changes: 5 additions & 5 deletions gix-worktree-stream/tests/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod from_tree {
use gix_object::{bstr::ByteSlice, tree::EntryMode};
use gix_odb::FindExt;
use gix_testtools::once_cell::sync::Lazy;
use gix_worktree::cache::state::attributes::Source;
use gix_worktree::stack::state::attributes::Source;

use crate::hex_to_id;

Expand Down Expand Up @@ -231,7 +231,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 @@ -242,14 +242,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
4 changes: 2 additions & 2 deletions gix-worktree/src/stack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Stack {
/// symlinks are in that path.
/// Unless `is_dir` is known with `Some(…)`, then `relative` points to a directory itself in which case the entire resulting
/// path is created as directory. If it's not known it is assumed to be a file.
/// `find` maybe used to lookup objects from an [id mapping][crate::cache::State::id_mappings_from_index()], with mappnigs
/// `find` maybe used to lookup objects from an [id mapping][crate::stack::State::id_mappings_from_index()], with mappnigs
///
/// Provide access to cached information for that `relative` path via the returned platform.
pub fn at_path<Find, E>(
Expand Down Expand Up @@ -110,7 +110,7 @@ impl Stack {

/// Obtain a platform for lookups from a repo-`relative` path, typically obtained from an index entry. `is_dir` should reflect
/// whether it's a directory or not, or left at `None` if unknown.
/// `find` maybe used to lookup objects from an [id mapping][crate::cache::State::id_mappings_from_index()].
/// `find` maybe used to lookup objects from an [id mapping][crate::stack::State::id_mappings_from_index()].
/// All effects are similar to [`at_path()`][Self::at_path()].
///
/// If `relative` ends with `/` and `is_dir` is `None`, it is automatically assumed to be a directory.
Expand Down
Loading

0 comments on commit e5717e1

Please sign in to comment.