Skip to content

libgit2-sys: More types and functions #1181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

tecc
Copy link
Contributor

@tecc tecc commented Aug 18, 2025

This PR adds a few more types and functions to libgit2-sys.
The changes should be largely correct but I might've missed a c_int somewhere or accidentally forgotten to make it c_uint instead of c_int.

Full list of additions:

  • struct git_odb_stream (previously existed as an empty enum, exposed in git2/odb_backend.h line 196)
  • enum git_odb_stream_t (exposed in git2/odb_backend.h line 182)
  • struct git_config_backend_entry (exposed in git2/sys/config.h line 27)
  • struct git_config_iterator (previously existed as an empty enum, exposed in git2/sys/config.h line 49)
  • struct git_config_backend (exposed in git2/sys/config.h line 69)
  • const GIT_CONFIG_BACKEND_VERSION (exposed in git2/sys/config.h line 103)
  • struct git_config_backend_memory_options (exposed in git2/sys/config.h line 148)
  • const GIT_CONFIG_BACKEND_MEMORY_OPTIONS_VERSION (exposed in git2/sys/config.h line 165)
  • fn git_config_add_backend (exposed in git2/sys/config.h line 140)
  • fn git_config_backend_from_string (exposed in git2/sys/config.h line 181)
  • fn git_config_backend_from_values (exposed in git2/sys/config.h line 197)
  • fn git_config_init_backend (exposed in git2/sys/config.h line 116)
  • struct git_reference_iterator (previously existed as an empty enum, exposed in git2/sys/refdb_backend.h line 35)

Additionally, git_commit_nth_gen_ancestor's first argument was renamed to ancestor (see b7ce5e6 for more comments).

tecc added 4 commits August 17, 2025 19:12
Added type definition for struct `libgit2-sys::git_odb_stream`.
Previously incorrectly defined as an opaque enum.
See git2/odb_backend.h line 196.

Added type definition for enum `git_odb_stream_t`.
I believe it corresponds to the `mode` field of `git_odb_stream`, but
that's just a guess.
See git2/odb_backend.h line 182.
Added struct `git_config_backend_entry`.
See git2/sys/config.h line 27.

Added struct `git_config_iterator`.
Previously incorrectly defined as an empty enum.
See git2/sys/config.h line 49.

Added struct `git_config_backend`.
See git2/sys/config.h line 69.

Added constant `GIT_CONFIG_BACKEND_VERSION`.
See git2/sys/config.h line 103.

Added struct `git_config_backend_memory_options`.
See git2/sys/config.h line 148.

Added constant `GIT_CONFIG_BACKEND_MEMORY_OPTIONS_VERSION`.
See git2/sys/config.h line 165.

Added function `git_config_add_backend`.
See git2/sys/config.h line 140.

Added function `git_config_backend_from_string`.
See git2/sys/config.h line 181.

Added function `git_config_backend_from_values`.
See git2/sys/config.h line 197.

Added function `git_config_init_backend`.
See git2/sys/config.h line 116.
Added struct `git_reference_iterator`.
See git2/sys/refdb_backend.h line 35.
`git_commit_nth_gen_ancestor`'s first argument has been changed to
`ancestor` from the previous `commit` to bring it closer to the actual
definition (git2/commit.h line 282) and because the previous name is
also used for the second argument.
@rustbot rustbot added the S-waiting-on-review Status: Waiting on review label Aug 18, 2025
@tecc
Copy link
Contributor Author

tecc commented Aug 18, 2025

Note:
cargo run -p systest does not compile on my machine due to git_config_backend_from_string and git_config_backend_from_values being undefined for some strange reason.
It fixes itself if I run with vendored libgit2 through cargo run -p systest -F libgit2-sys/vendored.

(Rust 1.88.0, Linux 6.16.0-arch2-1, libgit2 1:1.9.1-1)

error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "-m64" "/tmp/rustcBD7n9T/symbols.o" "<42 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "-lall" "/workspace/Projects/External/git2-rs/target/debug/deps/{liblibgit2_sys-eb52aa40d0dbebb4.rlib,liblibssh2_sys-76ac9fe9b1a3f388.rlib,libopenssl_sys-ec23f226fa72e5dd.rlib,liblibz_sys-6cbf952f28c57b51.rlib,liblibc-9c9836c48cf0592d.rlib}.rlib" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,liballoc-*,librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgit2" "-lssl" "-lcrypto" "-lz" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustcBD7n9T/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/workspace/Projects/External/git2-rs/target/debug/build/systest-36c797f2b6060b4b/out" "-L" "/workspace/Projects/External/git2-rs/target/debug/build/libssh2-sys-80ed1024da02284e/out/build" "-L" "/usr/lib" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/workspace/Projects/External/git2-rs/target/debug/deps/systest-cf2dca308fe01cba" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: /usr/bin/ld: /workspace/Projects/External/git2-rs/target/debug/deps/systest-cf2dca308fe01cba.90itukmblqb2ym2uptzxjm5zt.0upzwjf.rcgu.o: in function `systest::fn_git_config_backend_from_string':
          /workspace/Projects/External/git2-rs/target/debug/build/systest-36c797f2b6060b4b/out/all.rs:57148:(.text._ZN7systest33fn_git_config_backend_from_string17h6d20f92171da1f4bE+0xd): undefined reference to `git_config_backend_from_string'
          /usr/bin/ld: /workspace/Projects/External/git2-rs/target/debug/deps/systest-cf2dca308fe01cba.90itukmblqb2ym2uptzxjm5zt.0upzwjf.rcgu.o: in function `systest::fn_git_config_backend_from_values':
          /workspace/Projects/External/git2-rs/target/debug/build/systest-36c797f2b6060b4b/out/all.rs:57165:(.text._ZN7systest33fn_git_config_backend_from_values17he1a54b59f09f1f0fE+0xd): undefined reference to `git_config_backend_from_values'
          /usr/bin/ld: /workspace/Projects/External/git2-rs/target/debug/build/systest-36c797f2b6060b4b/out/liball.a(3491e8b27b653a69-all.o): in function `__test_fn_git_config_backend_from_string':
          /workspace/Projects/External/git2-rs/target/debug/build/systest-36c797f2b6060b4b/out/all.c:22732:(.text.__test_fn_git_config_backend_from_string+0x7): undefined reference to `git_config_backend_from_string'
          /usr/bin/ld: /workspace/Projects/External/git2-rs/target/debug/build/systest-36c797f2b6060b4b/out/liball.a(3491e8b27b653a69-all.o): in function `__test_fn_git_config_backend_from_values':
          /workspace/Projects/External/git2-rs/target/debug/build/systest-36c797f2b6060b4b/out/all.c:22737:(.text.__test_fn_git_config_backend_from_values+0x7): undefined reference to `git_config_backend_from_values'
          collect2: error: ld returned 1 exit status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Waiting on review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants