Skip to content

Commit 5d5f286

Browse files
committed
change!: rename Cache to Stack because it's more fitting.
1 parent 1958dff commit 5d5f286

File tree

12 files changed

+41
-40
lines changed

12 files changed

+41
-40
lines changed

gix-worktree/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ use bstr::BString;
3232
///
3333
/// The caching is only useful if consecutive calls to create a directory are using a sorted list of entries.
3434
#[derive(Clone)]
35-
pub struct Cache {
35+
pub struct Stack {
3636
stack: gix_fs::Stack,
3737
/// tells us what to do as we change paths.
38-
state: cache::State,
38+
state: stack::State,
3939
/// A buffer used when reading attribute or ignore files or their respective objects from the object database.
4040
buf: Vec<u8>,
4141
/// If case folding should happen when looking up attributes or exclusions.
4242
case: gix_glob::pattern::Case,
4343
/// A lookup table for object ids to read from in some situations when looking up attributes or exclusions.
4444
id_mappings: Vec<PathIdMapping>,
45-
statistics: cache::Statistics,
45+
statistics: stack::Statistics,
4646
}
4747

4848
pub(crate) type PathIdMapping = (BString, gix_hash::ObjectId);
4949

5050
///
51-
pub mod cache;
51+
pub mod stack;

gix-worktree/src/cache/delegate.rs renamed to gix-worktree/src/stack/delegate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bstr::{BStr, ByteSlice};
22

3-
use crate::{cache::State, PathIdMapping};
3+
use crate::{stack::State, PathIdMapping};
44

55
/// Various aggregate numbers related to the stack delegate itself.
66
#[derive(Default, Clone, Copy, Debug)]

gix-worktree/src/cache/mod.rs renamed to gix-worktree/src/stack/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use std::path::{Path, PathBuf};
44
use bstr::{BStr, ByteSlice};
55
use gix_hash::oid;
66

7-
use super::Cache;
7+
use super::Stack;
88
use crate::PathIdMapping;
99

10-
/// Various aggregate numbers collected from when the corresponding [`Cache`] was instantiated.
10+
/// Various aggregate numbers collected from when the corresponding [`Stack`] was instantiated.
1111
#[derive(Default, Clone, Copy, Debug)]
1212
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1313
pub struct Statistics {
@@ -45,12 +45,12 @@ pub enum State {
4545

4646
#[must_use]
4747
pub struct Platform<'a> {
48-
parent: &'a Cache,
48+
parent: &'a Stack,
4949
is_dir: Option<bool>,
5050
}
5151

5252
/// Initialization
53-
impl Cache {
53+
impl Stack {
5454
/// Create a new instance with `worktree_root` being the base for all future paths we match.
5555
/// `state` defines the capabilities of the cache.
5656
/// The `case` configures attribute and exclusion case sensitivity at *query time*, which should match the case that
@@ -64,7 +64,7 @@ impl Cache {
6464
id_mappings: Vec<PathIdMapping>,
6565
) -> Self {
6666
let root = worktree_root.into();
67-
Cache {
67+
Stack {
6868
stack: gix_fs::Stack::new(root),
6969
state,
7070
case,
@@ -76,7 +76,7 @@ impl Cache {
7676
}
7777

7878
/// Entry points for attribute query
79-
impl Cache {
79+
impl Stack {
8080
/// Append the `relative` path to the root directory of the cache and efficiently create leading directories, while assuring that no
8181
/// symlinks are in that path.
8282
/// Unless `is_dir` is known with `Some(…)`, then `relative` points to a directory itself in which case the entire resulting
@@ -140,7 +140,7 @@ impl Cache {
140140
}
141141

142142
/// Mutation
143-
impl Cache {
143+
impl Stack {
144144
/// Reset the statistics after returning them.
145145
pub fn take_statistics(&mut self) -> Statistics {
146146
std::mem::take(&mut self.statistics)
@@ -159,7 +159,7 @@ impl Cache {
159159
}
160160

161161
/// Access
162-
impl Cache {
162+
impl Stack {
163163
/// Return the statistics we gathered thus far.
164164
pub fn statistics(&self) -> &Statistics {
165165
&self.statistics

gix-worktree/src/cache/platform.rs renamed to gix-worktree/src/stack/platform.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::path::Path;
22

33
use bstr::ByteSlice;
44

5-
use crate::cache::Platform;
5+
use crate::stack::Platform;
66

77
/// Access
88
impl<'a> Platform<'a> {

gix-worktree/src/cache/state/attributes.rs renamed to gix-worktree/src/stack/state/attributes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use bstr::{BStr, ByteSlice};
44
use gix_glob::pattern::Case;
55

66
use crate::{
7-
cache::state::{AttributeMatchGroup, Attributes},
8-
Cache, PathIdMapping,
7+
stack::state::{AttributeMatchGroup, Attributes},
8+
PathIdMapping, Stack,
99
};
1010

1111
/// Various aggregate numbers related [`Attributes`].
@@ -200,7 +200,7 @@ impl Attributes {
200200
}
201201

202202
/// Attribute matching specific methods
203-
impl Cache {
203+
impl Stack {
204204
/// Creates a new container to store match outcomes for all attribute matches.
205205
///
206206
/// ### Panics

gix-worktree/src/cache/state/ignore.rs renamed to gix-worktree/src/stack/state/ignore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use bstr::{BStr, ByteSlice};
44
use gix_glob::pattern::Case;
55

66
use crate::{
7-
cache::state::{Ignore, IgnoreMatchGroup},
7+
stack::state::{Ignore, IgnoreMatchGroup},
88
PathIdMapping,
99
};
1010

gix-worktree/src/cache/state/mod.rs renamed to gix-worktree/src/stack/state/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::path::PathBuf;
33
use bstr::{BString, ByteSlice};
44
use gix_glob::pattern::Case;
55

6-
use crate::{cache::State, PathIdMapping};
6+
use crate::{stack::State, PathIdMapping};
77

88
type AttributeMatchGroup = gix_attributes::Search;
99
type IgnoreMatchGroup = gix_ignore::Search;

gix-worktree/tests/worktree/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
mod cache;
2-
31
use gix_hash::ObjectId;
2+
3+
mod stack;
4+
45
pub type Result<T = ()> = std::result::Result<T, Box<dyn std::error::Error>>;
56

67
pub fn hex_to_id(hex: &str) -> ObjectId {

gix-worktree/tests/worktree/cache/attributes.rs renamed to gix-worktree/tests/worktree/stack/attributes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use bstr::ByteSlice;
22
use gix_attributes::search::Outcome;
33
use gix_glob::pattern::Case;
4-
use gix_worktree::cache::state;
4+
use gix_worktree::stack::state;
55

66
#[test]
77
fn baseline() -> crate::Result {
@@ -19,17 +19,17 @@ fn baseline() -> crate::Result {
1919

2020
let mut buf = Vec::new();
2121
let mut collection = gix_attributes::search::MetadataCollection::default();
22-
let state = gix_worktree::cache::State::for_checkout(
22+
let state = gix_worktree::stack::State::for_checkout(
2323
false,
2424
state::Attributes::new(
2525
gix_attributes::Search::new_globals([base.join("user.attributes")], &mut buf, &mut collection)?,
2626
Some(git_dir.join("info").join("attributes")),
27-
gix_worktree::cache::state::attributes::Source::WorktreeThenIdMapping,
27+
gix_worktree::stack::state::attributes::Source::WorktreeThenIdMapping,
2828
collection,
2929
),
3030
);
3131

32-
let mut cache = gix_worktree::Cache::new(&base, state, case, buf, vec![]);
32+
let mut cache = gix_worktree::Stack::new(&base, state, case, buf, vec![]);
3333

3434
let mut actual = cache.attribute_matches();
3535
let input = std::fs::read(base.join("baseline"))?;

gix-worktree/tests/worktree/cache/create_directory.rs renamed to gix-worktree/tests/worktree/stack/create_directory.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::path::Path;
22

33
use gix_testtools::tempfile::{tempdir, TempDir};
4-
use gix_worktree::{cache, Cache};
4+
use gix_worktree::{stack, Stack};
55

66
#[allow(clippy::ptr_arg)]
77
fn panic_on_find<'buf>(_oid: &gix_hash::oid, _buf: &'buf mut Vec<u8>) -> std::io::Result<gix_object::BlobRef<'buf>> {
@@ -11,9 +11,9 @@ fn panic_on_find<'buf>(_oid: &gix_hash::oid, _buf: &'buf mut Vec<u8>) -> std::io
1111
#[test]
1212
fn root_is_assumed_to_exist_and_files_in_root_do_not_create_directory() -> crate::Result {
1313
let dir = tempdir()?;
14-
let mut cache = Cache::new(
14+
let mut cache = Stack::new(
1515
dir.path().join("non-existing-root"),
16-
cache::State::for_checkout(false, Default::default()),
16+
stack::State::for_checkout(false, Default::default()),
1717
Default::default(),
1818
Vec::new(),
1919
Default::default(),
@@ -68,7 +68,7 @@ fn symlinks_or_files_in_path_are_forbidden_or_unlinked_when_forced() -> crate::R
6868
std::fs::write(tmp.path().join("file-in-dir"), [])?;
6969

7070
for dirname in &["file-in-dir", "link-to-dir"] {
71-
if let cache::State::CreateDirectoryAndAttributesStack {
71+
if let stack::State::CreateDirectoryAndAttributesStack {
7272
unlink_on_collision, ..
7373
} = cache.state_mut()
7474
{
@@ -90,7 +90,7 @@ fn symlinks_or_files_in_path_are_forbidden_or_unlinked_when_forced() -> crate::R
9090
);
9191
cache.take_statistics();
9292
for dirname in &["link-to-dir", "file-in-dir"] {
93-
if let cache::State::CreateDirectoryAndAttributesStack {
93+
if let stack::State::CreateDirectoryAndAttributesStack {
9494
unlink_on_collision, ..
9595
} = cache.state_mut()
9696
{
@@ -109,11 +109,11 @@ fn symlinks_or_files_in_path_are_forbidden_or_unlinked_when_forced() -> crate::R
109109
Ok(())
110110
}
111111

112-
fn new_cache() -> (Cache, TempDir) {
112+
fn new_cache() -> (Stack, TempDir) {
113113
let dir = tempdir().unwrap();
114-
let cache = Cache::new(
114+
let cache = Stack::new(
115115
dir.path(),
116-
cache::State::for_checkout(false, Default::default()),
116+
stack::State::for_checkout(false, Default::default()),
117117
Default::default(),
118118
Vec::new(),
119119
Default::default(),

0 commit comments

Comments
 (0)