Skip to content

Commit

Permalink
Merge branch 'dirwalk'
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jan 17, 2024
2 parents 4138902 + f6e4bba commit 5d176fc
Show file tree
Hide file tree
Showing 56 changed files with 1,154 additions and 111 deletions.
7 changes: 6 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions gix-discover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ gix-sec = { version = "^0.10.3", path = "../gix-sec" }
gix-path = { version = "^0.10.3", path = "../gix-path" }
gix-ref = { version = "^0.40.1", path = "../gix-ref" }
gix-hash = { version = "^0.14.1", path = "../gix-hash" }
gix-fs = { version = "^0.9.1", path = "../gix-fs" }

bstr = { version = "1.3.0", default-features = false, features = ["std", "unicode"] }
thiserror = "1.0.26"
Expand Down
1 change: 1 addition & 0 deletions gix-discover/src/is.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ pub(crate) fn git_with_metadata(
dot_git.as_ref().into(),
gix_ref::store::WriteReflog::Normal,
object_hash_should_not_matter_here,
false,
);
let head = refs.find_loose("HEAD")?;
if head.name.as_bstr() != "HEAD" {
Expand Down
10 changes: 9 additions & 1 deletion gix-discover/src/upwards/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ pub(crate) mod function {
// us the parent directory. (`Path::parent` just strips off the last
// path component, which means it will not do what you expect when
// working with paths paths that contain '..'.)
let cwd = current_dir.map_or_else(|| std::env::current_dir().map(Cow::Owned), |cwd| Ok(Cow::Borrowed(cwd)))?;
let cwd = current_dir.map_or_else(
|| {
// The paths we return are relevant to the repository, but at this time it's impossible to know
// what `core.precomposeUnicode` is going to be. Hence the one using these paths will have to
// transform the paths as needed, because we can't. `false` means to leave the obtained path as is.
gix_fs::current_dir(false).map(Cow::Owned)
},
|cwd| Ok(Cow::Borrowed(cwd)),
)?;
#[cfg(windows)]
let directory = dunce::simplified(directory);
let dir = gix_path::normalize(directory.into(), cwd.as_ref()).ok_or_else(|| Error::InvalidInput {
Expand Down
4 changes: 4 additions & 0 deletions gix-discover/src/upwards/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ pub struct Options<'a> {
/// that this is merely an optimization for those who discover a lot of repositories in the same process.
///
/// If unset, the current working directory will be obtained automatically.
/// Note that the path here might or might not contained decomposed unicode, which may end up in a path
/// relevant us, like the git-dir or the worktree-dir. However, when opening the repository, it will
/// change decomposed unicode to precomposed unicode based on the value of `core.precomposeUnicode`, and we
/// don't have to deal with that value here just yet.
pub current_dir: Option<&'a std::path::Path>,
}

Expand Down
10 changes: 8 additions & 2 deletions gix-features/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ progress-unit-human-numbers = ["prodash?/unit-human"]
progress-unit-bytes = ["dep:bytesize", "prodash?/unit-bytes"]

## If set, walkdir iterators will be multi-threaded.
fs-walkdir-parallel = [ "dep:jwalk" ]
fs-walkdir-parallel = [ "dep:jwalk", "dep:gix-utils" ]

## Provide utilities suitable for working with the `std::fs::read_dir()`.
fs-read-dir = ["dep:gix-utils"]

## Implement `tracing` with `tracing-core`, which provides applications with valuable performance details if they opt-in to it.
##
Expand All @@ -47,7 +50,7 @@ parallel = ["dep:crossbeam-channel",
once_cell = ["dep:once_cell"]
## Makes facilities of the `walkdir` crate partially available.
## In conjunction with the **parallel** feature, directory walking will be parallel instead behind a compatible interface.
walkdir = ["dep:walkdir"]
walkdir = ["dep:walkdir", "dep:gix-utils"]
#* an in-memory unidirectional pipe using `bytes` as efficient transfer mechanism.
io-pipe = ["dep:bytes"]
## provide a proven and fast `crc32` implementation.
Expand Down Expand Up @@ -117,6 +120,9 @@ required-features = ["io-pipe"]
gix-hash = { version = "^0.14.1", path = "../gix-hash" }
gix-trace = { version = "^0.1.7", path = "../gix-trace" }

# for walkdir
gix-utils = { version = "^0.1.8", path = "../gix-utils", optional = true }

# 'parallel' feature
crossbeam-channel = { version = "0.5.0", optional = true }
parking_lot = { version = "0.12.0", default-features = false, optional = true }
Expand Down

0 comments on commit 5d176fc

Please sign in to comment.