summaryrefslogtreecommitdiffstats
path: root/vendor/gix-discover/src/upwards/mod.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
commita0b8f38ab54ac451646aa00cd5e91b6c76f22a84 (patch)
treefc451898ccaf445814e26b46664d78702178101d /vendor/gix-discover/src/upwards/mod.rs
parentAdding debian version 1.71.1+dfsg1-2. (diff)
downloadrustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.tar.xz
rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-discover/src/upwards/mod.rs')
-rw-r--r--vendor/gix-discover/src/upwards/mod.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/vendor/gix-discover/src/upwards/mod.rs b/vendor/gix-discover/src/upwards/mod.rs
index 87e6a18b4..c3d73ad32 100644
--- a/vendor/gix-discover/src/upwards/mod.rs
+++ b/vendor/gix-discover/src/upwards/mod.rs
@@ -4,8 +4,7 @@ pub use types::{Error, Options};
mod util;
pub(crate) mod function {
- use std::ffi::OsStr;
- use std::{borrow::Cow, path::Path};
+ use std::{borrow::Cow, ffi::OsStr, path::Path};
use gix_sec::Trust;
@@ -40,9 +39,7 @@ 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(|cwd| Ok(Cow::Borrowed(cwd)))
- .unwrap_or_else(|| std::env::current_dir().map(Cow::Owned))?;
+ let cwd = current_dir.map_or_else(|| std::env::current_dir().map(Cow::Owned), |cwd| Ok(Cow::Borrowed(cwd)))?;
let directory = directory.as_ref();
#[cfg(windows)]
let directory = dunce::simplified(directory);
@@ -95,15 +92,18 @@ pub(crate) mod function {
#[cfg(unix)]
if current_height != 0 && !cross_fs {
- let metadata = cursor_metadata.take().map(Ok).unwrap_or_else(|| {
- if cursor.as_os_str().is_empty() {
- Path::new(".")
- } else {
- cursor.as_ref()
- }
- .metadata()
- .map_err(|_| Error::InaccessibleDirectory { path: cursor.clone() })
- })?;
+ let metadata = cursor_metadata.take().map_or_else(
+ || {
+ if cursor.as_os_str().is_empty() {
+ Path::new(".")
+ } else {
+ cursor.as_ref()
+ }
+ .metadata()
+ .map_err(|_| Error::InaccessibleDirectory { path: cursor.clone() })
+ },
+ Ok,
+ )?;
if device_id(&metadata) != initial_device {
return Err(Error::NoGitRepositoryWithinFs {
@@ -169,7 +169,7 @@ pub(crate) mod function {
if dir_made_absolute
|| matches!(
cursor.components().next(),
- Some(std::path::Component::RootDir) | Some(std::path::Component::Prefix(_))
+ Some(std::path::Component::RootDir | std::path::Component::Prefix(_))
)
{
break Err(Error::NoGitRepository { path: dir.into_owned() });