git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] libgit-rs: add get_bool() method to ConfigSet

From
Chris Torek <chris.torek@gmail.com>
Date
Sep 26, 2025, 06:43 UTC
Message-ID
<CAPx1Gvcj-mVfXFMpLuvda_s89e_3jwdjMMdywEOya16yStXvFw@mail.gmail.com>
In-Reply-To
<a5904a2ac00ea6de142344272b45f6b4697b4f98.1758800669.git.gitgitgadget@gmail.com>
A bit minor, and I'm not a real Rust programmer, but:

On Thu, Sep 25, 2025 at 4:44 AM ionnss via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 27 quoted lines
>
> From: ionnss <zara.leonardo@gmail.com>
>
> Add support for parsing boolean configuration values in the Rust
> ConfigSet API. The method follows Git's standard boolean parsing
> rules, accepting true/yes/on/1 as true and false/no/off/0 as false.
>
> The implementation reuses the existing get_string() infrastructure
> and adds case-insensitive boolean parsing logic.
>
> Signed-off-by: ionnss <zara.leonardo@gmail.com>
> ---
>  contrib/libgit-rs/src/config.rs    | 24 ++++++++++++++++++++++++
>  contrib/libgit-rs/testdata/config3 |  2 ++
>  2 files changed, 26 insertions(+)
>
> diff --git a/contrib/libgit-rs/src/config.rs b/contrib/libgit-rs/src/config.rs
> index 6bf04845c8..3f4a32c72d 100644
> --- a/contrib/libgit-rs/src/config.rs
> +++ b/contrib/libgit-rs/src/config.rs
> @@ -68,6 +68,26 @@ impl ConfigSet {
>              Some(owned_str)
>          }
>      }
> +
> +    pub fn get_bool(&mut self, key: &str) -> Option<bool> {
> +        let key = CString::new(key).expect("Couldn't convert key to CString");

The string argument for `.expect` should be phrased in a more positive manner in terms of what is expected, since failure will cause a panic. So, something like:

    let key = CString::new(key).expect("boolean key should be valid CString");
which would produce, e.g.,
    panic: boolean key should be valid CString: ... details of key ...
A similar rule applies to the later `.expect`.
Chris
Previous: ionnss via GitGitGadgetNext: Phillip Wood
Message 4 of 22 in “libgit-rs: add get_bool() method to ConfigSet”
  1. 0/2 libgit-rs: add get_bool() method to ConfigSetions via GitGitGadget, Sep 25, 2025
  2. 1/2 po: fix escaped underscores in README.mdionnss via GitGitGadget, Sep 25, 2025
  3. 2/2 libgit-rs: add get_bool() method to ConfigSetionnss via GitGitGadget, Sep 25, 2025
  4. Chris TorekSep 26, 2025
  5. Phillip WoodSep 26, 2025
  6. Junio C HamanoSep 26, 2025
  7. 0/3 libgit-rs: add get_bool() method to ConfigSetions via GitGitGadget, Sep 27, 2025
  8. 1/3 po: fix escaped underscores in README.mdionnss via GitGitGadget, Sep 27, 2025
  9. 2/3 libgit-rs: add get_bool() method to ConfigSetionnss via GitGitGadget, Sep 27, 2025
  10. 3/3 libgit-rs: address review feedback for get_bool()ionnss via GitGitGadget, Sep 27, 2025
  11. Junio C HamanoSep 27, 2025
  12. 0/3 libgit-rs: add get_bool() method to ConfigSetions via GitGitGadget, Sep 27, 2025
  13. 1/3 po: fix escaped underscores in README.mdionnss via GitGitGadget, Sep 27, 2025
  14. Phillip WoodSep 29, 2025
  15. 2/3 libgit-rs: add get_bool() method to ConfigSetionnss via GitGitGadget, Sep 27, 2025
  16. Phillip WoodSep 29, 2025
  17. 3/3 libgit-rs: add get_ulong() and get_pathname() methodsionnss via GitGitGadget, Sep 27, 2025
  18. Phillip WoodSep 29, 2025
  19. libgit-rs: add get_bool(), get_ulong(), and get_pathname() methodsions via GitGitGadget, Sep 30, 2025
  20. Phillip WoodOct 1, 2025
  21. brian m. carlsonOct 6, 2025
  22. Phillip WoodOct 8, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.