Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Nov 15, 2022
1 parent e055617 commit b5ca8a6
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions git-repository/src/repository/config/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,13 @@ impl crate::Repository {
lenient: bool,
key: &'static str,
kind: &'static str,
mut filter: fn(&git_config::file::Metadata) -> bool,
filter: fn(&git_config::file::Metadata) -> bool,
default: T,
) -> Result<T, crate::config::transport::Error>
where
T: TryFrom<i64>,
{
let git_config::parse::Key {
section_name,
value_name,
..
} = git_config::parse::key(key).expect("valid key statically known");
let integer = check_lenient(
config
.integer_filter(section_name, None, value_name, &mut filter)
.transpose()
.map_err(|err| crate::config::transport::Error::ConfigValue { source: err, key }),
lenient,
)?
.unwrap_or_default();
check_lenient_default(
integer
.try_into()
.map_err(|_| crate::config::transport::Error::InvalidInteger {
actual: integer,
key,
kind,
}),
lenient,
|| default,
)
Ok(integer_opt(config, lenient, key, kind, filter)?.unwrap_or(default))
}
fn integer_opt<T>(
config: &git_config::File<'static>,
Expand Down

0 comments on commit b5ca8a6

Please sign in to comment.