diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:19 +0000 |
commit | a0b8f38ab54ac451646aa00cd5e91b6c76f22a84 (patch) | |
tree | fc451898ccaf445814e26b46664d78702178101d /vendor/gix-discover/src | |
parent | Adding debian version 1.71.1+dfsg1-2. (diff) | |
download | rustc-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')
-rw-r--r-- | vendor/gix-discover/src/is.rs | 11 | ||||
-rw-r--r-- | vendor/gix-discover/src/upwards/mod.rs | 30 | ||||
-rw-r--r-- | vendor/gix-discover/src/upwards/types.rs | 2 |
3 files changed, 25 insertions, 18 deletions
diff --git a/vendor/gix-discover/src/is.rs b/vendor/gix-discover/src/is.rs index e5d554452..ec504a5ee 100644 --- a/vendor/gix-discover/src/is.rs +++ b/vendor/gix-discover/src/is.rs @@ -143,9 +143,16 @@ pub(crate) fn git_with_metadata( git_dir: dot_git.into_owned(), }, Kind::MaybeRepo => { - if bare(git_dir) || git_dir.extension() == Some(OsStr::new("git")) { + let conformed_git_dir = if git_dir == Path::new(".") { + gix_path::realpath(git_dir) + .map(Cow::Owned) + .unwrap_or(Cow::Borrowed(git_dir)) + } else { + Cow::Borrowed(git_dir) + }; + if bare(conformed_git_dir.as_ref()) || conformed_git_dir.extension() == Some(OsStr::new("git")) { crate::repository::Kind::Bare - } else if submodule_git_dir(git_dir) { + } else if submodule_git_dir(conformed_git_dir.as_ref()) { crate::repository::Kind::SubmoduleGitDir } else { crate::repository::Kind::WorkTree { linked_git_dir: None } 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() }); diff --git a/vendor/gix-discover/src/upwards/types.rs b/vendor/gix-discover/src/upwards/types.rs index d8fb19d49..370a3ae98 100644 --- a/vendor/gix-discover/src/upwards/types.rs +++ b/vendor/gix-discover/src/upwards/types.rs @@ -1,6 +1,6 @@ use std::{env, ffi::OsStr, path::PathBuf}; -/// The error returned by [gix_discover::upwards()][crate::upwards()]. +/// The error returned by [`gix_discover::upwards()`][crate::upwards()]. #[derive(Debug, thiserror::Error)] #[allow(missing_docs)] pub enum Error { |