Skip to content

checkout: Create directories similar to and consider using a cache #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Mar 4, 2022
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
322c316
also validate symlink collisions (#301)
Byron Mar 2, 2022
48dc401
refactor (#301)
Byron Mar 2, 2022
acb8acd
hopefully fix symlink creation on windows (#301)
Byron Mar 2, 2022
be5e3fb
gather more information about test failure on windows (#301)
Byron Mar 2, 2022
60bcffc
performance issue on windows is due to slow process execution speed (…
Byron Mar 2, 2022
4b1650b
fix symlink creation on windows, hopefully (#301)
Byron Mar 2, 2022
e90c123
support for unicode-precomposition for gix apps (#301)
Byron Mar 2, 2022
039e822
basic progress reporting for checkout (#301)
Byron Mar 3, 2022
f23b8d2
basic version of index checkout via command-line (#301)
Byron Mar 3, 2022
5494fb3
support for repo to write actual objects (#301)
Byron Mar 3, 2022
5388d80
allow writing empty files during checkout but also query the odb (#301)
Byron Mar 3, 2022
537e5aa
fix progress - there is no max value for bytes written (#301)
Byron Mar 4, 2022
a39d476
Properly use 'max-performance' feature toggle to get pack caches :D (…
Byron Mar 4, 2022
f4621cc
sketch out dir cache and realize that git uses chdir (#301)
Byron Mar 4, 2022
cb36d56
basic impl of the dir cache which already avoids unnecessary allocati…
Byron Mar 4, 2022
a3501df
avoid popping the entire cached path (#301)
Byron Mar 4, 2022
de58f50
forbid symlinks and files in the path (#301)
Byron Mar 4, 2022
749c310
Support for forceful removal of symlinks or files during dir creation…
Byron Mar 4, 2022
0e2a243
thanks clippy
Byron Mar 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
avoid popping the entire cached path (#301)
This comes at a cost, but hopefully this is justified performance
wise but most importantly, makes the upcoming implementation of the
lstat cache possible or easier.
  • Loading branch information
Byron committed Mar 4, 2022
commit a3501df6eb8d2fd3176434c80c443316e91dabb6
24 changes: 20 additions & 4 deletions git-worktree/src/index/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub struct PathCache {
root: PathBuf,
/// the most recent known cached that we know is valid.
valid: PathBuf,
/// The relative portion of `valid` that was added previously.
valid_relative: PathBuf,
/// The amount of path components of 'valid' beyond the roots components. If `root` has 2, and this is 2, `valid` has 4 components.
valid_components: usize,
}
Expand All @@ -37,6 +39,7 @@ mod cache {
let root = root.into();
PathCache {
valid: root.clone(),
valid_relative: PathBuf::with_capacity(128),
valid_components: 0,
root,
}
Expand All @@ -63,14 +66,27 @@ mod cache {
"can only handle file-like items right now"
);

let mut components = relative.components().peekable();
let mut existing_components = self.valid_relative.components();
let mut matching_components = 0;
while let (Some(existing_comp), Some(new_comp)) = (existing_components.next(), components.peek()) {
if existing_comp == *new_comp {
components.next();
matching_components += 1;
} else {
break;
}
}

// TODO: handle valid state properly, handle _mode.
for _ in 0..self.valid_components {
for _ in 0..self.valid_components - matching_components {
self.valid.pop();
}

self.valid_components = 0;
for component in relative.iter() {
self.valid.push(component);
self.valid_components = matching_components;
for comp in components {
self.valid.push(comp);
self.valid_relative.push(comp);
self.valid_components += 1;
}

Expand Down