GithubHelp home page GithubHelp logo

git2-rs's Introduction

git2-rs

Documentation

libgit2 bindings for Rust.

[dependencies]
git2 = "0.18.3"

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.7.2 (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.

You can enable the Cargo feature vendored-libgit2 to always compile and statically link to a copy of libgit2. Sometimes the libgit2 on the system is required to be found and used even when vendored-libgit2 is activated. In this case, you shall set the environment variable LIBGIT2_NO_VENDOR=1.

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.

git2-rs's People

Contributors

alexanderkjall avatar alexcrichton avatar azenla avatar bhamail avatar blaenk avatar brooooooklyn avatar carlosmn avatar cmsd2 avatar ehuss avatar emlun avatar iancormac84 avatar ignatenkobrain avatar joshtriplett avatar katyo avatar keruspe avatar kim avatar ksqsf avatar kubo39 avatar lawliet89 avatar little-dude avatar nemo157 avatar rpelliard avatar rylio avatar s-panferov avatar staktrace avatar stephaneyfx avatar uzytkownik avatar weihanglo avatar zeerooth avatar zmbush avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git2-rs's Issues

git2-curl fails when i use rust-lang latest nightly and compile cargo

I am interested in writing my own CLI. Hence I cloned cargo and customized it to my own need.

  • Then updated all the dependencies to the latest.
  • executed cargo build

I received this compile error. The same happens in rust-lang 1.0 beta2

   Compiling git2-curl v0.2.3
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:127:9: 127:23 error: the trait `core::marker::Send` is not implemented for the type `E` [E0277]
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:127         io::Error::new(io::ErrorKind::Other, err)
                                                                                                 ^~~~~~~~~~~~~~
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:127:9: 127:23 note: `E` cannot be sent between threads safely
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:127         io::Error::new(io::ErrorKind::Other, err)
                                                                                                 ^~~~~~~~~~~~~~
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:127:9: 127:23 error: the trait `core::marker::Sync` is not implemented for the type `E` [E0277]
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:127         io::Error::new(io::ErrorKind::Other, err)
                                                                                                 ^~~~~~~~~~~~~~
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:127:9: 127:23 note: `E` cannot be shared between threads safely
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:127         io::Error::new(io::ErrorKind::Other, err)
                                                                                                 ^~~~~~~~~~~~~~
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:127:9: 127:23 error: the trait `std::error::Error` is not implemented for the type `E` [E0277]
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:127         io::Error::new(io::ErrorKind::Other, err)
                                                                                                 ^~~~~~~~~~~~~~
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:132:29: 132:61 error: the trait `core::convert::From<&str>` is not implemented for the type `Box<std::error::Error + Send>` [E0277]
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:132             return Err(self.err("already sent HTTP request"))
                                                                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:139:18: 139:53 error: the trait `core::convert::From<&str>` is not implemented for the type `Box<std::error::Error + Send>` [E0277]
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:139             self.err("invalid url, failed to parse")
                                                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:48 note: in expansion of try!
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:138:22: 140:12 note: expansion site
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:143:37: 143:76 error: the trait `core::convert::From<&str>` is not implemented for the type `Box<std::error::Error + Send>` [E0277]
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:143             None => return Err(self.err("invalid url, did not have a host")),
                                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:167:53: 167:59 error: the trait `core::convert::From<curl::ffi::err::ErrCode>` is not implemented for the type `Box<std::error::Error + Send>` [E0277]
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:167         let resp = try!(req.exec().map_err(|e| self.err(e)));
                                                                                                                                             ^~~~~~
<std macros>:1:1: 6:48 note: in expansion of try!
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:167:20: 167:61 note: expansion site
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:170:29: 171:73 error: the trait `core::convert::From<&str>` is not implemented for the type `Box<std::error::Error + Send>` [E0277]
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:170             return Err(self.err(&format!("failed to receive HTTP 200 response: \
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:171                                           got {}", resp.get_code())[..]))
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:181:29: 184:56 error: the trait `core::convert::From<&str>` is not implemented for the type `Box<std::error::Error + Send>` [E0277]
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:181             return Err(self.err(&format!("invalid Content-Type header: \
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:182                                           found `{:?}` expected `{}`",
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:183                                          resp.get_header("Content-Type"),
/home/ram/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-curl-0.2.3/src/lib.rs:184                                          expected)[..]))
error: aborting due to 9 previous errors
Could not compile `git2-curl`.

Build Failing on OSX Yosemite

I can't get this to build. I'm using

rustc 0.13.0-nightly (99d6956c3 2014-12-18 20:32:07 +0000)

and

cargo 0.0.1-pre-nightly (5cc6fb2 2014-12-19 21:45:29 +0000)

and getting the following error:

Failed to run custom build command for `libgit2-sys v0.1.3 (file:///Users/maxnew/git2-rs)`
Process didn't exit successfully: `/Users/maxnew/git2-rs/target/build/libgit2-sys-009ea0efd362f02c/build-script-build` (status=101)
--- stdout
running: cmake '/Users/maxnew/git2-rs/libgit2-sys/libgit2' '-DTHREADSAFE=ON' '-DBUILD_SHARED_LIBS=OFF' '-DBUILD_CLAR=OFF' '-DCMAKE_BUILD_TYPE=Debug' '-DCMAKE_INSTALL_PREFIX=/Users/maxnew/git2-rs/target/build/libgit2-sys-009ea0efd362f02c/out' '-DBUILD_EXAMPLES=OFF' '-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -m64 -fPIC'

--- stderr
task '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: no such file or directory', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libcore/result.rs:745

mismatched types: u32 vs i8

This crate isn't compiling for me as a part of semver:

/home/steve/.multirust/toolchains/nightly/cargo/registry/src/github.com-88ac128001ac3a9a/git2-0.3.4/src/diff.rs:665:13: 665:40 help: run `rustc --explain E0308` to see a detailed explanation
/home/steve/.multirust/toolchains/nightly/cargo/registry/src/github.com-88ac128001ac3a9a/git2-0.3.4/src/diff.rs:666:13: 666:38 error: mismatched types:
 expected `u32`,
    found `i8` [E0308]
/home/steve/.multirust/toolchains/nightly/cargo/registry/src/github.com-88ac128001ac3a9a/git2-0.3.4/src/diff.rs:666             raw::GIT_DIFF_LINE_BINARY => 'B',
                                                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~

Any idea what's going on here?

git2-rs cannot be built on msys2

Log:

$ RUST_BACKTRACE=1 ../cargo/target/snapshot/cargo/bin/cargo.exe build
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling matches v0.1.2
   Compiling libc v0.1.8
   Compiling pkg-config v0.3.5
   Compiling bitflags v0.1.1
   Compiling rustc-serialize v0.3.15
   Compiling libssh2-sys v0.1.25
   Compiling libgit2-sys v0.2.17 (file:///D:/msys64/mnt/develop/git2-rs)
   Compiling libz-sys v0.1.6
Build failed, waiting for other jobs to finish...
failed to run custom build command for `libgit2-sys v0.2.17 (file:///D:/msys64/mnt/develop/git2-rs)`
Process didn't exit successfully: `D:\msys64\mnt\develop\git2-rs\target\debug\build\libgit2-sys-33810a9bbc99735d\build-script-build` (exit code: 101)
--- stderr
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: NotPresent', D:/msys64/mnt/develop/rust/src/libcore\result.rs:729
stack backtrace:
   1:         0x702f89e2 - sys::backtrace::write::h00098dfeaffe4ecd0fs
   2:         0x70302073 - rt::unwind::register::h976fac48190837e4sNv
   3:         0x702c53a0 - rt::unwind::begin_unwind_inner::hf7bb18ccdf25707fCKv
   4:         0x702c5d97 - rt::unwind::begin_unwind_fmt::h0aaa081af7541f29IJv
   5:         0x70301aba - rust_begin_unwind
   6:         0x7031d439 - panicking::panic_fmt::ha0984e7a196361aff3B
   7:           0x406695
   8:           0x401ab3
   9:         0x7033b59c - rust_try
  10:         0x7033b579 - rust_try
  11:         0x70302aee - rt::lang_start::hc4dc5e509a4c99fblXv
  12:           0x40ee34 - main
  13:           0x4013e8
  14:           0x40151b
  15:         0x76f259cd - BaseThreadInitThunk

Rev: 3a7a990
rustc 1.1.0-dev (35ceea399 2015-06-19)
cargo 0.0.1-pre-nightly (84d6d2c 2015-03-31) (built 2015-04-02)

Can't compile libgit2 with latest Rust update.

While updating cargo on my system after installing the latest version of rust, the libgit2 crate fails to compile with the following error message:

Could not compile libgit2.

--- stderr
/var/tmp/portage/dev-rust/cargo-9999/homedir/.cargo/git/checkouts/git2-rs-cf258e7bcbaee34d/master/libgit2/src/lib.rs:429:5: 429:13 error: abstract is a reserved keyword
/var/tmp/portage/dev-rust/cargo-9999/homedir/.cargo/git/checkouts/git2-rs-cf258e7bcbaee34d/master/libgit2/src/lib.rs:429 abstract: *mut *mut c_void

Does not compile under rust 0.12.0-dev

plcstpierre@lotus ~/projects/rust % rustc --version (master)
rustc 0.12.0-dev (1f3cda8bd 2014-09-29 17:18:07 +0000)

Could not compile git2.

--- stderr
/home/plcstpierre/.cargo/git/checkouts/git2-rs-cf258e7bcbaee34d/master/src/branch.rs:44:12: 44:16 error: expected identifier, found keyword move
/home/plcstpierre/.cargo/git/checkouts/git2-rs-cf258e7bcbaee34d/master/src/branch.rs:44 pub fn move(&mut self, new_branch_name: &str, force: bool,
^~~~
error: aborting due to previous error

compiling without -fPIC fails on NixOS

I have to add -fPIC to the cflags on NixOS in order to be able to link this.
Thought that worked but can't get it to work that way anymore, I'm clueless. And -fPIC is apparently included..

See error below:

error: linking with `/nix/store/ylj1q31a7x3pvcraxk60dyv9y4wmwcrc-gcc-wrapper-4.8.4/bin/cc` failed: exit code: 1
note: "/nix/store/ylj1q31a7x3pvcraxk60dyv9y4wmwcrc-gcc-wrapper-4.8.4/bin/cc" "-Wl,--as-needed" "-m64" "-L" "/nix/store/4b37avxawl3zrzbq23iwqid1wxck3356-rustc-1.1.0/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/robin/dev/dependency-update-checker/target/debug/dependency_update_checker" "/home/robin/dev/dependency-update-checker/target/debug/dependency_update_checker.o" "-Wl,--whole-archive" "-lmorestack" "-Wl,--no-whole-archive" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "/home/robin/dev/dependency-update-checker/target/debug/deps/libhyper-5430830b6c9415c7.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libcargo-7d4f94162dd96571.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libflate2-41314c0597876aa0.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libsemver-9af778704c4cedca.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libtraitobject-e8fd97c9f52dc0fb.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libminiz_sys-9343607e1ddc701d.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/liblanguage_tags-97753499b1120d44.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libdocopt-141ed6b1383f3228.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libtar-37be75ed0ce09126.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libcookie-e6818e9cbd9a23bd.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libtoml-c925712d11adf72f.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libtypeable-3d4cacf3175a54fa.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libgit2-d5b60b78fba3006c.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/liblibgit2_sys-d13b80e47987a442.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/liblibssh2_sys-197403f26ef746c2.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libeventual-89a36857a9bbf0aa.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libglob-25f28f4f852d8a9f.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libmime-9888b9146b0c76d9.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libregex-c5abedf84fe61ddb.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libregex_syntax-c8b9f4684694b68e.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libnum_cpus-16707c6acca9fe91.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libunicase-1e872b36121cae26.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libstrsim-f37b8d6da2e1c859.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libterm-78a4699f433a04dc.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libsolicit-c21ee68bf7520de5.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libfiletime-98fab2a8e902dde6.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libsyncbox-dc1c282bf134c059.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libtime-77b646f204fa1d0c.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libbitflags-dd68b8369bcd8ff0.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libopenssl-67b24a7532162e96.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libbitflags-c495827ddcd6a202.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/liblazy_static-0b01921545729662.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libhttparse-d0764d07123db165.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libregistry-6abd7c5679ab10f8.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libcurl-8828a61714ae0eb4.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libcurl_sys-478772b4d493d102.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/liburl-41e9e3b273bd08e5.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libmatches-68291f81832fc22d.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/liblibz_sys-78922e0e40333890.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/librustc_serialize-c1e8163a38ed3d54.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libopenssl_sys-765ddf9de3c5179c.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libhpack-37abaf37ec66685c.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/liblog-8a6aba167994951e.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libaho_corasick-1c0816113fe68ddc.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libmemchr-38e2ee286f7e4bdb.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/liblibc-ef5cbad4ef5c7a1e.rlib" "/home/robin/dev/dependency-update-checker/target/debug/deps/libthreadpool-7afb0ed74cdfb4ee.rlib" "/nix/store/4b37avxawl3zrzbq23iwqid1wxck3356-rustc-1.1.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-7d23ff90.rlib" "/nix/store/4b37avxawl3zrzbq23iwqid1wxck3356-rustc-1.1.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-7d23ff90.rlib" "/nix/store/4b37avxawl3zrzbq23iwqid1wxck3356-rustc-1.1.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_unicode-7d23ff90.rlib" "/nix/store/4b37avxawl3zrzbq23iwqid1wxck3356-rustc-1.1.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-7d23ff90.rlib" "/nix/store/4b37avxawl3zrzbq23iwqid1wxck3356-rustc-1.1.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-7d23ff90.rlib" "/nix/store/4b37avxawl3zrzbq23iwqid1wxck3356-rustc-1.1.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-7d23ff90.rlib" "/nix/store/4b37avxawl3zrzbq23iwqid1wxck3356-rustc-1.1.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-7d23ff90.rlib" "-L" "/home/robin/dev/dependency-update-checker/target/debug" "-L" "/home/robin/dev/dependency-update-checker/target/debug/deps" "-L" "/home/robin/dev/dependency-update-checker/target/debug/build/curl-sys-478772b4d493d102/out/lib" "-L" "/home/robin/dev/dependency-update-checker/target/debug/build/libgit2-sys-d13b80e47987a442/out/lib" "-L" "/nix/store/zzjmzg5xpns5mcnj01ss6qsd4yj706zh-openssl-1.0.1m/lib" "-L" "/nix/store/ycbdnnsa6szmzgdd26ssn1yx2aj2knr3-libssh2-1.6.0/lib" "-L" "/nix/store/60nvlmj63b87xxfw20sg7ww3g84ijcq5-zlib-1.2.8/lib" "-L" "/nix/store/ycbdnnsa6szmzgdd26ssn1yx2aj2knr3-libssh2-1.6.0/lib" "-L" "/nix/store/60nvlmj63b87xxfw20sg7ww3g84ijcq5-zlib-1.2.8/lib" "-L" "/home/robin/dev/dependency-update-checker/target/debug/build/miniz-sys-9343607e1ddc701d/out" "-L" "/nix/store/zzjmzg5xpns5mcnj01ss6qsd4yj706zh-openssl-1.0.1m/lib" "-L" "/home/robin/dev/dependency-update-checker/target/debug/build/openssl-sys-765ddf9de3c5179c/out" "-L" "/nix/store/4b37avxawl3zrzbq23iwqid1wxck3356-rustc-1.1.0/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/robin/dev/dependency-update-checker/.rust/lib/x86_64-unknown-linux-gnu" "-L" "/home/robin/dev/dependency-update-checker/lib/x86_64-unknown-linux-gnu" "-Wl,--whole-archive" "-Wl,-Bstatic" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-lrt" "-lssl" "-lcrypto" "-ldl" "-lssh2" "-lssl" "-lcrypto" "-ldl" "-lcrypto" "-ldl" "-lssh2" "-lrt" "-lz" "-lssl" "-lcrypto" "-lc" "-lm" "-ldl" "-lpthread" "-lrt" "-lgcc_s" "-lpthread" "-lc" "-lm" "-lcompiler-rt"
note: /nix/store/yxg5zsjxp1l16xk7r23rayyc18fkxynk-binutils-2.23.1/bin/ld: /home/robin/dev/dependency-update-checker/target/debug/deps/liblibgit2_sys-d13b80e47987a442.rlib(r-z-deflate.o): relocation R_X86_64_32S against `_length_code' can not be used when making a shared object; recompile with -fPIC
/home/robin/dev/dependency-update-checker/target/debug/deps/liblibgit2_sys-d13b80e47987a442.rlib: could not read symbols: Bad value
collect2: error: ld returned 1 exit status

error: aborting due to previous error
Could not compile `dependency-update-checker`.

Fail to link if there is special chars in the project path

If there is a special character in the path of the project ( like รฉ,รจ ), libgit2-sys fail to link with the program. ex : /home/arnaud/workspace/Dรฉpots/laughing-journey

It took me time to find why it suddenly stop building after adding git2 dependency.

To reproduce:

mkdir yรจs
cd yรจs
cargo new myproject
cd myproject
echo "git2 = \"0.3.3\" " >> Cargo.toml
cargo build

Here the output: error.txt

Fails to build when a different version of libgit2 is already installed (with custom CFLAGS)

My scenario is a little unusual. At work, I don't have the ability to install packages system-wide, so I have a large collection of code installed into a homedirectory prefix. My environment has $CFLAGS and $LDFLAGS configured with -I and -L options that point to my custom prefix.

I have a version of libgit2 installed that is different from the version of libgit2 required by git2-rs. This seems to be causing git2-rs to fail to build because it seems to be finding libgit2 headers from my own install, not the packaged version.

Build failed, waiting for other jobs to finish...
failed to run custom build command for `libgit2-sys v0.2.12`
Process didn't exit successfully: `/rd/gen/lxd/do_not_delete/devel/cargo/target/debug/build/libgit2-sys-02c2db14240aac09/build-script-build` (exit code: 101)
--- stdout
running: "cmake" "/u/users/lxd/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.2.12/libgit2" "-DTHREADSAFE=ON" "-DBUILD_SHARED_LIBS=OFF" "-DBUILD_CLAR=OFF" "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_INSTALL_PREFIX=/rd/gen/lxd/do_not_delete/devel/cargo/target/x86_64-unknown-linux-gnu/debug/build/libgit2-sys-02c2db14240aac09/out" "-DBUILD_EXAMPLES=OFF" "-DCMAKE_C_FLAGS=-I/rd/gen/lxd/do_not_delete/lnx86_64/include -I/u/users/lxd/qt48base/include -ffunction-sections -fdata-sections -m64 -fPIC"
-- Could NOT find HTTP_Parser (missing:  HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY) 
-- http-parser was not found or is too old; using bundled 3rd-party sources.
-- Configuring done
-- Generating done
-- Build files have been written to: /rd/gen/lxd/do_not_delete/devel/cargo/target/x86_64-unknown-linux-gnu/debug/build/libgit2-sys-02c2db14240aac09/out/build
running: "cmake" "--build" "." "--target" "install"
gmake[1]: Entering directory `/rd/gen/lxd/do_not_delete/devel/cargo/target/x86_64-unknown-linux-gnu/debug/build/libgit2-sys-02c2db14240aac09/out/build'
gmake[2]: Entering directory `/rd/gen/lxd/do_not_delete/devel/cargo/target/x86_64-unknown-linux-gnu/debug/build/libgit2-sys-02c2db14240aac09/out/build'
gmake[3]: Entering directory `/rd/gen/lxd/do_not_delete/devel/cargo/target/x86_64-unknown-linux-gnu/debug/build/libgit2-sys-02c2db14240aac09/out/build'
gmake[3]: Leaving directory `/rd/gen/lxd/do_not_delete/devel/cargo/target/x86_64-unknown-linux-gnu/debug/build/libgit2-sys-02c2db14240aac09/out/build'
gmake[3]: Entering directory `/rd/gen/lxd/do_not_delete/devel/cargo/target/x86_64-unknown-linux-gnu/debug/build/libgit2-sys-02c2db14240aac09/out/build'
[  1%] Building C object CMakeFiles/git2.dir/src/diff_tform.c.o
/u/users/lxd/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.2.12/libgit2/src/diff_tform.c: In function 'normalize_find_opts':
/u/users/lxd/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.2.12/libgit2/src/diff_tform.c:355: error: 'GIT_HASHSIG_ALLOW_SMALL_FILES' undeclared (first use in this function)
/u/users/lxd/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.2.12/libgit2/src/diff_tform.c:355: error: (Each undeclared identifier is reported only once
/u/users/lxd/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.2.12/libgit2/src/diff_tform.c:355: error: for each function it appears in.)
At top level:
cc1: warning: unrecognized command line option "-Wno-unused-const-variable"
gmake[3]: *** [CMakeFiles/git2.dir/src/diff_tform.c.o] Error 1
gmake[3]: Leaving directory `/rd/gen/lxd/do_not_delete/devel/cargo/target/x86_64-unknown-linux-gnu/debug/build/libgit2-sys-02c2db14240aac09/out/build'
gmake[2]: *** [CMakeFiles/git2.dir/all] Error 2
gmake[2]: Leaving directory `/rd/gen/lxd/do_not_delete/devel/cargo/target/x86_64-unknown-linux-gnu/debug/build/libgit2-sys-02c2db14240aac09/out/build'
gmake[1]: *** [all] Error 2
gmake[1]: Leaving directory `/rd/gen/lxd/do_not_delete/devel/cargo/target/x86_64-unknown-linux-gnu/debug/build/libgit2-sys-02c2db14240aac09/out/build'

--- stderr
thread '<main>' panicked at '
command did not execute successfully, got: exit code: 2

build script failed, must exit now', /u/users/lxd/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.2.12/build.rs:109

Any thoughts about how to deal with this? The only workaround that I know of is to unset CFLAGS and LDFLAGS before building git2-rs

Thanks,
-Andrew

git2-rs panics when a checkout progress callack is given

I tried to run the clone example and it threw a SIGILL when it got to the checkout stage. I looked into it and I found that libgit calls report_progress (which calls the checkout callback) with NULL as the path here, report_progress here. Rust panics when it tries to read the string (and convert it to a byte array) here.

The C# binding converts NULL to an empty string, the Ruby and Swift bindings passes nil to the callback, and neither Haskell or OCaml have bindings for any checkout functions (just to mention two languages that lack nil completely).

No `peel` method on `Reference`?

When I run the following code (I made a crate to test):

extern crate git2;
use git2::{Repository, ObjectType};

fn main() {
    let repo = Repository::discover(".").unwrap();
    for reference in repo.references().unwrap() {
        let peeled_ref = reference.peel(ObjectType::Commit).unwrap();
        println!("{:?}", peeled_ref.id());
    }
}

I get the following error:

src/main.rs:7:36: 7:60 error: type `git2::reference::Reference<'_>` does not implement any method in scope named `peel`
src/main.rs:7         let peeled_ref = reference.peel(ObjectType::Commit).unwrap();
                                                 ^~~~~~~~~~~~~~~~~~~~~~~~

The docs and the source make it look like there's a peel method. Am I doing something wrong?

Iterating over a revwalk swallows the error

When there's an error during a git_revwalk_next() call (e.g. some of the data is corrupt). The iterator will swallow the message and simply stop the iteration. This makes it look like we're at the end of the requested history and there's no error to let us know that something bad happened.

I don't know of a good way to fix this while using the iterator traits, unfortunately.

arm-linux-gnueabihf: native compilation fails due to missing dependencies

When bootstrapping cargo on my ARM device, I get:

/home/japaric/.cargo/registry/src/github.com-1285ae84e5963aae/libgit2-sys-0.1.9/lib.rs:7:14: 7:52 error: can't find crate for `openssl`
/home/japaric/.cargo/registry/src/github.com-1285ae84e5963aae/libgit2-sys-0.1.9/lib.rs:7 #[cfg(unix)] extern crate "openssl-sys" as openssl;

The last cargo command is:

rustc
/home/japaric/.cargo/registry/src/github.com-1285ae84e5963aae/libgit2-sys-0.1.9/lib.rs
--crate-name libgit2-sys
--crate-type lib
-g
-C metadata=65c753755a4b169d
-C extra-filename=-65c753755a4b169d
--out-dir /home/japaric/tmp/cargo/target/deps
--emit=dep-info,link
-L dependency=/home/japaric/tmp/cargo/target/deps
-L dependency=/home/japaric/tmp/cargo/target/deps
--extern libssh2-sys=/home/japaric/tmp/cargo/target/deps/liblibssh2-sys-5026ca3a8e890bd1.rlib
-Awarnings
-L native=/home/japaric/tmp/cargo/target/build/libgit2-sys-65c753755a4b169d/out/lib
-L native=/usr/lib
-l rt
-l static=git2
-l ssl
-l crypto
-l dl
-l z
-l ssh2
-l ssl
-l crypto
-l dl
-l z
-l crypto
-l dl
-l z
-L native=/usr/lib
-L native=/usr/lib
-L native=/usr/lib

On the other hand on my x86_64 laptop that command contains two extra --extern arguments

rustc
/home/japaric/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.1.9/lib.rs
--crate-name libgit2-sys
--crate-type lib
-g
-C metadata=de8e4a35edb4e020
-C extra-filename=-de8e4a35edb4e020
--out-dir /home/japaric/tmp/cargo/target/deps
--emit=dep-info,link
-L dependency=/home/japaric/tmp/cargo/target/deps
-L dependency=/home/japaric/tmp/cargo/target/deps
--extern libz-sys=/home/japaric/tmp/cargo/target/deps/liblibz-sys-c466bff3a39d80f0.rlib  <--
--extern libssh2-sys=/home/japaric/tmp/cargo/target/deps/liblibssh2-sys-616a8038ed4e004b.rlib
--extern openssl-sys=/home/japaric/tmp/cargo/target/deps/libopenssl-sys-f6d7192b17104bf7.rlib <--
-Awarnings
-L native=/home/japaric/tmp/cargo/target/build/libgit2-sys-de8e4a35edb4e020/out/lib
-L native=/usr/lib
-l rt
-l static=git2
-l ssl
-l crypto
-l dl
-l z
-l ssh2
-l ssl
-l crypto
-l dl
-l z
-l crypto
-l dl
-l z
-L native=/usr/lib
-L native=/usr/lib
-L native=/usr/lib

The reason is that the libgit2-sys/Cargo.toml doesn't declare depedencies openssl-sys and libz-sys as dependencies for arm-unknown-linux-gnueabihf.

Fix incoming.

Call to `str::from_c_str` gets `*const libc::c_char` but it always expects `*const i8`, which may not always be the case

When building for an architecture where libc::c_char is not i8 (e.g., for AArch64 where it is u8), we get an error like this:

src/lib.rs:324:66: 324:69 error: mismatched types: expected `*const i8`, found `*const u8` (expected i8, found u8)

It seems that it has to be fixed at the caller's side (i.e., in git2-rs), since str::from_c_str is part of libcore, which is declared as dependency-free, so str::from_c_str cannot be changed to expect *const libc::c_char. IMHO.

Please provide bindings for git_reference_create_matching and git_reference_symbolic_create_matching

git2-rs provides bindings for git_reference_create (Repository::reference) and git_reference_symbolic_create (Repository::reference_symbolic), but not the safer versions that take an expected current OID value. Please consider adding bindings for those as well. (In hindsight, the ideal API would have been a single function that accepted an Option, but now that the unsafe versions exist, the safer versions should take an Oid.)

Please support distant working with remote repositories

Hi,
right now working with remote repositories requires to clone the repository to a local path ; however it would be interesting to have access to references of the remote repository without having to clone it first (like the git ls-remote terminal command). It would allow to check for new commits in the remote repository and for instance only clone the latter if needed (without having to clone the remote repo all the time or having a local copy of the remote and running fetch all the time).

Failed to commit

hi!
This issue concerns my understanding of "how to commit a modification with this library?".

An objective to my program is to get all diff for all followed objects, commit them with a simple commit like "back_up", and create a new branch starting from this commit.

For example, if I modify "README.md" and "CONTRIBUTING.md", I want to commit these files with a single commit.

But, I don't understand how to commit these 2 files in a simple way...
I use methods from Repository structure, but I really don't understand how to deal with the "commit" method. :-/
This method contains a Tree reference - does this reference must contains those modifications?
The "parents" field must contains previous commit in the current branch, right?

Is it possible to explain to me how to simply commit modifications in existing files please?

Thanks a lot!

Failing tests involving `Path` comparisons

Hello,

I tried to run the test suite on a mac and got three failures:

  • repo::tests::smoke_discover,
  • repo::tests::smoke_open, and
  • repo::tests::smoke_open_bare.

All three fail when they assert that two Paths are equal. The reason is that TempDir returns paths like

/var/folders/gj/wwyd13hx79d7fffdfhw19gg80000gn/T/rs-74979-28-test

and libgit2 (that is, git_repository_path) returns paths like

/private/var/folders/gj/wwyd13hx79d7fffdfhw19gg80000gn/T/rs-74979-28-test

On a mac, /var is symlinked to /privite/var.

I donโ€™t think that many people are suffering from this, and addressing this issue is probably not worth it. In any case, I hope it can be helpful. Thank you.

Regards,
Ivan

Can't push my modifications with the lib

Hi there!

I try to push some modifications on a remote with this part of code:

let mut callbacks = RemoteCallbacks::new();
callbacks.credentials(|user, pass, ctype| {
    return Cred::userpass_plaintext(user, pass.unwrap());
});
let mut push_options = PushOptions::new();
push_options.remote_callbacks(callbacks);
match r_remote.push(&[], Some(&mut push_options)) {
    Ok(_) => println!("Branch has been pushed!"),
    Err(error) => println!("Error {}", error),
};

but I obtained the error

thread '<main>' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:367
thread '<main>' panicked at 'callback has panicked, and continuing to unwind into C is not safe, so aborting the process', /home/antonin/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/git2-0.3.3/src/panic.rs:59
stack backtrace:
   1:     0x5620f8d584a0 - sys::backtrace::tracing::imp::write::haa19c02b4de52f3bG0t
   2:     0x5620f8d5a7f5 - panicking::log_panic::_<closure>::closure.41218
   3:     0x5620f8d5a270 - panicking::log_panic::h527fe484e9de8fe1W7x
   4:     0x5620f8d4c478 - sys_common::unwind::begin_unwind_inner::h51f64b1a34c60827fTs
   5:     0x5620f8ca4be7 - sys_common::unwind::begin_unwind::begin_unwind::h16792344233475443377
                        at ../src/libstd/sys/common/unwind/mod.rs:237
   6:     0x5620f8ca4b61 - panic::wrap::_<impl>::drop::h134a97ebfc9ce0d4a3b
                        at /home/antonin/Documents/dev/giwyn-rs/<std macros>:3
   7:     0x5620f8ca8eac - panic..wrap..Bomb::drop.22242::h43c09561fd975edb
   8:     0x5620f8cb245a - panic::wrap::h61232809709193426
                        at /home/antonin/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/git2-0.3.3/src/panic.rs:68
   9:     0x5620f8cb216c - remote_callbacks::credentials_cb::__rust_abi
                        at /home/antonin/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/git2-0.3.3/src/panic.rs:23
  10:     0x5620f8cb1f32 - remote_callbacks::credentials_cb::h8908a538de8f4e66gli
  11:     0x5620f8d2650a - on_headers_complete
                        at /home/antonin/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/libgit2-sys-0.3.8/libgit2/src/transports/http.c:354
  12:     0x5620f8d2c420 - http_parser_execute
                        at /home/antonin/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/libgit2-sys-0.3.8/libgit2/deps/http-parser/http_parser.c:1579
  13:     0x5620f8d2720e - http_stream_read
                        at /home/antonin/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/libgit2-sys-0.3.8/libgit2/src/transports/http.c:707
  14:     0x5620f8d2463a - git_smart__recv_cb
                        at /home/antonin/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/libgit2-sys-0.3.8/libgit2/src/transports/smart.c:22
  15:     0x5620f8d2dd6d - gitno_recv
                        at /home/antonin/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/libgit2-sys-0.3.8/libgit2/src/netops.c:20
  16:     0x5620f8d30279 - git_smart__store_refs
                        at /home/antonin/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/libgit2-sys-0.3.8/libgit2/src/transports/smart_protocol.c:50
  17:     0x5620f8d24dc9 - git_smart__connect
                        at /home/antonin/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/libgit2-sys-0.3.8/libgit2/src/transports/smart.c:242
  18:     0x5620f8cc1d91 - git_remote_connect
                        at /home/antonin/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/libgit2-sys-0.3.8/libgit2/src/remote.c:740
  19:     0x5620f8cc3d99 - git_remote_push
                        at /home/antonin/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/libgit2-sys-0.3.8/libgit2/src/remote.c:2464
  20:     0x5620f8cb142c - remote::_<impl>::push::h32e67b0670fb3884XTh
                        at /home/antonin/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/git2-0.3.3/src/call.rs:14
  21:     0x5620f8c4c5b7 - interactive_mod::_<impl>::create_back_up_for_good_repositories::h97af815ae4d95cd22Fa
                        at src/interactive_mod.rs:251
  22:     0x5620f8c4da58 - interactive_mod::_<impl>::trigger_format_process::he78dc6105ad60c163Qa
                        at src/interactive_mod.rs:264
  23:     0x5620f8c3be3c - interactive_mod::_<impl>::run::h62d33ec07166d347fRa
                        at src/interactive_mod.rs:293
  24:     0x5620f8c2fb50 - main::h2f511758d082d7d51Va
                        at src/main.rs:131
  25:     0x5620f8d5a014 - sys_common::unwind::try::try_fn::h11901883998771707766
  26:     0x5620f8d57948 - __rust_try
  27:     0x5620f8d59cb6 - rt::lang_start::hc150f651dd2af18b44x
  28:     0x5620f8c3c5c9 - main
  29:     0x7fdebfc08ec4 - __libc_start_main
  30:     0x5620f8c2e388 - <unknown>
  31:                0x0 - <unknown>
thread panicked while panicking. aborting.An unknown error occurred

I tried several solutions (found in the "Issues" section here), but no one works currently...

Have you ever found this error in a code?

Compile errors with 0.2.12

Thanks for addressing #71, in trying to use my shiny new peel method, I get a good chunk of barf from the compiler. Is there a missing dep in the new version or cargo update needed?

Without running cargo update first, cargo build produces this:

running: cargo build
    Updating registry `https://github.com/rust-lang/crates.io-index`
 Downloading git2 v0.2.12
   Compiling git2 v0.2.12
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:10:15: 10:29 error: use of undeclared type name `raw::git_blame`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:10     raw: *mut raw::git_blame,
                                                                                                                                  ^~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:16:15: 16:34 error: use of undeclared type name `raw::git_blame_hunk`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:16     raw: *mut raw::git_blame_hunk,
                                                                                                                                  ^~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:17:42: 17:56 error: use of undeclared type name `raw::git_blame`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:17     _marker: marker::PhantomData<&'blame raw::git_blame>,
                                                                                                                                                             ^~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:22:10: 22:32 error: use of undeclared type name `raw::git_blame_options`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:22     raw: raw::git_blame_options,
                                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:35:18: 35:47 error: unresolved name `raw::git_blame_get_hunk_count`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:35         unsafe { raw::git_blame_get_hunk_count(self.raw) as usize }
                                                                                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:41:23: 41:54 error: unresolved name `raw::git_blame_get_hunk_byindex`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:41             let ptr = raw::git_blame_get_hunk_byindex(self.raw(), index as u32);
                                                                                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:54:23: 54:53 error: unresolved name `raw::git_blame_get_hunk_byline`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:54             let ptr = raw::git_blame_get_hunk_byline(self.raw(), lineno as u32);
                                                                                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:72:42: 72:61 error: use of undeclared type name `raw::git_blame_hunk`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:72     unsafe fn from_raw_const(raw: *const raw::git_blame_hunk)
                                                                                                                                                             ^~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:75:30: 75:49 error: use of undeclared type name `raw::git_blame_hunk`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:75             raw: raw as *mut raw::git_blame_hunk,
                                                                                                                                                 ^~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:148:26: 148:48 error: use of undeclared type name `raw::git_blame_options`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:148             let mut raw: raw::git_blame_options = mem::zeroed();

/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:151:45: 151:75 error: unresolved name `raw::GIT_BLAME_OPTIONS_VERSION`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:151                                             raw::GIT_BLAME_OPTIONS_VERSION)
                                                                                                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 9:39 note: in expansion of assert_eq!
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:149:13: 152:18 note: expansion site
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:150:17: 150:44 error: unresolved name `raw::git_blame_init_options`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:150                 raw::git_blame_init_options(&mut raw,
                                                                                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 9:39 note: in expansion of assert_eq!
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:149:13: 152:18 note: expansion site
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:169:19: 169:56 error: unresolved name `raw::GIT_BLAME_TRACK_COPIES_SAME_FILE`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:169         self.flag(raw::GIT_BLAME_TRACK_COPIES_SAME_FILE, opt)
                                                                                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:174:19: 174:64 error: unresolved name `raw::GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:174         self.flag(raw::GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES, opt)
                                                                                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:180:19: 180:65 error: unresolved name `raw::GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:180         self.flag(raw::GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES, opt)
                                                                                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:186:19: 186:64 error: unresolved name `raw::GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:186         self.flag(raw::GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES, opt)
                                                                                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:192:19: 192:46 error: unresolved name `raw::GIT_BLAME_FIRST_PARENT`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:192         self.flag(raw::GIT_BLAME_FIRST_PARENT, opt)
                                                                                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:210:21: 210:35 error: use of undeclared type name `raw::git_blame`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:210     type Raw = *mut raw::git_blame;
                                                                                                                                         ^~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:212:34: 212:48 error: use of undeclared type name `raw::git_blame`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:212     unsafe fn from_raw(raw: *mut raw::git_blame) -> Blame<'repo> {
                                                                                                                                                      ^~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:216:27: 216:41 error: use of undeclared type name `raw::git_blame`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:216     fn raw(&self) -> *mut raw::git_blame { self.raw }
                                                                                                                                               ^~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:221:18: 221:37 error: unresolved name `raw::git_blame_free`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:221         unsafe { raw::git_blame_free(self.raw) }
                                                                                                                                      ^~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:226:21: 226:40 error: use of undeclared type name `raw::git_blame_hunk`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:226     type Raw = *mut raw::git_blame_hunk;
                                                                                                                                         ^~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:228:34: 228:53 error: use of undeclared type name `raw::git_blame_hunk`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:228     unsafe fn from_raw(raw: *mut raw::git_blame_hunk) -> BlameHunk<'blame> {
                                                                                                                                                      ^~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:232:27: 232:46 error: use of undeclared type name `raw::git_blame_hunk`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:232     fn raw(&self) -> *mut raw::git_blame_hunk { self.raw }
                                                                                                                                               ^~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:236:21: 236:43 error: use of undeclared type name `raw::git_blame_options`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:236     type Raw = *mut raw::git_blame_options;
                                                                                                                                         ^~~~~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:238:35: 238:57 error: use of undeclared type name `raw::git_blame_options`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:238     unsafe fn from_raw(opts: *mut raw::git_blame_options) -> BlameOptions {
                                                                                                                                                       ^~~~~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:242:27: 242:49 error: use of undeclared type name `raw::git_blame_options`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/blame.rs:242     fn raw(&self) -> *mut raw::git_blame_options {
                                                                                                                                               ^~~~~~~~~~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/call.rs:14:27: 14:34 error: unresolved name `raw::git_reference_peel`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/call.rs:14         match ::call::try(raw::$p($(::call::convert(&$e)),*)) {
                                                                                                                                             ^~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/call.rs:12:1: 19:2 note: in expansion of try_call!
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/reference.rs:159:13: 159:76 note: expansion site
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/repo.rs:1095:33: 1095:47 error: use of undeclared type name `raw::git_blame`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/repo.rs:1095         let mut raw = 0 as *mut raw::git_blame;
                                                                                                                                                     ^~~~~~~~~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/call.rs:14:27: 14:34 error: unresolved name `raw::git_blame_file`
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/call.rs:14         match ::call::try(raw::$p($(::call::convert(&$e)),*)) {
                                                                                                                                             ^~~~~~~
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/call.rs:12:1: 19:2 note: in expansion of try_call!
/Users/ben/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.2.12/src/repo.rs:1098:13: 1101:67 note: expansion site
error: aborting due to 30 previous errors
Could not compile `git2`.

To learn more, run the command again with --verbose.

After cargo update, everything is groovy.

Fail to link, can't find libhttp_parser

On linux cargo test fails to link executable.
Seems like it fails to find libhttp_parser.so which is installed in the system.

/home/user/git2-rs/target/debug/deps/liblibgit2_sys-71b7810ef1368bc1.rlib(http.c.o): In function `clear_parser_state':
/home/user/git2-rs/libgit2-sys/libgit2/src/transports/http.c:494: undefined reference to `http_parser_init'
/home/user/git2-rs/target/debug/deps/liblibgit2_sys-71b7810ef1368bc1.rlib(http.c.o): In function `http_connect':
/home/user/git2-rs/libgit2-sys/libgit2/src/transports/http.c:553: undefined reference to `http_should_keep_alive'
/home/user/git2-rs/target/debug/deps/liblibgit2_sys-71b7810ef1368bc1.rlib(http.c.o): In function `http_stream_read':
/home/user/git2-rs/libgit2-sys/libgit2/src/transports/http.c:707: undefined reference to `http_parser_execute'
/home/user/git2-rs/libgit2-sys/libgit2/src/transports/http.c:733: undefined reference to `http_errno_description'
/home/user/git2-rs/target/debug/deps/liblibgit2_sys-71b7810ef1368bc1.rlib(netops.c.o): In function `gitno_extract_url_parts':
/home/user/git2-rs/libgit2-sys/libgit2/src/netops.c:239: undefined reference to `http_parser_parse_url'

target/debug/build/libgit2-sys-edeca217c76a8f82/output ends with

cargo:root=/home/user/git2-rs/target/debug/build/libgit2-sys-edeca217c76a8f82/out
cargo:rustc-link-lib=static=git2
cargo:rustc-link-search=native=/home/user/git2-rs/target/debug/build/libgit2-sys-edeca217c76a8f82/out/lib

When 4d2b771 is reverted, links to libraries appear in output

cargo:root=/home/user/git2-rs/target/debug/build/libgit2-sys-edeca217c76a8f82/out
cargo:rustc-link-search=native=/home/user/git2-rs/target/debug/build/libgit2-sys-edeca217c76a8f82/out/lib
cargo:rustc-link-search=native=/usr/lib64
cargo:rustc-link-lib=static=git2
cargo:rustc-link-lib=http_parser
cargo:rustc-link-lib=rt
cargo:rustc-link-lib=ssl
cargo:rustc-link-lib=dl
cargo:rustc-link-lib=z
cargo:rustc-link-lib=crypto
cargo:rustc-link-lib=dl
cargo:rustc-link-lib=z

and linkage is successful .

peel_to_type or generic peel methods on references

Given a reference r, I tried to write the following:

let c = r.peel(git2::ObjectType::Commit).unwrap_or_else(die).into_commit().unwrap();

(unwrap_or_else(die) here produces a clean error message and exits, unlike the assertion-failure-style error from unwrap.)

However, the Result returned by into_commit has the original Object as its error type, which doesn't support the Debug trait required for unwrap. (And even if it did, an object isn't a useful error message.)

I understand the intent of into_commit and similar: they preserve either the object or its converted version. However, in a context like the above (after calling peel) where it would be an internal error to have anything other than a given type of object, I'd like to have a convenient way to obtain the right type for the object.

To simplify this case, perhaps references could provide type-specific methods like peel_to_commit, peel_to_tag, and similar? Or a method that has a generic return type and returns the object type the caller expects?

Support for colors, integrated with term library

I just filed libgit2/libgit2#3710 requesting support for colors in libgit2's config API. Once that goes in, I'd love to have support in git2-rs that integrates with the term library. In particular, git2::Config::get_color could return a git2::Color object, which in addition to methods to return the data that libgit2 provides, could have a method that takes a term::Terminal and sets the color accordingly.

`libgit2-sys::git_error` must implement `core::kinds::Send`

When building cargo for aarch64 with a recent self-built rustc, I get the following error for git2:

"/home/akiss/opt/rust-aarch64-latest/bin/rustc" -V
rustc 0.13.0-dev (539d2ac4b 2014-12-27 21:37:09 +0100)
/home/akiss/opt/cargo-aarch64-latest/bin/cargo build --target aarch64-unknown-linux-gnu  
   Compiling git2 v0.1.3
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:100:1: 106:2 error: the trait `core::kinds::Send` is not implemented for the type `*mut u8`
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:100 impl error::Error for Error {
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:101     fn description(&self) -> &str {
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:102         unsafe { str::from_c_str(self.raw.message as *const _) }
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:103     }
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:104 
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:105     fn detail(&self) -> Option<String> { Some(self.message()) }
                                                                                        ...
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:100:1: 106:2 note: the type `*mut u8` must implement `core::kinds::Send` because it appears within the type `libgit2-sys::git_error`
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:100 impl error::Error for Error {
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:101     fn description(&self) -> &str {
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:102         unsafe { str::from_c_str(self.raw.message as *const _) }
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:103     }
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:104 
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:105     fn detail(&self) -> Option<String> { Some(self.message()) }
                                                                                        ...
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:100:1: 106:2 note: the type `libgit2-sys::git_error` must implement `core::kinds::Send` because it appears within the type `error::Error`
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:100 impl error::Error for Error {
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:101     fn description(&self) -> &str {
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:102         unsafe { str::from_c_str(self.raw.message as *const _) }
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:103     }
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:104 
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:105     fn detail(&self) -> Option<String> { Some(self.message()) }
                                                                                        ...
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:100:1: 106:2 note: the trait `core::kinds::Send` must be implemented because it is required by `std::error::Error`
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:100 impl error::Error for Error {
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:101     fn description(&self) -> &str {
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:102         unsafe { str::from_c_str(self.raw.message as *const _) }
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:103     }
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:104 
/home/akiss/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.1.3/src/error.rs:105     fn detail(&self) -> Option<String> { Some(self.message()) }
                                                                                        ...
error: aborting due to previous error
Could not compile `git2`.

The error is actually reported against *mut c_char (c_char is u8 on aarch64) but it seemed to me that the note (i.e., "type libgit2-sys::git_error must implement core::kinds::Send because it appears within the type error::Error") is more relevant here.

Shouldn't Diff constructors be just methods of Repository?

I'm working on a project that is going to be wrapping libgit2 structs to get an API similiar to git2-rs, and Diff, having standalone constructors seems inconsistent with other parts of library (and is making my life more difficult, for reasons that are irrelevant here).

So it seems to me that Diff::tree_to_tree should be Repository::diff_tree_to_tree, just like eg. Index is constructed with Repository::index()

cargo test/build fails

Build failed, waiting for other jobs to finish...
failed to run custom build command for `libgit2-sys v0.4.2 (file:///home/srinivas/workspace/github/git2-rs)`
Process didn't exit successfully: `/home/srinivas/workspace/github/git2-rs/target/debug/build/libgit2-sys-9cd41cc7ed63ed3b/build-script-build` (exit code: 101)
--- stdout
running: "cmake" "/home/srinivas/workspace/github/git2-rs/libgit2-sys/libgit2" "-DBUILD_SHARED_LIBS=OFF" "-DBUILD_CLAR=OFF" "-DCURL=OFF" "-DCMAKE_INSTALL_PREFIX=/home/srinivas/workspace/github/git2-rs/target/debug/build/libgit2-sys-9cd41cc7ed63ed3b/out" "-DCMAKE_C_FLAGS= -O0 -ffunction-sections -fdata-sections -m32" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -O0 -ffunction-sections -fdata-sections -m32" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_BUILD_TYPE=Debug"

--- stderr
CMake Error: The source directory "/home/srinivas/workspace/github/git2-rs/libgit2-sys/libgit2" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
thread '<main>' panicked at '
command did not execute successfully, got: exit code: 1

build script failed, must exit now', /home/srinivas/.cargo/registry/src/github.com-48ad6e4054423464/cmake-0.1.16/src/lib.rs:448

How to connect a remote that requires authentication?

I want to connect a remote that requires authentication, but Remote#connect() doesn't have a parameter to pass credentials. How to do it with git2-rs?

I tried to connect with examples/fetch.rs, an error has occured at line 79:

error: [23/-1] authentication required but no callback set

cargo build fails because git submodule is missing

I tried to compile git2-rs (cloning the repo and as cargo dependency) thr result is allways the same:

Process didn't exit successfully: `make -f build/cargo.mk` (status=2)
--- stdout
cmake build/libgit2 -G "Unix Makefiles" -B"/home/alex/dev/99_rust/target/native/libgit2-fcba23a36b59f31c" -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_EXAMPLES=OFF -DCMAKE_C_FLAGS="-m64 -fPIC"
build/cargo.mk:11: recipe for target 'all' failed

--- stderr
CMake Error: The source directory "/home/alex/.cargo/git/checkouts/git2-rs-cf258e7bcbaee34d/master/libgit2/build/libgit2" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
make: *** [all] Error 1

When I work with the cloned repository, it's enough to do the following to fix the problem:

git submodule init
git submodule update

Could you please add this to the README.md. It seems that the current cargo build is failing because of the same problem.

Should `Oid` implement `AsRef<[u8]>`

Not entirely certain this makes sense, but it would allow avoiding a call to as_bytes when passing an Oid into functions taking in &[u8] generically.

Looking through std there's precedence in that str.as_bytes() and AsRef::<[u8]>::as_ref(str) are equivalent.

Casting `Object` via `as_type()` and references

It looks like Object's as_{tree,commit,blob,tag}() is meant for situations where you keep hold of the Object variable and need the specific type for a function call or similar. I'm trying to build a function where I accept an extended-sha1 string and return a tree (wrapped in Option and/or Result). But the "obvious" way of writing this, something like

fn resolve_tree<'repo>(repo: &'repo Repository, expr: &str) -> Option<&'repo Tree<'repo>> {
    repo.revparse_single(expr).ok()
        .and_then(|o| o.peel(ObjectType::Tree).ok())
        .and_then(|t| t.as_tree())
}

doesn't work, since t doesn't live long enough (because as_tree() returns something tied to its life-time). I don't actually care about the generically-typed object and would rather get a Tree<'repo> out of it. I think that would involve consuming self which sounds fine for this.

Would something named more like into_{tree,commit,blob,tag}() be more appropriate for this kind of behaviour (does it exist but I'm missing it?). I know that looking up the object via repo.find_tree() ends up being pretty cheap since the object is cached by libgit2 but it'd feel cleaner not having to rely in that kind of information.

IndexEntry path and flags not safe to expose directly

In the underlying git_index_entry structure, the low 12 bits of flags define the length of the path (with 0xFFF indicating a need to search for a NUL terminator, which as far as I can tell must always exist for an in-memory structure regardless of length). IndexEntry exposes the path and flags fields directly, without handling NUL termination or length. An IndexEntry constructed in safe code can cause libgit2 to access memory it shouldn't and write that out as part of the path. For instance, I constructed an IndexEntry for a file "base", and the index on disk ended up with a file "basec6d", where "c6d" were characters of a recently handled short hash ID.

git2-rs needs to provide a safer wrapper for IndexEntry, making the safer fields available directly, but providing wrappers for the path, stage, and flags, to maintain consistency. Since IndexEntry won't have all of its fields available, it will also need an appropriate constructor. I'd suggest an IndexEntry::new that takes a Path, mode, and Option<Oid>.

Linking issue during test

cargo build runs fine, but cargo test has link errors like the following:

error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/storage/home/achin/devel/rust/prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-o' '/storage/home/achin/devel/git2-rs/target/te
st/git2-cbb49407bcd245e7' '/storage/home/achin/devel/git2-rs/target/test/git2-cbb49407bcd245e7.o' '-Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-a
rchive' '-nodefaultlibs' '-Wl,--gc-sections' '-Wl,--as-needed' '/storage/home/achin/devel/rust/prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-
4e7c5e5c.rlib' '/storage/home/achin/devel/rust/prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtime-4e7c5e5c.rlib' '/storage/home/achin/devel/rust/p
refix/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgetopts-4e7c5e5c.rlib' '/storage/home/achin/devel/rust/prefix/lib/rustlib/x86_64-unknown-linux-gnu/li
b/libregex-4e7c5e5c.rlib' '/storage/home/achin/devel/rust/prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib/libterm-4e7c5e5c.rlib' '/storage/home/achin/d
evel/git2-rs/target/test/deps/liblibgit2-2913156a3c646424.rlib' '/storage/home/achin/devel/rust/prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib/libnati
ve-4e7c5e5c.rlib' '/storage/home/achin/devel/git2-rs/target/test/deps/libopenssl-2a176440e0479728.rlib' '/storage/home/achin/devel/rust/prefix/lib/rust
lib/x86_64-unknown-linux-gnu/lib/libserialize-4e7c5e5c.rlib' '/storage/home/achin/devel/rust/prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblog-4e7
c5e5c.rlib' '/storage/home/achin/devel/rust/prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-4e7c5e5c.rlib' '/storage/home/achin/devel/rust/prefi
x/lib/rustlib/x86_64-unknown-linux-gnu/lib/libsync-4e7c5e5c.rlib' '/storage/home/achin/devel/rust/prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib/libru
strt-4e7c5e5c.rlib' '/storage/home/achin/devel/rust/prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-4e7c5e5c.rlib' '/storage/home/achin/
devel/rust/prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-4e7c5e5c.rlib' '/storage/home/achin/devel/rust/prefix/lib/rustlib/x86_64-unknown-li
nux-gnu/lib/liblibc-4e7c5e5c.rlib' '/storage/home/achin/devel/rust/prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-4e7c5e5c.rlib' '/storage/hom
e/achin/devel/rust/prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode-4e7c5e5c.rlib' '/storage/home/achin/devel/rust/prefix/lib/rustlib/x86_64-
unknown-linux-gnu/lib/libcore-4e7c5e5c.rlib' '-L' '/storage/home/achin/devel/git2-rs/target/test/deps' '-L' '/storage/home/achin/devel/git2-rs/target/t
est/native/libgit2-2913156a3c646424' '-L' '/storage/home/achin/devel/git2-rs/target/test' '-L' '/storage/home/achin/devel/git2-rs/.rust' '-L' '/storage
/home/achin/devel/git2-rs' '-Wl,-Bdynamic' '-lrt' '-lz' '-lssl' '-lcrypto' '-lcrypto' '-lcrypto' '-lcrypto' '-lcrypto' '-lcrypto' '-lcrypto' '-lcrypto'
 '-ldl' '-lpthread' '-lgcc_s' '-lpthread' '-lc' '-lm' '-lcompiler-rt'

/storage/home/achin/devel/git2-rs/target/test/deps/liblibgit2-2913156a3c646424.rlib(r-git2-http.c.o): In function `http_stream_write_chunked':
http.c:(.text+0x1630): undefined reference to `http_parser_init'
/storage/home/achin/devel/git2-rs/target/test/deps/liblibgit2-2913156a3c646424.rlib(r-git2-ssh.c.o): In function `ssh_stream_free':
ssh.c:(.text+0x149): undefined reference to `libssh2_channel_close'
ssh.c:(.text+0x152): undefined reference to `libssh2_channel_free'
ssh.c:(.text+0x168): undefined reference to `libssh2_session_free'

The following patch fixes the issue on my Gentoo machine, but I'm not sure if it's the correct fix:

diff --git a/libgit2/src/lib.rs b/libgit2/src/lib.rs
index a3107c3..54807b1 100644
--- a/libgit2/src/lib.rs
+++ b/libgit2/src/lib.rs
@@ -376,6 +376,8 @@ pub enum git_config_level_t {

 #[link(name = "git2", kind = "static")]
 #[link(name = "z")]
+#[link(name = "ssh2")]
+#[link(name = "http_parser")]
 extern {
     // threads
     pub fn git_threads_init() -> c_int;

I am using the following commits:

How to set cred callback for push?

I'm trying to push to a remote using SSH authentication. Trying to do this "out of the box" yields the following:

thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: -1, klass: 23, message: "authentication required but no callback set" }', src/libcore/result.rs:741

which is fine, I haven't given it any authentication callback yet.

So, I tried to set the callback in what I think is the right place, by making a callbacks object:

let mut callbacks = RemoteCallbacks::new();
callbacks.credentials(|user, pass, ctype| {
    return Cred::ssh_key_from_agent(user);
});

However, the only method I could find on a Remote to set the callbacks was in update_tips, so I tried the following:

remote.update_tips(Some(&mut callbacks), false, AutotagOption::Auto, None).unwrap();

Which doesn't work because I haven't connected yet. But if I try to:

remote.connect(Direction::Push).unwrap();

It fails since there's no creds.

I've gotta be missing something or doing something wrong, does anyone know what that is?

i64LLVM ERROR: Broken function found, compilation aborted!

Hello All,

follow the instructions:

git clone --recursive https://github.com/alexcrichton/git2-rs
cd git2-rs/
cargo build

I got the following:

   Updating registry `https://github.com/rust-lang/crates.io-index`
 Downloading openssl-sys v0.7.8
   Compiling rustc-serialize v0.3.18
   Compiling libc v0.2.8
   Compiling pkg-config v0.3.8
   Compiling unicode-normalization v0.1.2
   Compiling bitflags v0.1.1
   Compiling matches v0.1.2
   Compiling unicode-bidi v0.2.3
   Compiling rand v0.3.14
   Compiling gcc v0.3.25
   Compiling openssl-sys v0.7.8
   Compiling cmake v0.1.16
   Compiling libz-sys v1.0.1
   Compiling libgit2-sys v0.4.1 (file:///mnt/disk2/opt/pkgs/git2-rs/libgit2-sys)
   Compiling libssh2-sys v0.1.36
   Compiling uuid v0.1.18
   Compiling url v0.5.7
   Compiling git2 v0.4.2 (file:///mnt/disk2/opt/pkgs/git2-rs)
Stored value type does not match pointer operand type!
  store %"2.core::option::Option<diff::DiffHunk>"* %2, i64* %7, align 8
 i64LLVM ERROR: Broken function found, compilation aborted!
       error Could not compile `git2`.

This prevents the cargo from being built normally.
Additional information:

rustc --version
rustc 1.9.0-dev (151be0933 2016-03-19)
uname -a
Linux chisel 4.2.0-34-generic #39-Ubuntu SMP Thu Mar 10 22:13:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Thanks!

get stable-compatible

It seems like the only language feature we use is catch_panic. Is it feasible to avoid the use of this feature to get this building on stable? Perhaps introducing a cargo feature that, when enabled, makes use of catch_panic, and otherwise does not?

Cannot use unstable #![feature(catch_panic)] in beta

$ rustc --version
rustc 1.0.0-beta (9854143cb 2015-04-02) (built 2015-04-02)
$ cargo build
   Compiling git2 v0.2.8 (file:///home/anders/rust/git2-rs)
src/lib.rs:67:1: 67:25 error: unstable feature
src/lib.rs:67 #![feature(catch_panic)]
              ^~~~~~~~~~~~~~~~~~~~~~~~
note: this feature may not be used in the beta release channel
error: aborting due to previous error
Could not compile `git2`.

To learn more, run the command again with --verbose.
$ sed -i 67d src/lib.rs
$ cargo build
   Compiling git2 v0.2.8 (file:///home/anders/rust/git2-rs)
src/panic.rs:41:11: 41:30 error: use of unstable library feature 'catch_panic': recent API addition
src/panic.rs:41     match thread::catch_panic(f) {
                          ^~~~~~~~~~~~~~~~~~~
src/panic.rs:41:30: 41:30 help: add #![feature(catch_panic)] to the crate attributes to enable
error: aborting due to previous error
Could not compile `git2`.

To learn more, run the command again with --verbose.

Testing problem.

I'm working on a release tool that relies on git2-rs. Because there are no git2-rs traits to implement as mocks/stubs/doubles (whatever we're calling them these days) I'm having a really hard time figuring out a way to test my code that relies on git2-rs. The failure cases are the really tough ones to test without traits to implement. I can't even think of a way to create a bad git repo that would exhibit the kinds of errors I need to test.

For an example see: https://github.com/ereichert/cargo-release/blob/feature/branch_check/src/main.rs#L196

Would you consider a pull request that adds traits to the public API?

Keep in mind I'm still working my way through Rust's testing story so there may be a way to do this without traits I'm failing to grasp (other than doing actual side effecting git2-rs calls). If you won't consider the addition of traits to git2-rs could you suggest a way to test my code?

Broken libgit2-sys 0.3 compatibility (bump to 0.4?)

Commit 287be9c, now part of libgit2-sys 0.3.8, broke compatibility with previous 0.3.7 API by moving around some pub constants.
You noticed yourself the effect of this when touching cargo.

According to vanilla semver, 0.3.7 and 0.3.8 are not forced to be compatible (rule 4, aka v0 major).
According to cargo semver, 0.3.7 and 0.3.8 are considered compatible.

It is my understanding that ligbit2-sys should be bumped to 0.4.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.