Skip to content

Commit dea1746

Browse files
committed
Update/refine comments and do some minor cleanup
* Update a couple of preexisting doc comments for clarity and to avoid implying that the `git` that is found is *always* from PATH, since it may be from an alternative location. * Correct the claim about `EXEPATH` and MSYS, as it is present in Git Bash but not other MSYS environments. (This remains something of an oversimplification, since it is also present in Git Cmd environments, but that shell environment is decreasingly used and probably not essential information for that explanatory comment.) * Hedge claim about what `EXEPATH` gives us, because some ways of running Git Bash cause it to point to the `bin` directory rather than the installation directory, in which case our shortcut use of it will fail. This seems to happen when Git Bash is run by means other than the `git-bash.exe` graphical launcher, even if an attempt is made to start the shell the same way. Traditionally such approaches to running Git Bash may not have been overtly supported by Git for Windows. But the difference seems to be preserved even when the non-`git-bash.exe` way Git Bash is run is through a Windows Terminal profile added by the Git for Windows installer (which recently added that feature). * Remove a couple spurious semicolons I had accidentally added. * Remove unnecessary qualification for an imported name.
1 parent 76e3b28 commit dea1746

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

gix-path/src/env/git.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ where
6161
// This shouldn't happen, but if it does then don't use the path. This is mainly in
6262
// case we are accidentally invoked with the environment variable set but empty.
6363
continue;
64-
};
64+
}
6565
let location = pf.join(suffix);
6666
if !locations.contains(&location) {
6767
locations.push(location);
@@ -77,7 +77,9 @@ pub(super) static EXE_NAME: &str = "git.exe";
7777
#[cfg(not(windows))]
7878
pub(super) static EXE_NAME: &str = "git";
7979

80-
/// Invoke the git executable in PATH to obtain the origin configuration, which is cached and returned.
80+
/// Invoke the git executable to obtain the origin configuration, which is cached and returned.
81+
///
82+
/// The git executable is the one found in PATH or an alternative location.
8183
pub(super) static EXE_INFO: Lazy<Option<BString>> = Lazy::new(|| {
8284
let git_cmd = |executable: PathBuf| {
8385
let mut cmd = Command::new(executable);
@@ -105,15 +107,18 @@ pub(super) static EXE_INFO: Lazy<Option<BString>> = Lazy::new(|| {
105107
first_file_from_config_with_origin(cmd_output.as_slice().into()).map(ToOwned::to_owned)
106108
});
107109

108-
/// Returns the file that contains git configuration coming with the installation of the `git` file in the current `PATH`, or `None`
109-
/// if no `git` executable was found or there were other errors during execution.
110+
/// Try to find the file that contains git configuration coming with the git installation.
111+
///
112+
/// This returns the configuration associated with the `git` executable found in the current `PATH`
113+
/// or an alternative location, or `None` if no `git` executable was found or there were other
114+
/// errors during execution.
110115
pub(super) fn install_config_path() -> Option<&'static BStr> {
111116
let _span = gix_trace::detail!("gix_path::git::install_config_path()");
112117
static PATH: Lazy<Option<BString>> = Lazy::new(|| {
113-
// Shortcut: in Msys shells this variable is set which allows to deduce the installation directory,
114-
// so we can save the `git` invocation.
118+
// Shortcut: Specifically in Git for Windows 'Git Bash' shells, this variable is set. It
119+
// may let us deduce the installation directory, so we can save the `git` invocation.
115120
#[cfg(windows)]
116-
if let Some(mut exec_path) = std::env::var_os("EXEPATH").map(std::path::PathBuf::from) {
121+
if let Some(mut exec_path) = std::env::var_os("EXEPATH").map(PathBuf::from) {
117122
exec_path.push("etc");
118123
exec_path.push("gitconfig");
119124
return crate::os_string_into_bstring(exec_path.into()).ok();
@@ -197,7 +202,7 @@ mod tests {
197202
_ => None,
198203
}
199204
}
200-
};
205+
}
201206
}
202207

203208
macro_rules! locations_from {

0 commit comments

Comments
 (0)