Skip to content

Commit 2c6dcb2

Browse files
committed
Further refactor rules loop in locations_under_program_files
This consolidates the check that the value is present with the check that it is an absolute path, and simplifies the comment.
1 parent d06b89d commit 2c6dcb2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

gix-path/src/env/git/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,10 @@ where
6262
let mut locations = vec![];
6363

6464
for (varname, suffixes) in rules {
65-
let Some(program_files_dir) = var_os_func(varname).map(PathBuf::from) else { continue };
66-
if program_files_dir.is_relative() {
67-
// This shouldn't happen, but if it does then don't use the path. This is mainly in
68-
// case we are accidentally invoked with the environment variable set but empty.
65+
let Some(program_files_dir) = var_os_func(varname).map(PathBuf::from).filter(|p| p.is_absolute()) else {
66+
// The environment variable is unset or somehow not an absolute path (e.g. an empty string).
6967
continue;
70-
}
68+
};
7169
for suffix in suffixes {
7270
let location = program_files_dir.join(suffix);
7371
if !locations.contains(&location) {

0 commit comments

Comments
 (0)