diff --git a/cargo-smart-release/src/command/release/git.rs b/cargo-smart-release/src/command/release/git.rs index 0478c0d288..91b5825a2b 100644 --- a/cargo-smart-release/src/command/release/git.rs +++ b/cargo-smart-release/src/command/release/git.rs @@ -100,7 +100,9 @@ pub fn push_tags_and_head( .into_remote(git::remote::Direction::Push) .ok_or_else(|| anyhow!("Cannot push in uninitialized repo"))?? .name() - .expect("configured remotes have a name"), + .expect("configured remotes have a name") + .as_bstr() + .to_string(), ) .arg("HEAD"); for tag_name in tag_names { diff --git a/gitoxide-core/src/organize.rs b/gitoxide-core/src/organize.rs index 61fa2f9e12..22dbbabd74 100644 --- a/gitoxide-core/src/organize.rs +++ b/gitoxide-core/src/organize.rs @@ -104,7 +104,7 @@ fn find_origin_remote(repo: &Path) -> anyhow::Result> { let config = git::config::File::from_path_no_includes(non_bare.as_path(), local) .or_else(|_| git::config::File::from_path_no_includes(repo.join("config").as_path(), local))?; Ok(config - .string("remote", Some("origin"), "url") + .string_by_key("remote.origin.url") .map(|url| git_url::Url::from_bytes(url.as_ref())) .transpose()?) } diff --git a/gitoxide-core/src/repository/config.rs b/gitoxide-core/src/repository/config.rs index 8dc4680ee2..11bfb43fe4 100644 --- a/gitoxide-core/src/repository/config.rs +++ b/gitoxide-core/src/repository/config.rs @@ -1,12 +1,12 @@ use anyhow::{bail, Result}; +use git::bstr::{BStr, BString}; use git_repository as git; -use git_repository::bstr::BString; use crate::OutputFormat; pub fn list( repo: git::Repository, - filters: Vec, + filters: Vec, overrides: Vec, format: OutputFormat, mut out: impl std::io::Write, @@ -52,18 +52,18 @@ pub fn list( struct Filter { name: String, - subsection: Option, + subsection: Option, } impl Filter { - fn new(input: String) -> Self { - match git::config::parse::key(&input) { + fn new(input: BString) -> Self { + match git::config::parse::key(<_ as AsRef>::as_ref(&input)) { Some(key) => Filter { name: key.section_name.into(), subsection: key.subsection_name.map(ToOwned::to_owned), }, None => Filter { - name: input, + name: input.to_string(), subsection: None, }, } @@ -77,7 +77,7 @@ impl Filter { } match (self.subsection.as_deref(), section.header().subsection_name()) { (Some(filter), Some(name)) => { - if !git::glob::wildmatch(filter.as_bytes().into(), name, ignore_case) { + if !git::glob::wildmatch(filter.as_slice().into(), name, ignore_case) { return false; } } diff --git a/src/plumbing/options/mod.rs b/src/plumbing/options/mod.rs index 7e4ace87e7..c7cfc1b050 100644 --- a/src/plumbing/options/mod.rs +++ b/src/plumbing/options/mod.rs @@ -106,6 +106,9 @@ pub enum Subcommands { } pub mod config { + use git::bstr::BString; + use git_repository as git; + /// Print all entries in a configuration file or access other sub-commands #[derive(Debug, clap::Parser)] #[clap(subcommand_required(false))] @@ -114,7 +117,8 @@ pub mod config { /// /// Typical filters are `branch` or `remote.origin` or `remote.or*` - git-style globs are supported /// and comparisons are case-insensitive. - pub filter: Vec, + #[clap(parse(try_from_os_str = git::env::os_str_to_bstring))] + pub filter: Vec, } }