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

Re: [PATCH v4] libgit-rs: add get_bool(), get_ulong(), and get_pathname() methods

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Oct 1, 2025, 10:15 UTC
Message-ID
<0cb55558-a48e-42ac-a80e-a24ee2be55ee@gmail.com>
In-Reply-To
<pull.1977.v4.git.1759221968318.gitgitgadget@gmail.com>

[I've cc'd brian to sanity check my suggestion for handling c_ulong in rust 1.63 which lacks std::ffi::c_ulong]

On 30/09/2025 09:46, ions via GitGitGadget wrote:
Show 7 quoted lines
> From: ionnss <zara.leonardo@gmail.com>
> 
> Expand ConfigSet API with three new configuration value parsers:
> 
> - get_bool(): Parse boolean values using git_configset_get_bool()
> - get_ulong(): Parse unsigned long values
> - get_pathname(): Parse file paths, returning PathBuf

I would be nice to explain in the commit message why we require paths to be utf-8 encoded. I've left one comment below, apart from that I think this looks good.

Show 18 quoted lines
> --- a/contrib/libgit-sys/src/lib.rs
> +++ b/contrib/libgit-sys/src/lib.rs
> @@ -1,7 +1,7 @@
>   use std::ffi::c_void;
>   
>   #[cfg(has_std__ffi__c_char)]
> -use std::ffi::{c_char, c_int};
> +use std::ffi::{c_char, c_int, c_ulong};
>   
>   #[cfg(not(has_std__ffi__c_char))]
>   #[allow(non_camel_case_types)]
> @@ -11,6 +11,10 @@ pub type c_char = i8;
>   #[allow(non_camel_case_types)]
>   pub type c_int = i32;
>   
> +#[cfg(not(has_std__ffi__c_char))]
> +#[allow(non_camel_case_types)]
> +pub type c_ulong = u64;

As I said before this wont work because C's ulong type is platform dependent so you cannot assume it 64 bits wide. Looking at the previous discussion[1] the reason we have these fallback definitions is because std::ffi::c_int etc were only added in rust 1.64 and we want to support rust 1.63 as that is the version shipped by Debian oldstable. I think it would be better to have a separate preparatory patch that changes the existing fallbacks to

#[cfg(not(has_std__ff__c_char))] use std::os::raw::{c_char, c_int};

and then this patch can add "c_ulong" to the list.
Thanks
Phillip

[1] https://lore.kernel.org/git/ZtivGeDZ_MZDEDB_@tapette.crustytoothpaste.net/

Previous: ions via GitGitGadgetNext: brian m. carlson
Message 20 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.