#git-repository #http-transport #libgit2 #libcurl #http-request #git-clone #git2

git2-curl

Backend for an HTTP transport in libgit2 powered by libcurl. Intended to be used with the git2 crate

29 releases (19 breaking)

0.20.0 Jun 14, 2024
0.19.0 Aug 28, 2023
0.18.0 Apr 2, 2023
0.17.0 Jan 10, 2023
0.2.2 Mar 25, 2015

#211 in Network programming

Download history 35258/week @ 2024-07-21 35640/week @ 2024-07-28 33067/week @ 2024-08-04 34336/week @ 2024-08-11 32355/week @ 2024-08-18 32358/week @ 2024-08-25 37835/week @ 2024-09-01 38939/week @ 2024-09-08 33881/week @ 2024-09-15 38238/week @ 2024-09-22 39015/week @ 2024-09-29 38892/week @ 2024-10-06 40355/week @ 2024-10-13 40246/week @ 2024-10-20 41093/week @ 2024-10-27 40094/week @ 2024-11-03

165,849 downloads per month
Used in 143 crates (6 directly)

MIT/Apache

1MB
19K SLoC

git2-rs

Documentation

libgit2 bindings for Rust.

[dependencies]
git2 = "0.19.0"

Rust version requirements

git2-rs works with stable Rust, and typically works with the most recent prior stable release as well.

Version of libgit2

Currently this library requires libgit2 1.8.1 (or newer patch versions). The source for libgit2 is included in the libgit2-sys crate so there's no need to pre-install the libgit2 library, the libgit2-sys crate will figure that and/or build that for you. On the other hand, if an appropriate version of libgit2 is present, git2 will attempt to dynamically link it.

To be more precise, the vendored libgit2 is linked statically if two conditions both hold:

  • The enviornment variable LIBGIT2_NO_VENDOR=1 is not set
  • and either a) The Cargo feature vendored-libgit2 is set or b) an appropriate version of libgit2 cannot be found on the system.

In particular, note that the environment variable overrides the Cargo feature.

Building git2-rs

$ git clone https://github.com/rust-lang/git2-rs
$ cd git2-rs
$ cargo build

Automating Testing

Running tests and handling all of the associated edge cases on every commit proves tedious very quickly. To automate tests and handle proper stashing and unstashing of unstaged changes and thus avoid nasty surprises, use the pre-commit hook found here and place it into the .git/hooks/ with the name pre-commit. You may need to add execution permissions with chmod +x.

To skip tests on a simple commit or doc-fixes, use git commit --no-verify.

Building on macOS 10.10+

If the ssh feature is enabled (and it is by default) then this library depends on libssh2 which depends on OpenSSL. To get OpenSSL working follow the openssl crate's instructions.

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in git2-rs by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

A crate for using libcurl as a backend for HTTP git requests with git2-rs.

This crate provides one public function, register, which will register a custom HTTP transport with libcurl for any HTTP requests made by libgit2. At this time the register function is unsafe for the same reasons that git2::transport::register is also unsafe.

It is not recommended to use this crate wherever possible. The current libcurl backend used, curl-rust, only supports executing a request in one method call implying no streaming support. This consequently means that when a repository is cloned the entire contents of the repo are downloaded into memory, and then written off to disk by libgit2 afterwards. It should be possible to alleviate this problem in the future.

NOTE: At this time this crate likely does not support a git push operation, only clones.

Dependencies

~16–25MB
~443K SLoC