Skip to content

Commit

Permalink
adapt to changes in git-repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Nov 29, 2022
1 parent 0ce29a9 commit f1a4c8b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 4 additions & 2 deletions gitoxide-core/src/repository/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ pub fn list(
if format != OutputFormat::Human {
bail!("Only human output format is supported at the moment");
}
let mut repo = git::open_opts(repo.git_dir(), repo.open_options().clone().lossy_config(false))?;
repo.config_snapshot_mut().apply_cli_overrides(overrides.into_iter())?;
let repo = git::open_opts(
repo.git_dir(),
repo.open_options().clone().lossy_config(false).cli_overrides(overrides),
)?;
let config = repo.config_snapshot();
let config = config.plumbing();
if let Some(frontmatter) = config.frontmatter() {
Expand Down
14 changes: 11 additions & 3 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,22 @@ pub fn main() -> Result<()> {
mode,
Mode::StrictWithGitInstallConfig | Mode::LenientWithGitInstallConfig
);
mapping.full.permissions.config.git_binary = git_installation;
mapping.reduced.permissions.config.git_binary = git_installation;
let to_match_settings = |mut opts: git::open::Options| {
opts.permissions.config.git_binary = git_installation;
if config.is_empty() {
opts
} else {
opts.cli_overrides(config.clone())
}
};
mapping.full.modify(to_match_settings);
mapping.reduced.modify(to_match_settings);
let mut repo = git::ThreadSafeRepository::discover_opts(repository, Default::default(), mapping)
.map(git::Repository::from)
.map(|r| r.apply_environment())?;
if !config.is_empty() {
repo.config_snapshot_mut()
.apply_cli_overrides(config.iter())
.append_config(config.iter(), git::config::Source::Cli)
.context("Unable to parse command-line configuration")?;
}
Ok(repo)
Expand Down

0 comments on commit f1a4c8b

Please sign in to comment.