Skip to content

Commit 98b3d90

Browse files
committed
Restyle just-changed and related code for clarity
1 parent 9eaa0d9 commit 98b3d90

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

gix-path/src/env/git.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
use std::path::PathBuf;
2-
use std::{
3-
ffi::OsString,
4-
path::Path,
5-
process::{Command, Stdio},
6-
};
1+
use std::ffi::OsString;
2+
use std::path::{Path, PathBuf};
3+
use std::process::{Command, Stdio};
74

85
use bstr::{BStr, BString, ByteSlice};
6+
use once_cell::sync::Lazy;
97

108
/// Other places to find Git in.
119
#[cfg(windows)]
12-
pub(super) static ALTERNATIVE_LOCATIONS: once_cell::sync::Lazy<Vec<OsString>> = once_cell::sync::Lazy::new(|| {
10+
pub(super) static ALTERNATIVE_LOCATIONS: Lazy<Vec<OsString>> = Lazy::new(|| {
1311
vec![
1412
"C:/Program Files/Git/mingw64/bin".into(),
1513
"C:/Program Files (x86)/Git/mingw32/bin".into(),
@@ -24,7 +22,7 @@ pub(super) static EXE_NAME: &str = "git.exe";
2422
pub(super) static EXE_NAME: &str = "git";
2523

2624
/// Invoke the git executable in PATH to obtain the origin configuration, which is cached and returned.
27-
pub(super) static EXE_INFO: once_cell::sync::Lazy<Option<BString>> = once_cell::sync::Lazy::new(|| {
25+
pub(super) static EXE_INFO: Lazy<Option<BString>> = Lazy::new(|| {
2826
let git_cmd = |executable: PathBuf| {
2927
let mut cmd = Command::new(executable);
3028
cmd.args(["config", "-l", "--show-origin"])
@@ -55,7 +53,7 @@ pub(super) static EXE_INFO: once_cell::sync::Lazy<Option<BString>> = once_cell::
5553
/// if no `git` executable was found or there were other errors during execution.
5654
pub(super) fn install_config_path() -> Option<&'static BStr> {
5755
let _span = gix_trace::detail!("gix_path::git::install_config_path()");
58-
static PATH: once_cell::sync::Lazy<Option<BString>> = once_cell::sync::Lazy::new(|| {
56+
static PATH: Lazy<Option<BString>> = Lazy::new(|| {
5957
// Shortcut: in Msys shells this variable is set which allows to deduce the installation directory,
6058
// so we can save the `git` invocation.
6159
#[cfg(windows)]

gix-path/src/env/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use std::{
2-
ffi::OsString,
3-
path::{Path, PathBuf},
4-
};
1+
use std::ffi::OsString;
2+
use std::path::{Path, PathBuf};
53

6-
use crate::env::git::EXE_NAME;
74
use bstr::{BString, ByteSlice};
5+
use once_cell::sync::Lazy;
6+
7+
use crate::env::git::EXE_NAME;
88

99
mod git;
1010

@@ -37,7 +37,7 @@ pub fn exe_invocation() -> &'static Path {
3737
if cfg!(windows) {
3838
/// The path to the Git executable as located in the `PATH` or in other locations that it's known to be installed to.
3939
/// It's `None` if environment variables couldn't be read or if no executable could be found.
40-
static EXECUTABLE_PATH: once_cell::sync::Lazy<Option<PathBuf>> = once_cell::sync::Lazy::new(|| {
40+
static EXECUTABLE_PATH: Lazy<Option<PathBuf>> = Lazy::new(|| {
4141
std::env::split_paths(&std::env::var_os("PATH")?)
4242
.chain(git::ALTERNATIVE_LOCATIONS.iter().map(Into::into))
4343
.find_map(|prefix| {
@@ -98,7 +98,7 @@ pub fn xdg_config(file: &str, env_var: &mut dyn FnMut(&str) -> Option<OsString>)
9898
/// wasn't built with a well-known directory structure or environment.
9999
pub fn system_prefix() -> Option<&'static Path> {
100100
if cfg!(windows) {
101-
static PREFIX: once_cell::sync::Lazy<Option<PathBuf>> = once_cell::sync::Lazy::new(|| {
101+
static PREFIX: Lazy<Option<PathBuf>> = Lazy::new(|| {
102102
if let Some(root) = std::env::var_os("EXEPATH").map(PathBuf::from) {
103103
for candidate in ["mingw64", "mingw32"] {
104104
let candidate = root.join(candidate);

0 commit comments

Comments
 (0)