History

Restyle just-changed and related code for clarity

Eliah Kagan committed 2 years ago

Commit 98b3d901 parent 9eaa0d92 files · +14 −16Browse files

Unified · Split

2 files
  1. gix-path/src/env/git.rs +7 −9
  2. gix-path/src/env/mod.rs +7 −7
gix-path/src/env/git.rs+7−9
@@ -1,15 +1,13 @@
1use std::path::PathBuf;1use std::ffi::OsString;
2use std::{2use std::path::{Path, PathBuf};
3 ffi::OsString,3use std::process::{Command, Stdio};
4 path::Path,
5 process::{Command, Stdio},
6};
7 4
8use bstr::{BStr, BString, ByteSlice};5use bstr::{BStr, BString, ByteSlice};
6use once_cell::sync::Lazy;
9 7
10/// Other places to find Git in.8/// Other places to find Git in.
11#[cfg(windows)]9#[cfg(windows)]
12pub(super) static ALTERNATIVE_LOCATIONS: once_cell::sync::Lazy<Vec<OsString>> = once_cell::sync::Lazy::new(|| {10pub(super) static ALTERNATIVE_LOCATIONS: Lazy<Vec<OsString>> = Lazy::new(|| {
13 vec![11 vec![
14 "C:/Program Files/Git/mingw64/bin".into(),12 "C:/Program Files/Git/mingw64/bin".into(),
15 "C:/Program Files (x86)/Git/mingw32/bin".into(),13 "C:/Program Files (x86)/Git/mingw32/bin".into(),
@@ -24,7 +22,7 @@ pub(super) static EXE_NAME: &str = "git.exe"; · 8 unmodified lines
24pub(super) static EXE_NAME: &str = "git";22pub(super) static EXE_NAME: &str = "git";
25 23
26/// Invoke the git executable in PATH to obtain the origin configuration, which is cached and returned.24/// Invoke the git executable in PATH to obtain the origin configuration, which is cached and returned.
27pub(super) static EXE_INFO: once_cell::sync::Lazy<Option<BString>> = once_cell::sync::Lazy::new(|| {25pub(super) static EXE_INFO: Lazy<Option<BString>> = Lazy::new(|| {
28 let git_cmd = |executable: PathBuf| {26 let git_cmd = |executable: PathBuf| {
29 let mut cmd = Command::new(executable);27 let mut cmd = Command::new(executable);
30 cmd.args(["config", "-l", "--show-origin"])28 cmd.args(["config", "-l", "--show-origin"])
@@ -55,7 +53,7 @@ pub(super) static EXE_INFO: once_cell::sync::Lazy<Option<BString>> = once_cell:: · 24 unmodified lines
55/// if no `git` executable was found or there were other errors during execution.53/// if no `git` executable was found or there were other errors during execution.
56pub(super) fn install_config_path() -> Option<&'static BStr> {54pub(super) fn install_config_path() -> Option<&'static BStr> {
57 let _span = gix_trace::detail!("gix_path::git::install_config_path()");55 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(|| {
59 // Shortcut: in Msys shells this variable is set which allows to deduce the installation directory,57 // Shortcut: in Msys shells this variable is set which allows to deduce the installation directory,
60 // so we can save the `git` invocation.58 // so we can save the `git` invocation.
61 #[cfg(windows)]59 #[cfg(windows)]
gix-path/src/env/mod.rs+7−7
@@ -1,10 +1,10 @@
1use std::{1use std::ffi::OsString;
2 ffi::OsString,2use std::path::{Path, PathBuf};
3 path::{Path, PathBuf},
4};
5 3
6use crate::env::git::EXE_NAME;
7use bstr::{BString, ByteSlice};4use bstr::{BString, ByteSlice};
5use once_cell::sync::Lazy;
6
7use crate::env::git::EXE_NAME;
8 8
9mod git;9mod git;
10 10
@@ -37,7 +37,7 @@ pub fn exe_invocation() -> &'static Path { · 26 unmodified lines
37 if cfg!(windows) {37 if cfg!(windows) {
38 /// The path to the Git executable as located in the `PATH` or in other locations that it's known to be installed to.38 /// The path to the Git executable as located in the `PATH` or in other locations that it's known to be installed to.
39 /// It's `None` if environment variables couldn't be read or if no executable could be found.39 /// 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(|| {
41 std::env::split_paths(&std::env::var_os("PATH")?)41 std::env::split_paths(&std::env::var_os("PATH")?)
42 .chain(git::ALTERNATIVE_LOCATIONS.iter().map(Into::into))42 .chain(git::ALTERNATIVE_LOCATIONS.iter().map(Into::into))
43 .find_map(|prefix| {43 .find_map(|prefix| {
@@ -98,7 +98,7 @@ pub fn xdg_config(file: &str, env_var: &mut dyn FnMut(&str) -> Option<OsString>) · 54 unmodified lines
98/// wasn't built with a well-known directory structure or environment.98/// wasn't built with a well-known directory structure or environment.
99pub fn system_prefix() -> Option<&'static Path> {99pub fn system_prefix() -> Option<&'static Path> {
100 if cfg!(windows) {100 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(|| {
102 if let Some(root) = std::env::var_os("EXEPATH").map(PathBuf::from) {102 if let Some(root) = std::env::var_os("EXEPATH").map(PathBuf::from) {
103 for candidate in ["mingw64", "mingw32"] {103 for candidate in ["mingw64", "mingw32"] {
104 let candidate = root.join(candidate);104 let candidate = root.join(candidate);