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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ default = ["max"]
## Makes the crate execute as fast as possible by supporting parallel computation of otherwise long-running functions
## as well as fast, hardware accelerated hashing, along with a faster zlib backend.
## If disabled, the binary will be visibly smaller.
fast = ["git-features/parallel", "git-features/fast-sha1", "git-features/zlib-ng-compat"]
fast = ["git-features/parallel", "git-features/fast-sha1", "git-features/zlib-ng-compat", "git-repository/max-performance"]

## Use `clap` 3.0 to build the prettiest, best documented and most user-friendly CLI at the expense of binary size.
## Provides a terminal user interface for detailed and exhaustive progress.
Expand Down
1 change: 1 addition & 0 deletions crate-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ See its [README.md](https://github.com/Byron/gitoxide/blob/main/git-lock/README.
* [x] initialize
* [ ] Proper configuration depending on platform (e.g. ignorecase, filemode, …)
* [ ] All mutations are multi-process safe and this is tested and configurable (i.e. abort or wait if lock is encountered)
* support for unicode-precomposition of command-line arguments (needs explicit use in parent application)
* **Easy** (_porcelain_)
* **Id**
* [x] short hashes with detection of ambiguity.
Expand Down
2 changes: 1 addition & 1 deletion etc/check-package-size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ echo "in root: gitoxide CLI"
(enter git-packetline && indent cargo diet -n --package-size-limit 35KB)
(enter git-repository && indent cargo diet -n --package-size-limit 80KB)
(enter git-transport && indent cargo diet -n --package-size-limit 50KB)
(enter gitoxide-core && indent cargo diet -n --package-size-limit 50KB)
(enter gitoxide-core && indent cargo diet -n --package-size-limit 60KB)
3 changes: 3 additions & 0 deletions git-index/src/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ impl State {
pub fn entries(&self) -> &[Entry] {
&self.entries
}
pub fn entries_mut(&mut self) -> &mut [Entry] {
&mut self.entries
}
pub fn entries_mut_with_paths(&mut self) -> impl Iterator<Item = (&mut Entry, &BStr)> {
let paths = &self.path_backing;
self.entries.iter_mut().map(move |e| {
Expand Down
6 changes: 1 addition & 5 deletions git-ref/tests/packed/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,7 @@ fn find_speed() -> crate::Result {
let packed = store.open_packed_buffer()?.expect("packed-refs present");
let start = std::time::Instant::now();
let mut num_refs = 0;
#[cfg(windows)]
let count = 500;
#[cfg(not(windows))]
let count = 10_000;
for r in packed.iter()?.take(count) {
for r in packed.iter()?.take(10_000) {
num_refs += 1;
let r = r?;
assert_eq!(
Expand Down
6 changes: 5 additions & 1 deletion git-repository/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ max-performance = ["git-features/parallel", "git-features/zlib-ng-compat", "git-
local-time-support = ["git-actor/local-time-support"]
## Re-export stability tier 2 crates for convenience and make `Repository` struct fields with types from these crates publicly accessible.
## Doing so is less stable than the stability tier 1 that `git-repository` is a member of.
unstable = ["git-index"]
unstable = ["git-index", "git-worktree"]
## Print debugging information about usage of object database caches, useful for tuning cache sizes.
cache-efficiency-debug = ["git-features/cache-efficiency-debug"]

Expand Down Expand Up @@ -77,6 +77,7 @@ git-features = { version = "^0.19.1", path = "../git-features", features = ["pro

# unstable only
git-index = { version ="^0.1.0", path = "../git-index", optional = true }
git-worktree = { version ="^0.0.0", path = "../git-worktree", optional = true }

signal-hook = { version = "0.3.9", default-features = false }
thiserror = "1.0.26"
Expand All @@ -86,6 +87,9 @@ log = "0.4.14"

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

[target.'cfg(target_vendor = "apple")'.dependencies]
unicode-normalization = { version = "0.1.19", default-features = false }

[dev-dependencies]
git-testtools = { path = "../tests/tools" }
anyhow = "1"
Expand Down
26 changes: 26 additions & 0 deletions git-repository/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
//! * [`actor`]
//! * [`bstr`][bstr]
//! * [`index`]
//! * [`worktree`]
//! * [`objs`]
//! * [`odb`]
//! * [`pack`][odb::pack]
Expand Down Expand Up @@ -144,6 +145,8 @@ pub use git_url as url;
#[doc(inline)]
#[cfg(all(feature = "unstable", feature = "git-url"))]
pub use git_url::Url;
#[cfg(all(feature = "unstable", feature = "git-worktree"))]
pub use git_worktree as worktree;
pub use hash::{oid, ObjectId};

pub mod interrupt;
Expand Down Expand Up @@ -286,3 +289,26 @@ pub mod discover {
}
}
}

///
pub mod env {
use std::ffi::OsString;

/// Equivalent to `std::env::args_os()`, but with precomposed unicode on MacOS and other apple platforms.
#[cfg(not(target_vendor = "apple"))]
pub fn args_os() -> impl Iterator<Item = OsString> {
std::env::args_os()
}

/// Equivalent to `std::env::args_os()`, but with precomposed unicode on MacOS and other apple platforms.
///
/// Note that this ignores `core.precomposeUnicode` as git-config isn't available yet. It's default enabled in modern git though.
#[cfg(target_vendor = "apple")]
pub fn args_os() -> impl Iterator<Item = OsString> {
use unicode_normalization::UnicodeNormalization;
std::env::args_os().map(|arg| match arg.to_str() {
Some(arg) => arg.nfc().collect::<String>().into(),
None => arg,
})
}
}
4 changes: 2 additions & 2 deletions git-worktree/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ impl Capabilities {
.write(true)
.open(&src_path)?;
let link_path = root.join("__file_link");
if symlink::symlink_file(&src_path, &link_path).is_err() {
if crate::os::create_symlink(&src_path, &link_path).is_err() {
std::fs::remove_file(&src_path)?;
return Ok(false);
}

let res = std::fs::symlink_metadata(&link_path).map(|m| m.is_symlink());
let cleanup = std::fs::remove_file(&src_path);
symlink::remove_symlink_file(&link_path)
crate::os::remove_symlink(&link_path)
.or_else(|_| std::fs::remove_file(&link_path))
.and(cleanup)?;
res
Expand Down
245 changes: 0 additions & 245 deletions git-worktree/src/index.rs

This file was deleted.

Loading