Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: git/git
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3f3fd0f34617bc9901d5cfaca9a5b5a12eec8cf4
Choose a base ref
...
head repository: git/git
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 65c10aa8d5000e0ecab34a9652056f0520fe51ed
Choose a head ref
  • 4 commits
  • 24 files changed
  • 3 contributors

Commits on Jan 28, 2025

  1. common-main: split init and exit code into new files

    Currently, object files in libgit.a reference common_exit(), which is
    contained in common-main.o. However, common-main.o also includes main(),
    which references cmd_main() in git.o, which in turn depends on all the
    builtin/*.o objects.
    
    We would like to allow external users to link libgit.a without needing
    to include so many extra objects. Enable this by splitting common_exit()
    and check_bug_if_BUG() into a new file common-exit.c, and add
    common-exit.o to LIB_OBJS so that these are included in libgit.a.
    
    This split has previously been proposed ([1], [2]) to support fuzz tests
    and unit tests by avoiding conflicting definitions for main(). However,
    both of those issues were resolved by other methods of avoiding symbol
    conflicts. Now we are trying to make libgit.a more self-contained, so
    hopefully we can revisit this approach.
    
    Additionally, move the initialization code out of main() into a new
    init_git() function in its own file. Include this in libgit.a as well,
    so that external users can share our setup code without calling our
    main().
    
    [1] https://lore.kernel.org/git/[email protected]/
    [2] https://lore.kernel.org/git/[email protected]/
    
    Signed-off-by: Josh Steadmon <[email protected]>
    Signed-off-by: Junio C Hamano <[email protected]>
    steadmon authored and gitster committed Jan 28, 2025
    Configuration menu
    Copy the full SHA
    3f8f2ab View commit details
    Browse the repository at this point in the history
  2. libgit-sys: introduce Rust wrapper for libgit.a

    Introduce libgit-sys, a Rust wrapper crate that allows Rust code to call
    functions in libgit.a. This initial patch defines build rules and an
    interface that exposes user agent string getter functions as a proof of
    concept. This library can be tested with `cargo test`. In later commits,
    a higher-level library containing a more Rust-friendly interface will be
    added at `contrib/libgit-rs`.
    
    Symbols in libgit can collide with symbols from other libraries such as
    libgit2. We avoid this by first exposing library symbols in
    public_symbol_export.[ch]. These symbols are prepended with "libgit_" to
    avoid collisions and set to visible using a visibility pragma. In
    build.rs, Rust builds contrib/libgit-rs/libgit-sys/libgitpub.a, which also
    contains libgit.a and other dependent libraries, with
    -fvisibility=hidden to hide all symbols within those libraries that
    haven't been exposed with a visibility pragma.
    
    Co-authored-by: Kyle Lippincott <[email protected]>
    Co-authored-by: Calvin Wan <[email protected]>
    Signed-off-by: Calvin Wan <[email protected]>
    Signed-off-by: Kyle Lippincott <[email protected]>
    Signed-off-by: Josh Steadmon <[email protected]>
    Signed-off-by: Junio C Hamano <[email protected]>
    3 people authored and gitster committed Jan 28, 2025
    Configuration menu
    Copy the full SHA
    e7f8bf1 View commit details
    Browse the repository at this point in the history

Commits on Jan 29, 2025

  1. libgit-sys: also export some config_set functions

    In preparation for implementing a higher-level Rust API for accessing
    Git configs, export some of the upstream configset API via libgitpub and
    libgit-sys. Since this will be exercised as part of the higher-level API
    in the next commit, no tests have been added for libgit-sys.
    
    While we're at it, add git_configset_alloc() and git_configset_free()
    functions in libgitpub so that callers can manage config_set structs on
    the heap. This also allows non-C external consumers to treat config_sets
    as opaque structs.
    
    Co-authored-by: Calvin Wan <[email protected]>
    Signed-off-by: Calvin Wan <[email protected]>
    Signed-off-by: Josh Steadmon <[email protected]>
    Signed-off-by: Junio C Hamano <[email protected]>
    2 people authored and gitster committed Jan 29, 2025
    Configuration menu
    Copy the full SHA
    d76eb0d View commit details
    Browse the repository at this point in the history
  2. libgit: add higher-level libgit crate

    The C functions exported by libgit-sys do not provide an idiomatic Rust
    interface. To make it easier to use these functions via Rust, add a
    higher-level "libgit" crate, that wraps the lower-level configset API
    with an interface that is more Rust-y.
    
    This combination of $X and $X-sys crates is a common pattern for FFI in
    Rust, as documented in "The Cargo Book" [1].
    
    [1] https://doc.rust-lang.org/cargo/reference/build-scripts.html#-sys-packages
    
    Co-authored-by: Josh Steadmon <[email protected]>
    Signed-off-by: Josh Steadmon <[email protected]>
    Signed-off-by: Calvin Wan <[email protected]>
    Signed-off-by: Junio C Hamano <[email protected]>
    2 people authored and gitster committed Jan 29, 2025
    Configuration menu
    Copy the full SHA
    65c10aa View commit details
    Browse the repository at this point in the history
Loading