1 diff -urN rustc-1.56.0-src/Cargo.lock rustc-1.56.0-src-git2/Cargo.lock
2 --- rustc-1.56.0-src/Cargo.lock 2021-10-18 11:52:36.000000000 +0200
3 +++ rustc-1.56.0-src-git2/Cargo.lock 2021-10-23 20:59:08.434911180 +0200
10 source = "registry+https://github.com/rust-lang/crates.io-index"
11 checksum = "1d250f5f82326884bd39c2853577e70a121775db76818ffa452ed1e80de12986"
17 -version = "0.12.18+1.1.0"
18 +version = "0.12.24+1.3.0"
19 source = "registry+https://github.com/rust-lang/crates.io-index"
20 checksum = "3da6a42da88fc37ee1ecda212ffa254c25713532980005d5f7c0b0fbe7e6e885"
22 diff -urN rustc-1.56.0-src/src/tools/cargo/Cargo.toml rustc-1.56.0-src-git2/src/tools/cargo/Cargo.toml
23 --- rustc-1.56.0-src/src/tools/cargo/Cargo.toml 2021-10-18 11:52:56.000000000 +0200
24 +++ rustc-1.56.0-src-git2/src/tools/cargo/Cargo.toml 2021-10-23 21:00:31.124770799 +0200
29 -libgit2-sys = "0.12.18"
30 +libgit2-sys = "0.12.24"
34 diff -urN rustc-1.56.0-src/src/tools/miri/cargo-miri/Cargo.lock rustc-1.56.0-src-git2/src/tools/miri/cargo-miri/Cargo.lock
35 --- rustc-1.56.0-src/src/tools/miri/cargo-miri/Cargo.lock 2021-10-18 11:52:56.000000000 +0200
36 +++ rustc-1.56.0-src-git2/src/tools/miri/cargo-miri/Cargo.lock 2021-10-23 21:01:01.564718045 +0200
43 source = "registry+https://github.com/rust-lang/crates.io-index"
44 checksum = "1d250f5f82326884bd39c2853577e70a121775db76818ffa452ed1e80de12986"
50 -version = "0.12.18+1.1.0"
51 +version = "0.12.24+1.3.0"
52 source = "registry+https://github.com/rust-lang/crates.io-index"
53 checksum = "3da6a42da88fc37ee1ecda212ffa254c25713532980005d5f7c0b0fbe7e6e885"
55 diff -urN rustc-1.56.0-src/src/tools/rls/Cargo.lock rustc-1.56.0-src-git2/src/tools/rls/Cargo.lock
56 --- rustc-1.56.0-src/src/tools/rls/Cargo.lock 2021-10-18 11:52:56.000000000 +0200
57 +++ rustc-1.56.0-src-git2/src/tools/rls/Cargo.lock 2021-10-23 20:55:59.835212449 +0200
64 source = "registry+https://github.com/rust-lang/crates.io-index"
65 checksum = "1d250f5f82326884bd39c2853577e70a121775db76818ffa452ed1e80de12986"
71 -version = "0.12.18+1.1.0"
72 +version = "0.12.24+1.3.0"
73 source = "registry+https://github.com/rust-lang/crates.io-index"
74 checksum = "3da6a42da88fc37ee1ecda212ffa254c25713532980005d5f7c0b0fbe7e6e885"
76 diff -urN rustc-1.56.0-src/vendor/git2/Cargo.lock rustc-1.56.0-src-git2/vendor/git2/Cargo.lock
77 --- rustc-1.56.0-src/vendor/git2/Cargo.lock 2021-10-18 13:05:54.000000000 +0200
78 +++ rustc-1.56.0-src-git2/vendor/git2/Cargo.lock 2021-10-23 20:59:46.411513930 +0200
92 -version = "0.12.18+1.1.0"
93 +version = "0.12.24+1.3.0"
94 source = "registry+https://github.com/rust-lang/crates.io-index"
95 checksum = "3da6a42da88fc37ee1ecda212ffa254c25713532980005d5f7c0b0fbe7e6e885"
97 diff -urN rustc-1.56.0-src/vendor/git2/Cargo.toml rustc-1.56.0-src-git2/vendor/git2/Cargo.toml
98 --- rustc-1.56.0-src/vendor/git2/Cargo.toml 2021-10-18 13:05:54.000000000 +0200
99 +++ rustc-1.56.0-src-git2/vendor/git2/Cargo.toml 2021-10-23 20:47:39.252455615 +0200
106 authors = ["Josh Triplett <josh@joshtriplett.org>", "Alex Crichton <alex@alexcrichton.com>"]
107 description = "Bindings to libgit2 for interoperating with git repositories. This library is\nboth threadsafe and memory safe and allows both reading and writing git\nrepositories.\n"
108 documentation = "https://docs.rs/git2"
112 [dependencies.libgit2-sys]
118 diff -urN rustc-1.56.0-src/vendor/git2/README.md rustc-1.56.0-src-git2/vendor/git2/README.md
119 --- rustc-1.56.0-src/vendor/git2/README.md 2021-10-18 13:05:54.000000000 +0200
120 +++ rustc-1.56.0-src-git2/vendor/git2/README.md 2021-10-23 20:47:39.252455615 +0200
122 ## Rust version requirements
124 git2-rs works with stable Rust, and typically works with the most recent prior
125 -stable release as well. Check the MSRV job of [the CI script](.github/workflows/main.yml) to see the oldest
126 -version of Rust known to pass tests.
127 +stable release as well.
129 ## Version of libgit2
131 diff -urN rustc-1.56.0-src/vendor/git2/src/attr.rs rustc-1.56.0-src-git2/vendor/git2/src/attr.rs
132 --- rustc-1.56.0-src/vendor/git2/src/attr.rs 1970-01-01 01:00:00.000000000 +0100
133 +++ rustc-1.56.0-src-git2/vendor/git2/src/attr.rs 2021-10-23 20:47:39.252455615 +0200
139 +/// All possible states of an attribute.
141 +/// This enum is used to interpret the value returned by
142 +/// [`Repository::get_attr`](crate::Repository::get_attr) and
143 +/// [`Repository::get_attr_bytes`](crate::Repository::get_attr_bytes).
144 +#[derive(Debug, Clone, Copy, Eq)]
145 +pub enum AttrValue<'string> {
146 + /// The attribute is set to true.
148 + /// The attribute is unset (set to false).
150 + /// The attribute is set to a [valid UTF-8 string](prim@str).
151 + String(&'string str),
152 + /// The attribute is set to a string that might not be [valid UTF-8](prim@str).
153 + Bytes(&'string [u8]),
154 + /// The attribute is not specified.
158 +macro_rules! from_value {
159 + ($value:expr => $string:expr) => {
160 + match unsafe { raw::git_attr_value($value.map_or(ptr::null(), |v| v.as_ptr().cast())) } {
161 + raw::GIT_ATTR_VALUE_TRUE => Self::True,
162 + raw::GIT_ATTR_VALUE_FALSE => Self::False,
163 + raw::GIT_ATTR_VALUE_STRING => $string,
164 + raw::GIT_ATTR_VALUE_UNSPECIFIED => Self::Unspecified,
165 + _ => unreachable!(),
170 +impl<'string> AttrValue<'string> {
171 + /// Returns the state of an attribute by inspecting its [value](crate::Repository::get_attr)
172 + /// by a [string](prim@str).
174 + /// This function always returns [`AttrValue::String`] and never returns [`AttrValue::Bytes`]
175 + /// when the attribute is set to a string.
176 + pub fn from_string(value: Option<&'string str>) -> Self {
177 + from_value!(value => Self::String(value.unwrap()))
180 + /// Returns the state of an attribute by inspecting its [value](crate::Repository::get_attr_bytes)
181 + /// by a [byte](u8) [slice].
183 + /// This function will perform UTF-8 validation when the attribute is set to a string, returns
184 + /// [`AttrValue::String`] if it's valid UTF-8 and [`AttrValue::Bytes`] otherwise.
185 + pub fn from_bytes(value: Option<&'string [u8]>) -> Self {
186 + let mut value = Self::always_bytes(value);
187 + if let Self::Bytes(bytes) = value {
188 + if let Ok(string) = str::from_utf8(bytes) {
189 + value = Self::String(string);
195 + /// Returns the state of an attribute just like [`AttrValue::from_bytes`], but skips UTF-8
196 + /// validation and always returns [`AttrValue::Bytes`] when it's set to a string.
197 + pub fn always_bytes(value: Option<&'string [u8]>) -> Self {
198 + from_value!(value => Self::Bytes(value.unwrap()))
202 +/// Compare two [`AttrValue`]s.
204 +/// Note that this implementation does not differentiate between [`AttrValue::String`] and
205 +/// [`AttrValue::Bytes`].
206 +impl PartialEq for AttrValue<'_> {
207 + fn eq(&self, other: &AttrValue<'_>) -> bool {
208 + match (self, other) {
209 + (Self::True, AttrValue::True)
210 + | (Self::False, AttrValue::False)
211 + | (Self::Unspecified, AttrValue::Unspecified) => true,
212 + (AttrValue::String(string), AttrValue::Bytes(bytes))
213 + | (AttrValue::Bytes(bytes), AttrValue::String(string)) => string.as_bytes() == *bytes,
214 + (AttrValue::String(left), AttrValue::String(right)) => left == right,
215 + (AttrValue::Bytes(left), AttrValue::Bytes(right)) => left == right,
223 + use super::AttrValue;
225 + macro_rules! test_attr_value {
226 + ($function:ident, $variant:ident) => {
227 + const ATTR_TRUE: &str = "[internal]__TRUE__";
228 + const ATTR_FALSE: &str = "[internal]__FALSE__";
229 + const ATTR_UNSET: &str = "[internal]__UNSET__";
230 + let as_bytes = AsRef::<[u8]>::as_ref;
231 + // Use `matches!` here since the `PartialEq` implementation does not differentiate
232 + // between `String` and `Bytes`.
234 + AttrValue::$function(Some(ATTR_TRUE.as_ref())),
235 + AttrValue::$variant(s) if as_bytes(s) == ATTR_TRUE.as_bytes()
238 + AttrValue::$function(Some(ATTR_FALSE.as_ref())),
239 + AttrValue::$variant(s) if as_bytes(s) == ATTR_FALSE.as_bytes()
242 + AttrValue::$function(Some(ATTR_UNSET.as_ref())),
243 + AttrValue::$variant(s) if as_bytes(s) == ATTR_UNSET.as_bytes()
246 + AttrValue::$function(Some("foo".as_ref())),
247 + AttrValue::$variant(s) if as_bytes(s) == b"foo"
250 + AttrValue::$function(Some("bar".as_ref())),
251 + AttrValue::$variant(s) if as_bytes(s) == b"bar"
253 + assert_eq!(AttrValue::$function(None), AttrValue::Unspecified);
258 + fn attr_value_from_string() {
259 + test_attr_value!(from_string, String);
263 + fn attr_value_from_bytes() {
264 + test_attr_value!(from_bytes, String);
266 + AttrValue::from_bytes(Some(&[0xff])),
267 + AttrValue::Bytes(&[0xff])
270 + AttrValue::from_bytes(Some(b"\xffoobar")),
271 + AttrValue::Bytes(b"\xffoobar")
276 + fn attr_value_always_bytes() {
277 + test_attr_value!(always_bytes, Bytes);
279 + AttrValue::always_bytes(Some(&[0xff; 2])),
280 + AttrValue::Bytes(&[0xff, 0xff])
283 + AttrValue::always_bytes(Some(b"\xffoo")),
284 + AttrValue::Bytes(b"\xffoo")
289 + fn attr_value_partial_eq() {
290 + assert_eq!(AttrValue::True, AttrValue::True);
291 + assert_eq!(AttrValue::False, AttrValue::False);
292 + assert_eq!(AttrValue::String("foo"), AttrValue::String("foo"));
293 + assert_eq!(AttrValue::Bytes(b"foo"), AttrValue::Bytes(b"foo"));
294 + assert_eq!(AttrValue::String("bar"), AttrValue::Bytes(b"bar"));
295 + assert_eq!(AttrValue::Bytes(b"bar"), AttrValue::String("bar"));
296 + assert_eq!(AttrValue::Unspecified, AttrValue::Unspecified);
297 + assert_ne!(AttrValue::True, AttrValue::False);
298 + assert_ne!(AttrValue::False, AttrValue::Unspecified);
299 + assert_ne!(AttrValue::Unspecified, AttrValue::True);
300 + assert_ne!(AttrValue::True, AttrValue::String("true"));
301 + assert_ne!(AttrValue::Unspecified, AttrValue::Bytes(b"unspecified"));
302 + assert_ne!(AttrValue::Bytes(b"false"), AttrValue::False);
303 + assert_ne!(AttrValue::String("unspecified"), AttrValue::Unspecified);
304 + assert_ne!(AttrValue::String("foo"), AttrValue::String("bar"));
305 + assert_ne!(AttrValue::Bytes(b"foo"), AttrValue::Bytes(b"bar"));
306 + assert_ne!(AttrValue::String("foo"), AttrValue::Bytes(b"bar"));
307 + assert_ne!(AttrValue::Bytes(b"foo"), AttrValue::String("bar"));
310 diff -urN rustc-1.56.0-src/vendor/git2/src/blame.rs rustc-1.56.0-src-git2/vendor/git2/src/blame.rs
311 --- rustc-1.56.0-src/vendor/git2/src/blame.rs 2021-10-18 13:05:54.000000000 +0200
312 +++ rustc-1.56.0-src-git2/vendor/git2/src/blame.rs 2021-10-23 20:47:39.252455615 +0200
318 + /// The first line in the file to blame.
319 + pub fn min_line(&mut self, lineno: usize) -> &mut BlameOptions {
320 + self.raw.min_line = lineno;
324 + /// The last line in the file to blame.
325 + pub fn max_line(&mut self, lineno: usize) -> &mut BlameOptions {
326 + self.raw.max_line = lineno;
331 impl<'repo> Binding for Blame<'repo> {
334 unsafe fn from_raw(raw: *mut raw::git_blame) -> Blame<'repo> {
338 _marker: marker::PhantomData,
343 unsafe fn from_raw(raw: *mut raw::git_blame_hunk) -> BlameHunk<'blame> {
347 _marker: marker::PhantomData,
350 diff -urN rustc-1.56.0-src/vendor/git2/src/blob.rs rustc-1.56.0-src-git2/vendor/git2/src/blob.rs
351 --- rustc-1.56.0-src/vendor/git2/src/blob.rs 2021-10-18 13:05:54.000000000 +0200
352 +++ rustc-1.56.0-src-git2/vendor/git2/src/blob.rs 2021-10-23 20:47:39.252455615 +0200
355 unsafe fn from_raw(raw: *mut raw::git_blob) -> Blob<'repo> {
359 _marker: marker::PhantomData,
364 unsafe fn from_raw(raw: *mut raw::git_writestream) -> BlobWriter<'repo> {
369 _marker: marker::PhantomData,
371 diff -urN rustc-1.56.0-src/vendor/git2/src/branch.rs rustc-1.56.0-src-git2/vendor/git2/src/branch.rs
372 --- rustc-1.56.0-src/vendor/git2/src/branch.rs 2021-10-18 13:05:54.000000000 +0200
373 +++ rustc-1.56.0-src-git2/vendor/git2/src/branch.rs 2021-10-23 20:47:39.252455615 +0200
375 Branch { inner: reference }
378 + /// Ensure the branch name is well-formed.
379 + pub fn name_is_valid(name: &str) -> Result<bool, Error> {
381 + let name = CString::new(name)?;
382 + let mut valid: libc::c_int = 0;
384 + try_call!(raw::git_branch_name_is_valid(&mut valid, name.as_ptr()));
389 /// Gain access to the reference that is this branch
390 pub fn get(&self) -> &Reference<'repo> {
394 pub unsafe fn from_raw(raw: *mut raw::git_branch_iterator) -> Branches<'repo> {
398 _marker: marker::PhantomData,
405 - use crate::BranchType;
406 + use crate::{Branch, BranchType};
412 b1.delete().unwrap();
416 + fn name_is_valid() {
417 + assert!(Branch::name_is_valid("foo").unwrap());
418 + assert!(!Branch::name_is_valid("").unwrap());
419 + assert!(!Branch::name_is_valid("with spaces").unwrap());
420 + assert!(!Branch::name_is_valid("~tilde").unwrap());
423 diff -urN rustc-1.56.0-src/vendor/git2/src/call.rs rustc-1.56.0-src-git2/vendor/git2/src/call.rs
424 --- rustc-1.56.0-src/vendor/git2/src/call.rs 2021-10-18 13:05:54.000000000 +0200
425 +++ rustc-1.56.0-src-git2/vendor/git2/src/call.rs 2021-10-23 20:47:39.252455615 +0200
428 use crate::call::Convert;
429 use crate::{raw, BranchType, ConfigLevel, Direction, ObjectType, ResetType};
430 - use crate::{AutotagOption, DiffFormat, FetchPrune, FileFavor, SubmoduleIgnore};
432 + AutotagOption, DiffFormat, FetchPrune, FileFavor, SubmoduleIgnore, SubmoduleUpdate,
435 impl<T: Copy> Convert<T> for T {
436 fn convert(&self) -> T {
442 + impl Convert<raw::git_submodule_update_t> for SubmoduleUpdate {
443 + fn convert(&self) -> raw::git_submodule_update_t {
445 + SubmoduleUpdate::Checkout => raw::GIT_SUBMODULE_UPDATE_CHECKOUT,
446 + SubmoduleUpdate::Rebase => raw::GIT_SUBMODULE_UPDATE_REBASE,
447 + SubmoduleUpdate::Merge => raw::GIT_SUBMODULE_UPDATE_MERGE,
448 + SubmoduleUpdate::None => raw::GIT_SUBMODULE_UPDATE_NONE,
449 + SubmoduleUpdate::Default => raw::GIT_SUBMODULE_UPDATE_DEFAULT,
454 impl Convert<raw::git_remote_autotag_option_t> for AutotagOption {
455 fn convert(&self) -> raw::git_remote_autotag_option_t {
456 diff -urN rustc-1.56.0-src/vendor/git2/src/cert.rs rustc-1.56.0-src-git2/vendor/git2/src/cert.rs
457 --- rustc-1.56.0-src/vendor/git2/src/cert.rs 2021-10-18 13:05:54.000000000 +0200
458 +++ rustc-1.56.0-src-git2/vendor/git2/src/cert.rs 2021-10-23 20:47:39.252455615 +0200
460 type Raw = *mut raw::git_cert;
461 unsafe fn from_raw(raw: *mut raw::git_cert) -> Cert<'a> {
465 _marker: marker::PhantomData,
468 diff -urN rustc-1.56.0-src/vendor/git2/src/commit.rs rustc-1.56.0-src-git2/vendor/git2/src/commit.rs
469 --- rustc-1.56.0-src/vendor/git2/src/commit.rs 2021-10-18 13:05:54.000000000 +0200
470 +++ rustc-1.56.0-src-git2/vendor/git2/src/commit.rs 2021-10-23 20:47:39.252455615 +0200
474 use crate::util::Binding;
475 -use crate::{raw, signature, Error, Object, Oid, Signature, Time, Tree};
476 +use crate::{raw, signature, Buf, Error, IntoCString, Mailmap, Object, Oid, Signature, Time, Tree};
478 /// A structure to represent a git [commit][1]
481 str::from_utf8(self.raw_header_bytes()).ok()
484 + /// Get an arbitrary header field.
485 + pub fn header_field_bytes<T: IntoCString>(&self, field: T) -> Result<Buf, Error> {
486 + let buf = Buf::new();
487 + let raw_field = field.into_c_string()?;
489 + try_call!(raw::git_commit_header_field(
498 /// Get the full raw text of the commit header.
499 pub fn raw_header_bytes(&self) -> &[u8] {
500 unsafe { crate::opt_bytes(self, raw::git_commit_raw_header(&*self.raw)).unwrap() }
505 + /// Get the author of this commit, using the mailmap to map names and email
506 + /// addresses to canonical real names and email addresses.
507 + pub fn author_with_mailmap(&self, mailmap: &Mailmap) -> Result<Signature<'static>, Error> {
508 + let mut ret = ptr::null_mut();
510 + try_call!(raw::git_commit_author_with_mailmap(
515 + Ok(Binding::from_raw(ret))
519 /// Get the committer of this commit.
520 pub fn committer(&self) -> Signature<'_> {
526 + /// Get the committer of this commit, using the mailmap to map names and email
527 + /// addresses to canonical real names and email addresses.
528 + pub fn committer_with_mailmap(&self, mailmap: &Mailmap) -> Result<Signature<'static>, Error> {
529 + let mut ret = ptr::null_mut();
531 + try_call!(raw::git_commit_committer_with_mailmap(
536 + Ok(Binding::from_raw(ret))
540 /// Amend this existing commit with all non-`None` values
542 /// This creates a new commit that is exactly the same as the old commit,
544 type Raw = *mut raw::git_commit;
545 unsafe fn from_raw(raw: *mut raw::git_commit) -> Commit<'repo> {
549 _marker: marker::PhantomData,
553 commit.tree().unwrap();
554 assert_eq!(commit.parents().count(), 0);
556 + let tree_header_bytes = commit.header_field_bytes("tree").unwrap();
558 + crate::Oid::from_str(tree_header_bytes.as_str().unwrap()).unwrap(),
561 assert_eq!(commit.author().name(), Some("name"));
562 assert_eq!(commit.author().email(), Some("email"));
563 assert_eq!(commit.committer().name(), Some("name"));
564 diff -urN rustc-1.56.0-src/vendor/git2/src/config.rs rustc-1.56.0-src-git2/vendor/git2/src/config.rs
565 --- rustc-1.56.0-src/vendor/git2/src/config.rs 2021-10-18 13:05:54.000000000 +0200
566 +++ rustc-1.56.0-src-git2/vendor/git2/src/config.rs 2021-10-23 20:47:39.252455615 +0200
568 impl Binding for Config {
569 type Raw = *mut raw::git_config;
570 unsafe fn from_raw(raw: *mut raw::git_config) -> Config {
571 - Config { raw: raw }
574 fn raw(&self) -> *mut raw::git_config {
578 unsafe fn from_raw(raw: *mut raw::git_config_entry) -> ConfigEntry<'cfg> {
582 _marker: marker::PhantomData,
587 unsafe fn from_raw(raw: *mut raw::git_config_iterator) -> ConfigEntries<'cfg> {
591 _marker: marker::PhantomData,
595 try_call_iter!(raw::git_config_next(&mut raw, self.raw));
596 Some(Ok(ConfigEntry {
600 _marker: marker::PhantomData,
603 diff -urN rustc-1.56.0-src/vendor/git2/src/cred.rs rustc-1.56.0-src-git2/vendor/git2/src/cred.rs
604 --- rustc-1.56.0-src/vendor/git2/src/cred.rs 2021-10-18 13:05:54.000000000 +0200
605 +++ rustc-1.56.0-src-git2/vendor/git2/src/cred.rs 2021-10-23 20:47:39.252455615 +0200
607 pub username: Option<String>,
608 protocol: Option<String>,
609 host: Option<String>,
611 path: Option<String>,
613 commands: Vec<String>,
615 type Raw = *mut raw::git_cred;
617 unsafe fn from_raw(raw: *mut raw::git_cred) -> Cred {
621 fn raw(&self) -> *mut raw::git_cred {
624 let mut ret = CredentialHelper {
630 url: url.to_string(),
632 if let Some(url::Host::Domain(s)) = url.host() {
633 ret.host = Some(s.to_string());
635 + ret.port = url.port();
636 ret.protocol = Some(url.scheme().to_string());
640 let _ = writeln!(stdin, "protocol={}", p);
642 if let Some(ref p) = self.host {
643 - let _ = writeln!(stdin, "host={}", p);
644 + if let Some(ref p2) = self.port {
645 + let _ = writeln!(stdin, "host={}:{}", p, p2);
647 + let _ = writeln!(stdin, "host={}", p);
650 if let Some(ref p) = self.path {
651 let _ = writeln!(stdin, "path={}", p);
656 + fn credential_helper9() {
657 + let cfg = test_cfg! {
658 + "credential.helper" => "!f() { while read line; do eval $line; done; if [ \"$host\" = example.com:3000 ]; then echo username=a; echo password=b; fi; }; f"
660 + let (u, p) = CredentialHelper::new("https://example.com:3000/foo/bar")
664 + assert_eq!(u, "a");
665 + assert_eq!(p, "b");
669 #[cfg(feature = "ssh")]
670 fn ssh_key_from_memory() {
671 let cred = Cred::ssh_key_from_memory(
672 diff -urN rustc-1.56.0-src/vendor/git2/src/describe.rs rustc-1.56.0-src-git2/vendor/git2/src/describe.rs
673 --- rustc-1.56.0-src/vendor/git2/src/describe.rs 2021-10-18 13:05:54.000000000 +0200
674 +++ rustc-1.56.0-src-git2/vendor/git2/src/describe.rs 2021-10-23 20:47:39.255788944 +0200
677 unsafe fn from_raw(raw: *mut raw::git_describe_result) -> Describe<'repo> {
681 _marker: marker::PhantomData,
684 diff -urN rustc-1.56.0-src/vendor/git2/src/diff.rs rustc-1.56.0-src-git2/vendor/git2/src/diff.rs
685 --- rustc-1.56.0-src/vendor/git2/src/diff.rs 2021-10-18 13:05:54.000000000 +0200
686 +++ rustc-1.56.0-src-git2/vendor/git2/src/diff.rs 2021-10-23 20:47:39.255788944 +0200
688 raw: raw::git_diff_format_email_options,
691 +/// Control behavior of formatting emails
692 +pub struct DiffPatchidOptions {
693 + raw: raw::git_diff_patchid_options,
696 /// An iterator over the diffs in a delta
697 pub struct Deltas<'diff> {
703 + /// Create an patchid from a diff.
704 + pub fn patchid(&self, opts: Option<&mut DiffPatchidOptions>) -> Result<Oid, Error> {
705 + let mut raw = raw::git_oid {
706 + id: [0; raw::GIT_OID_RAWSZ],
709 + try_call!(raw::git_diff_patchid(
712 + opts.map(|o| &mut o.raw)
714 + Ok(Binding::from_raw(&raw as *const _))
718 // TODO: num_deltas_of_type, find_similar
722 /// a patch file likely contains abbreviated object IDs, so the
723 /// object IDs parsed by this function will also be abreviated.
724 pub fn from_buffer(buffer: &[u8]) -> Result<Diff<'static>, Error> {
726 let mut diff: *mut raw::git_diff = std::ptr::null_mut();
728 // NOTE: Doesn't depend on repo, so lifetime can be 'static
730 (*data)(delta, hunk, line)
790 type Raw = *mut raw::git_diff;
791 unsafe fn from_raw(raw: *mut raw::git_diff) -> Diff<'repo> {
795 _marker: marker::PhantomData,
799 type Raw = *mut raw::git_diff_delta;
800 unsafe fn from_raw(raw: *mut raw::git_diff_delta) -> DiffDelta<'a> {
804 _marker: marker::PhantomData,
808 type Raw = *const raw::git_diff_file;
809 unsafe fn from_raw(raw: *const raw::git_diff_file) -> DiffFile<'a> {
813 _marker: marker::PhantomData,
817 self.flag(raw::GIT_DIFF_IGNORE_WHITESPACE_EOL, ignore)
820 + /// Ignore blank lines
821 + pub fn ignore_blank_lines(&mut self, ignore: bool) -> &mut DiffOptions {
822 + self.flag(raw::GIT_DIFF_IGNORE_BLANK_LINES, ignore)
825 /// When generating patch text, include the content of untracked files.
827 /// This automatically turns on `include_untracked` but it does not turn on
830 impl<'diff> ExactSizeIterator for Deltas<'diff> {}
832 +/// Line origin constants.
833 +#[derive(Copy, Clone, Debug, PartialEq)]
834 +pub enum DiffLineType {
835 + /// These values will be sent to `git_diff_line_cb` along with the line
841 + /// Both files have no LF at end
843 + /// Old has no LF at end, new does
845 + /// Old has LF at end, new does not
847 + /// The following values will only be sent to a `git_diff_line_cb` when
848 + /// the content of a diff is being formatted through `git_diff_print`.
852 + /// For "Binary files x and y differ"
856 +impl Binding for DiffLineType {
857 + type Raw = raw::git_diff_line_t;
858 + unsafe fn from_raw(raw: raw::git_diff_line_t) -> Self {
860 + raw::GIT_DIFF_LINE_CONTEXT => DiffLineType::Context,
861 + raw::GIT_DIFF_LINE_ADDITION => DiffLineType::Addition,
862 + raw::GIT_DIFF_LINE_DELETION => DiffLineType::Deletion,
863 + raw::GIT_DIFF_LINE_CONTEXT_EOFNL => DiffLineType::ContextEOFNL,
864 + raw::GIT_DIFF_LINE_ADD_EOFNL => DiffLineType::AddEOFNL,
865 + raw::GIT_DIFF_LINE_DEL_EOFNL => DiffLineType::DeleteEOFNL,
866 + raw::GIT_DIFF_LINE_FILE_HDR => DiffLineType::FileHeader,
867 + raw::GIT_DIFF_LINE_HUNK_HDR => DiffLineType::HunkHeader,
868 + raw::GIT_DIFF_LINE_BINARY => DiffLineType::Binary,
869 + _ => panic!("Unknown git diff line type"),
872 + fn raw(&self) -> raw::git_diff_line_t {
874 + DiffLineType::Context => raw::GIT_DIFF_LINE_CONTEXT,
875 + DiffLineType::Addition => raw::GIT_DIFF_LINE_ADDITION,
876 + DiffLineType::Deletion => raw::GIT_DIFF_LINE_DELETION,
877 + DiffLineType::ContextEOFNL => raw::GIT_DIFF_LINE_CONTEXT_EOFNL,
878 + DiffLineType::AddEOFNL => raw::GIT_DIFF_LINE_ADD_EOFNL,
879 + DiffLineType::DeleteEOFNL => raw::GIT_DIFF_LINE_DEL_EOFNL,
880 + DiffLineType::FileHeader => raw::GIT_DIFF_LINE_FILE_HDR,
881 + DiffLineType::HunkHeader => raw::GIT_DIFF_LINE_HUNK_HDR,
882 + DiffLineType::Binary => raw::GIT_DIFF_LINE_BINARY,
887 impl<'a> DiffLine<'a> {
888 /// Line number in old file or `None` for added line
889 pub fn old_lineno(&self) -> Option<u32> {
890 @@ -968,6 +1049,12 @@
894 + /// origin of this `DiffLine`.
896 + pub fn origin_value(&self) -> DiffLineType {
897 + unsafe { Binding::from_raw((*self.raw).origin as raw::git_diff_line_t) }
900 /// Sigil showing the origin of this `DiffLine`.
902 /// * ` ` - Line context
904 type Raw = *const raw::git_diff_line;
905 unsafe fn from_raw(raw: *const raw::git_diff_line) -> DiffLine<'a> {
909 _marker: marker::PhantomData,
912 @@ -1061,7 +1148,7 @@
913 type Raw = *const raw::git_diff_hunk;
914 unsafe fn from_raw(raw: *const raw::git_diff_hunk) -> DiffHunk<'a> {
918 _marker: marker::PhantomData,
921 @@ -1083,7 +1170,7 @@
925 - /// Get the total number of files chaned in a diff.
926 + /// Get the total number of files changed in a diff.
927 pub fn files_changed(&self) -> usize {
928 unsafe { raw::git_diff_stats_files_changed(&*self.raw) as usize }
930 @@ -1117,7 +1204,7 @@
931 type Raw = *mut raw::git_diff_stats;
933 unsafe fn from_raw(raw: *mut raw::git_diff_stats) -> DiffStats {
934 - DiffStats { raw: raw }
937 fn raw(&self) -> *mut raw::git_diff_stats {
939 @@ -1166,7 +1253,7 @@
940 type Raw = *const raw::git_diff_binary;
941 unsafe fn from_raw(raw: *const raw::git_diff_binary) -> DiffBinary<'a> {
945 _marker: marker::PhantomData,
948 @@ -1198,7 +1285,7 @@
949 type Raw = *const raw::git_diff_binary_file;
950 unsafe fn from_raw(raw: *const raw::git_diff_binary_file) -> DiffBinaryFile<'a> {
954 _marker: marker::PhantomData,
957 @@ -1433,9 +1520,29 @@
961 +impl DiffPatchidOptions {
962 + /// Creates a new set of patchid options,
963 + /// initialized to the default values
964 + pub fn new() -> Self {
965 + let mut opts = DiffPatchidOptions {
966 + raw: unsafe { mem::zeroed() },
970 + raw::git_diff_patchid_options_init(
972 + raw::GIT_DIFF_PATCHID_OPTIONS_VERSION,
983 - use crate::{DiffOptions, Signature, Time};
984 + use crate::{DiffLineType, DiffOptions, Oid, Signature, Time};
985 use std::borrow::Borrow;
988 @@ -1450,6 +1557,8 @@
989 assert_eq!(stats.insertions(), 0);
990 assert_eq!(stats.deletions(), 0);
991 assert_eq!(stats.files_changed(), 0);
992 + let patchid = diff.patchid(None).unwrap();
993 + assert_ne!(patchid, Oid::zero());
997 @@ -1684,4 +1793,58 @@
998 assert_eq!(line.trim(), "")
1003 + fn foreach_diff_line_origin_value() {
1004 + let foo_path = Path::new("foo");
1005 + let (td, repo) = crate::test::repo_init();
1006 + t!(t!(File::create(&td.path().join(foo_path))).write_all(b"bar\n"));
1007 + let mut index = t!(repo.index());
1008 + t!(index.add_path(foo_path));
1009 + let mut opts = DiffOptions::new();
1010 + opts.include_untracked(true);
1011 + let diff = t!(repo.diff_tree_to_index(None, Some(&index), Some(&mut opts)));
1012 + let mut origin_values: Vec<DiffLineType> = Vec::new();
1014 + &mut |_file, _progress| { true },
1017 + Some(&mut |_file, _hunk, line| {
1018 + origin_values.push(line.origin_value());
1022 + assert_eq!(origin_values.len(), 1);
1023 + assert_eq!(origin_values[0], DiffLineType::Addition);
1027 + fn foreach_exits_with_euser() {
1028 + let foo_path = Path::new("foo");
1029 + let bar_path = Path::new("foo");
1031 + let (td, repo) = crate::test::repo_init();
1032 + t!(t!(File::create(&td.path().join(foo_path))).write_all(b"bar\n"));
1034 + let mut index = t!(repo.index());
1035 + t!(index.add_path(foo_path));
1036 + t!(index.add_path(bar_path));
1038 + let mut opts = DiffOptions::new();
1039 + opts.include_untracked(true);
1040 + let diff = t!(repo.diff_tree_to_index(None, Some(&index), Some(&mut opts)));
1042 + let mut calls = 0;
1043 + let result = diff.foreach(
1044 + &mut |_file, _progress| {
1053 + assert_eq!(result.unwrap_err().code(), crate::ErrorCode::User);
1056 diff -urN rustc-1.56.0-src/vendor/git2/src/error.rs rustc-1.56.0-src-git2/vendor/git2/src/error.rs
1057 --- rustc-1.56.0-src/vendor/git2/src/error.rs 2021-10-18 13:05:54.000000000 +0200
1058 +++ rustc-1.56.0-src-git2/vendor/git2/src/error.rs 2021-10-23 20:47:39.255788944 +0200
1062 unsafe fn from_raw(code: c_int, ptr: *const raw::git_error) -> Error {
1063 - let msg = CStr::from_ptr((*ptr).message as *const _).to_bytes();
1064 - let msg = String::from_utf8_lossy(msg).into_owned();
1065 + let message = CStr::from_ptr((*ptr).message as *const _).to_bytes();
1066 + let message = String::from_utf8_lossy(message).into_owned();
1070 klass: (*ptr).klass,
1076 diff -urN rustc-1.56.0-src/vendor/git2/src/index.rs rustc-1.56.0-src-git2/vendor/git2/src/index.rs
1077 --- rustc-1.56.0-src/vendor/git2/src/index.rs 2021-10-18 13:05:54.000000000 +0200
1078 +++ rustc-1.56.0-src-git2/vendor/git2/src/index.rs 2021-10-23 20:47:39.255788944 +0200
1081 file_size: entry.file_size,
1082 id: *entry.id.raw(),
1085 flags_extended: entry.flags_extended,
1086 path: path.as_ptr(),
1087 mtime: raw::git_index_time {
1090 file_size: entry.file_size,
1091 id: *entry.id.raw(),
1094 flags_extended: entry.flags_extended,
1095 path: path.as_ptr(),
1096 mtime: raw::git_index_time {
1098 impl Binding for Index {
1099 type Raw = *mut raw::git_index;
1100 unsafe fn from_raw(raw: *mut raw::git_index) -> Index {
1101 - Index { raw: raw }
1104 fn raw(&self) -> *mut raw::git_index {
1106 @@ -718,15 +718,15 @@
1107 let path = slice::from_raw_parts(path as *const u8, pathlen);
1115 - file_size: file_size,
1122 id: Binding::from_raw(&id as *const _),
1124 - flags_extended: flags_extended,
1127 path: path.to_vec(),
1128 mtime: Binding::from_raw(mtime),
1129 ctime: Binding::from_raw(ctime),
1130 diff -urN rustc-1.56.0-src/vendor/git2/src/lib.rs rustc-1.56.0-src-git2/vendor/git2/src/lib.rs
1131 --- rustc-1.56.0-src/vendor/git2/src/lib.rs 2021-10-18 13:05:54.000000000 +0200
1132 +++ rustc-1.56.0-src-git2/vendor/git2/src/lib.rs 2021-10-23 20:47:39.255788944 +0200
1134 use std::sync::Once;
1136 pub use crate::apply::{ApplyLocation, ApplyOptions};
1137 +pub use crate::attr::AttrValue;
1138 pub use crate::blame::{Blame, BlameHunk, BlameIter, BlameOptions};
1139 pub use crate::blob::{Blob, BlobWriter};
1140 pub use crate::branch::{Branch, Branches};
1142 pub use crate::describe::{Describe, DescribeFormatOptions, DescribeOptions};
1143 pub use crate::diff::{Deltas, Diff, DiffDelta, DiffFile, DiffOptions};
1144 pub use crate::diff::{DiffBinary, DiffBinaryFile, DiffBinaryKind};
1145 -pub use crate::diff::{DiffFindOptions, DiffHunk, DiffLine, DiffStats};
1146 +pub use crate::diff::{DiffFindOptions, DiffHunk, DiffLine, DiffLineType, DiffStats};
1147 pub use crate::error::Error;
1148 pub use crate::index::{
1149 Index, IndexConflict, IndexConflicts, IndexEntries, IndexEntry, IndexMatchedPath,
1151 pub use crate::indexer::{IndexerProgress, Progress};
1152 +pub use crate::mailmap::Mailmap;
1153 pub use crate::mempack::Mempack;
1154 pub use crate::merge::{AnnotatedCommit, MergeOptions};
1155 -pub use crate::message::{message_prettify, DEFAULT_COMMENT_CHAR};
1156 +pub use crate::message::{
1157 + message_prettify, message_trailers_bytes, message_trailers_strs, MessageTrailersBytes,
1158 + MessageTrailersBytesIterator, MessageTrailersStrs, MessageTrailersStrsIterator,
1159 + DEFAULT_COMMENT_CHAR,
1161 pub use crate::note::{Note, Notes};
1162 pub use crate::object::Object;
1163 pub use crate::odb::{Odb, OdbObject, OdbPackwriter, OdbReader, OdbWriter};
1164 @@ -128,9 +134,12 @@
1165 pub use crate::submodule::{Submodule, SubmoduleUpdateOptions};
1166 pub use crate::tag::Tag;
1167 pub use crate::time::{IndexTime, Time};
1168 +pub use crate::tracing::{trace_set, TraceLevel};
1169 +pub use crate::transaction::Transaction;
1170 pub use crate::tree::{Tree, TreeEntry, TreeIter, TreeWalkMode, TreeWalkResult};
1171 pub use crate::treebuilder::TreeBuilder;
1172 pub use crate::util::IntoCString;
1173 +pub use crate::version::Version;
1174 pub use crate::worktree::{Worktree, WorktreeAddOptions, WorktreeLockStatus, WorktreePruneOptions};
1176 // Create a convinience method on bitflag struct which checks the given flag
1193 @@ -685,8 +696,11 @@
1205 @@ -929,6 +943,34 @@
1209 +impl SubmoduleIgnore {
1210 + /// Converts a [`raw::git_submodule_ignore_t`] to a [`SubmoduleIgnore`]
1211 + pub fn from_raw(raw: raw::git_submodule_ignore_t) -> Self {
1213 + raw::GIT_SUBMODULE_IGNORE_UNSPECIFIED => SubmoduleIgnore::Unspecified,
1214 + raw::GIT_SUBMODULE_IGNORE_NONE => SubmoduleIgnore::None,
1215 + raw::GIT_SUBMODULE_IGNORE_UNTRACKED => SubmoduleIgnore::Untracked,
1216 + raw::GIT_SUBMODULE_IGNORE_DIRTY => SubmoduleIgnore::Dirty,
1217 + raw::GIT_SUBMODULE_IGNORE_ALL => SubmoduleIgnore::All,
1218 + n => panic!("unknown submodule ignore rule: {}", n),
1223 +impl SubmoduleUpdate {
1224 + /// Converts a [`raw::git_submodule_update_t`] to a [`SubmoduleUpdate`]
1225 + pub fn from_raw(raw: raw::git_submodule_update_t) -> Self {
1227 + raw::GIT_SUBMODULE_UPDATE_CHECKOUT => SubmoduleUpdate::Checkout,
1228 + raw::GIT_SUBMODULE_UPDATE_REBASE => SubmoduleUpdate::Rebase,
1229 + raw::GIT_SUBMODULE_UPDATE_MERGE => SubmoduleUpdate::Merge,
1230 + raw::GIT_SUBMODULE_UPDATE_NONE => SubmoduleUpdate::None,
1231 + raw::GIT_SUBMODULE_UPDATE_DEFAULT => SubmoduleUpdate::Default,
1232 + n => panic!("unknown submodule update strategy: {}", n),
1238 /// Status flags for a single file
1240 @@ -1171,6 +1213,7 @@
1241 /// These values represent settings for the `submodule.$name.ignore`
1242 /// configuration value which says how deeply to look at the working
1243 /// directory when getting the submodule status.
1245 pub enum SubmoduleIgnore {
1246 /// Use the submodule's configuration
1248 @@ -1184,6 +1227,31 @@
1252 +/// Submodule update values
1254 +/// These values represent settings for the `submodule.$name.update`
1255 +/// configuration value which says how to handle `git submodule update`
1256 +/// for this submodule. The value is usually set in the ".gitmodules"
1257 +/// file and copied to ".git/config" when the submodule is initialized.
1259 +pub enum SubmoduleUpdate {
1260 + /// The default; when a submodule is updated, checkout the new detached
1261 + /// HEAD to the submodule directory.
1263 + /// Update by rebasing the current checked out branch onto the commit from
1264 + /// the superproject.
1266 + /// Update by merging the commit in the superproject into the current
1267 + /// checkout out branch of the submodule.
1269 + /// Do not update this submodule even when the commit in the superproject
1272 + /// Not used except as static initializer when we don't want any particular
1273 + /// update rule to be specified.
1279 pub struct PathspecFlags: u32 {
1280 diff -urN rustc-1.56.0-src/vendor/git2/src/mailmap.rs rustc-1.56.0-src-git2/vendor/git2/src/mailmap.rs
1281 --- rustc-1.56.0-src/vendor/git2/src/mailmap.rs 1970-01-01 01:00:00.000000000 +0100
1282 +++ rustc-1.56.0-src-git2/vendor/git2/src/mailmap.rs 2021-10-23 20:47:39.255788944 +0200
1284 +use std::ffi::CString;
1287 +use crate::util::Binding;
1288 +use crate::{raw, Error, Signature};
1290 +/// A structure to represent a repository's .mailmap file.
1292 +/// The representation cannot be written to disk.
1293 +pub struct Mailmap {
1294 + raw: *mut raw::git_mailmap,
1297 +impl Binding for Mailmap {
1298 + type Raw = *mut raw::git_mailmap;
1300 + unsafe fn from_raw(ptr: *mut raw::git_mailmap) -> Mailmap {
1301 + Mailmap { raw: ptr }
1304 + fn raw(&self) -> *mut raw::git_mailmap {
1309 +impl Drop for Mailmap {
1310 + fn drop(&mut self) {
1312 + raw::git_mailmap_free(self.raw);
1318 + /// Creates an empty, in-memory mailmap object.
1319 + pub fn new() -> Result<Mailmap, Error> {
1321 + let mut ret = ptr::null_mut();
1323 + try_call!(raw::git_mailmap_new(&mut ret));
1324 + Ok(Binding::from_raw(ret))
1328 + /// Creates an in-memory mailmap object representing the given buffer.
1329 + pub fn from_buffer(buf: &str) -> Result<Mailmap, Error> {
1331 + let mut ret = ptr::null_mut();
1332 + let len = buf.len();
1333 + let buf = CString::new(buf)?;
1335 + try_call!(raw::git_mailmap_from_buffer(&mut ret, buf, len));
1336 + Ok(Binding::from_raw(ret))
1340 + /// Adds a new entry to this in-memory mailmap object.
1343 + real_name: Option<&str>,
1344 + real_email: Option<&str>,
1345 + replace_name: Option<&str>,
1346 + replace_email: &str,
1347 + ) -> Result<(), Error> {
1348 + let real_name = crate::opt_cstr(real_name)?;
1349 + let real_email = crate::opt_cstr(real_email)?;
1350 + let replace_name = crate::opt_cstr(replace_name)?;
1351 + let replace_email = CString::new(replace_email)?;
1353 + try_call!(raw::git_mailmap_add_entry(
1364 + /// Resolves a signature to its real name and email address.
1365 + pub fn resolve_signature(&self, sig: &Signature<'_>) -> Result<Signature<'static>, Error> {
1366 + let mut ret = ptr::null_mut();
1368 + try_call!(raw::git_mailmap_resolve_signature(
1373 + Ok(Binding::from_raw(ret))
1384 + let sig_name = "name";
1385 + let sig_email = "email";
1386 + let sig = t!(Signature::now(sig_name, sig_email));
1388 + let mut mm = t!(Mailmap::new());
1390 + let mailmapped_sig = t!(mm.resolve_signature(&sig));
1391 + assert_eq!(mailmapped_sig.name(), Some(sig_name));
1392 + assert_eq!(mailmapped_sig.email(), Some(sig_email));
1394 + t!(mm.add_entry(None, None, None, sig_email));
1396 + Some("real name"),
1397 + Some("real@email"),
1402 + let mailmapped_sig = t!(mm.resolve_signature(&sig));
1403 + assert_eq!(mailmapped_sig.name(), Some("real name"));
1404 + assert_eq!(mailmapped_sig.email(), Some("real@email"));
1408 + fn from_buffer() {
1409 + let buf = "<prøper@emæil> <email>";
1410 + let mm = t!(Mailmap::from_buffer(&buf));
1412 + let sig = t!(Signature::now("name", "email"));
1413 + let mailmapped_sig = t!(mm.resolve_signature(&sig));
1414 + assert_eq!(mailmapped_sig.name(), Some("name"));
1415 + assert_eq!(mailmapped_sig.email(), Some("prøper@emæil"));
1418 diff -urN rustc-1.56.0-src/vendor/git2/src/mempack.rs rustc-1.56.0-src-git2/vendor/git2/src/mempack.rs
1419 --- rustc-1.56.0-src/vendor/git2/src/mempack.rs 2021-10-18 13:05:54.000000000 +0200
1420 +++ rustc-1.56.0-src-git2/vendor/git2/src/mempack.rs 2021-10-23 20:47:39.255788944 +0200
1423 unsafe fn from_raw(raw: *mut raw::git_odb_backend) -> Mempack<'odb> {
1427 _marker: marker::PhantomData,
1430 diff -urN rustc-1.56.0-src/vendor/git2/src/merge.rs rustc-1.56.0-src-git2/vendor/git2/src/merge.rs
1431 --- rustc-1.56.0-src/vendor/git2/src/merge.rs 2021-10-18 13:05:54.000000000 +0200
1432 +++ rustc-1.56.0-src-git2/vendor/git2/src/merge.rs 2021-10-23 20:47:39.255788944 +0200
1434 type Raw = *mut raw::git_annotated_commit;
1435 unsafe fn from_raw(raw: *mut raw::git_annotated_commit) -> AnnotatedCommit<'repo> {
1439 _marker: marker::PhantomData,
1442 diff -urN rustc-1.56.0-src/vendor/git2/src/message.rs rustc-1.56.0-src-git2/vendor/git2/src/message.rs
1443 --- rustc-1.56.0-src/vendor/git2/src/message.rs 2021-10-18 13:05:54.000000000 +0200
1444 +++ rustc-1.56.0-src-git2/vendor/git2/src/message.rs 2021-10-23 20:47:39.255788944 +0200
1446 +use core::ops::Range;
1447 +use std::ffi::CStr;
1448 use std::ffi::CString;
1451 use libc::{c_char, c_int};
1453 @@ -31,12 +34,216 @@
1454 /// The default comment character for `message_prettify` ('#')
1455 pub const DEFAULT_COMMENT_CHAR: Option<u8> = Some(b'#');
1457 +/// Get the trailers for the given message.
1459 +/// Use this function when you are dealing with a UTF-8-encoded message.
1460 +pub fn message_trailers_strs(message: &str) -> Result<MessageTrailersStrs, Error> {
1461 + _message_trailers(message.into_c_string()?).map(|res| MessageTrailersStrs(res))
1464 +/// Get the trailers for the given message.
1466 +/// Use this function when the message might not be UTF-8-encoded,
1467 +/// or if you want to handle the returned trailer key–value pairs
1469 +pub fn message_trailers_bytes<S: IntoCString>(message: S) -> Result<MessageTrailersBytes, Error> {
1470 + _message_trailers(message.into_c_string()?).map(|res| MessageTrailersBytes(res))
1473 +fn _message_trailers(message: CString) -> Result<MessageTrailers, Error> {
1474 + let ret = MessageTrailers::new();
1476 + try_call!(raw::git_message_trailers(ret.raw(), message));
1481 +/// Collection of UTF-8-encoded trailers.
1483 +/// Use `iter()` to get access to the values.
1484 +pub struct MessageTrailersStrs(MessageTrailers);
1486 +impl MessageTrailersStrs {
1487 + /// Create a borrowed iterator.
1488 + pub fn iter(&self) -> MessageTrailersStrsIterator<'_> {
1489 + MessageTrailersStrsIterator(self.0.iter())
1491 + /// The number of trailer key–value pairs.
1492 + pub fn len(&self) -> usize {
1495 + /// Convert to the “bytes” variant.
1496 + pub fn to_bytes(self) -> MessageTrailersBytes {
1497 + MessageTrailersBytes(self.0)
1501 +/// Collection of unencoded (bytes) trailers.
1503 +/// Use `iter()` to get access to the values.
1504 +pub struct MessageTrailersBytes(MessageTrailers);
1506 +impl MessageTrailersBytes {
1507 + /// Create a borrowed iterator.
1508 + pub fn iter(&self) -> MessageTrailersBytesIterator<'_> {
1509 + MessageTrailersBytesIterator(self.0.iter())
1511 + /// The number of trailer key–value pairs.
1512 + pub fn len(&self) -> usize {
1517 +struct MessageTrailers {
1518 + raw: raw::git_message_trailer_array,
1521 +impl MessageTrailers {
1522 + fn new() -> MessageTrailers {
1525 + Binding::from_raw(&mut raw::git_message_trailer_array {
1526 + trailers: ptr::null_mut(),
1528 + _trailer_block: ptr::null_mut(),
1532 + fn iter(&self) -> MessageTrailersIterator<'_> {
1533 + MessageTrailersIterator {
1537 + end: self.raw.count,
1541 + fn len(&self) -> usize {
1546 +impl Drop for MessageTrailers {
1547 + fn drop(&mut self) {
1549 + raw::git_message_trailer_array_free(&mut self.raw);
1554 +impl Binding for MessageTrailers {
1555 + type Raw = *mut raw::git_message_trailer_array;
1556 + unsafe fn from_raw(raw: *mut raw::git_message_trailer_array) -> MessageTrailers {
1557 + MessageTrailers { raw: *raw }
1559 + fn raw(&self) -> *mut raw::git_message_trailer_array {
1560 + &self.raw as *const _ as *mut _
1564 +struct MessageTrailersIterator<'a> {
1565 + trailers: &'a MessageTrailers,
1566 + range: Range<usize>,
1569 +fn to_raw_tuple(trailers: &MessageTrailers, index: usize) -> (*const c_char, *const c_char) {
1571 + let addr = trailers.raw.trailers.wrapping_add(index);
1572 + ((*addr).key, (*addr).value)
1576 +/// Borrowed iterator over the UTF-8-encoded trailers.
1577 +pub struct MessageTrailersStrsIterator<'a>(MessageTrailersIterator<'a>);
1579 +impl<'pair> Iterator for MessageTrailersStrsIterator<'pair> {
1580 + type Item = (&'pair str, &'pair str);
1582 + fn next(&mut self) -> Option<Self::Item> {
1586 + .map(|index| to_str_tuple(&self.0.trailers, index))
1589 + fn size_hint(&self) -> (usize, Option<usize>) {
1590 + self.0.range.size_hint()
1594 +impl ExactSizeIterator for MessageTrailersStrsIterator<'_> {
1595 + fn len(&self) -> usize {
1596 + self.0.range.len()
1600 +impl DoubleEndedIterator for MessageTrailersStrsIterator<'_> {
1601 + fn next_back(&mut self) -> Option<Self::Item> {
1605 + .map(|index| to_str_tuple(&self.0.trailers, index))
1609 +fn to_str_tuple(trailers: &MessageTrailers, index: usize) -> (&str, &str) {
1611 + let (rkey, rvalue) = to_raw_tuple(&trailers, index);
1612 + let key = CStr::from_ptr(rkey).to_str().unwrap();
1613 + let value = CStr::from_ptr(rvalue).to_str().unwrap();
1618 +/// Borrowed iterator over the raw (bytes) trailers.
1619 +pub struct MessageTrailersBytesIterator<'a>(MessageTrailersIterator<'a>);
1621 +impl<'pair> Iterator for MessageTrailersBytesIterator<'pair> {
1622 + type Item = (&'pair [u8], &'pair [u8]);
1624 + fn next(&mut self) -> Option<Self::Item> {
1628 + .map(|index| to_bytes_tuple(&self.0.trailers, index))
1631 + fn size_hint(&self) -> (usize, Option<usize>) {
1632 + self.0.range.size_hint()
1636 +impl ExactSizeIterator for MessageTrailersBytesIterator<'_> {
1637 + fn len(&self) -> usize {
1638 + self.0.range.len()
1642 +impl DoubleEndedIterator for MessageTrailersBytesIterator<'_> {
1643 + fn next_back(&mut self) -> Option<Self::Item> {
1647 + .map(|index| to_bytes_tuple(&self.0.trailers, index))
1651 +fn to_bytes_tuple(trailers: &MessageTrailers, index: usize) -> (&[u8], &[u8]) {
1653 + let (rkey, rvalue) = to_raw_tuple(&trailers, index);
1654 + let key = CStr::from_ptr(rkey).to_bytes();
1655 + let value = CStr::from_ptr(rvalue).to_bytes();
1662 - use crate::{message_prettify, DEFAULT_COMMENT_CHAR};
1666 + use crate::{message_prettify, DEFAULT_COMMENT_CHAR};
1668 // This does not attempt to duplicate the extensive tests for
1669 // git_message_prettify in libgit2, just a few representative values to
1670 // make sure the interface works as expected.
1678 + use crate::{message_trailers_bytes, message_trailers_strs, MessageTrailersStrs};
1679 + use std::collections::HashMap;
1683 +WHAT ARE WE HERE FOR
1685 +What are we here for?
1689 + let expected: HashMap<&str, &str> = HashMap::new();
1690 + assert_eq!(expected, to_map(&message_trailers_strs(message1).unwrap()));
1696 +We are out of tomatoes.
1698 +Spoken-by: Major Turnips
1699 +Transcribed-by: Seargant Persimmons
1700 +Signed-off-by: Colonel Kale
1702 + let expected: HashMap<&str, &str> = vec![
1703 + ("Spoken-by", "Major Turnips"),
1704 + ("Transcribed-by", "Seargant Persimmons"),
1705 + ("Signed-off-by", "Colonel Kale"),
1709 + assert_eq!(expected, to_map(&message_trailers_strs(message2).unwrap()));
1711 + // ignore everything after `---`
1713 +The fate of Seargant Green-Peppers
1715 +Seargant Green-Peppers was killed by Caterpillar Battalion 44.
1717 +Signed-off-by: Colonel Kale
1719 +I never liked that guy, anyway.
1721 +Opined-by: Corporal Garlic
1723 + let expected: HashMap<&str, &str> = vec![("Signed-off-by", "Colonel Kale")]
1726 + assert_eq!(expected, to_map(&message_trailers_strs(message3).unwrap()));
1728 + // Raw bytes message; not valid UTF-8
1729 + // Source: https://stackoverflow.com/a/3886015/1725151
1733 +Am I a malformed brussels sprout?
1735 +Signed-off-by: Lieutenant \xe2\x28\xa1prout
1738 + let trailer = message_trailers_bytes(&message4[..]).unwrap();
1739 + let expected = (&b"Signed-off-by"[..], &b"Lieutenant \xe2\x28\xa1prout"[..]);
1740 + let actual = trailer.iter().next().unwrap();
1741 + assert_eq!(expected, actual);
1743 + fn to_map(trailers: &MessageTrailersStrs) -> HashMap<&str, &str> {
1744 + let mut map = HashMap::with_capacity(trailers.len());
1745 + for (key, value) in trailers.iter() {
1746 + map.insert(key, value);
1752 diff -urN rustc-1.56.0-src/vendor/git2/src/note.rs rustc-1.56.0-src-git2/vendor/git2/src/note.rs
1753 --- rustc-1.56.0-src/vendor/git2/src/note.rs 2021-10-18 13:05:54.000000000 +0200
1754 +++ rustc-1.56.0-src-git2/vendor/git2/src/note.rs 2021-10-23 20:47:39.255788944 +0200
1756 type Raw = *mut raw::git_note;
1757 unsafe fn from_raw(raw: *mut raw::git_note) -> Note<'repo> {
1761 _marker: marker::PhantomData,
1765 type Raw = *mut raw::git_note_iterator;
1766 unsafe fn from_raw(raw: *mut raw::git_note_iterator) -> Notes<'repo> {
1770 _marker: marker::PhantomData,
1773 diff -urN rustc-1.56.0-src/vendor/git2/src/object.rs rustc-1.56.0-src-git2/vendor/git2/src/object.rs
1774 --- rustc-1.56.0-src/vendor/git2/src/object.rs 2021-10-18 13:05:54.000000000 +0200
1775 +++ rustc-1.56.0-src-git2/vendor/git2/src/object.rs 2021-10-23 20:47:39.255788944 +0200
1778 unsafe fn from_raw(raw: *mut raw::git_object) -> Object<'repo> {
1782 _marker: marker::PhantomData,
1785 diff -urN rustc-1.56.0-src/vendor/git2/src/odb.rs rustc-1.56.0-src-git2/vendor/git2/src/odb.rs
1786 --- rustc-1.56.0-src/vendor/git2/src/odb.rs 2021-10-18 13:05:54.000000000 +0200
1787 +++ rustc-1.56.0-src-git2/vendor/git2/src/odb.rs 2021-10-23 20:47:39.255788944 +0200
1790 unsafe fn from_raw(raw: *mut raw::git_odb) -> Odb<'repo> {
1794 _marker: marker::PhantomData,
1799 unsafe fn from_raw(raw: *mut raw::git_odb_object) -> OdbObject<'a> {
1803 _marker: marker::PhantomData,
1808 unsafe fn from_raw(raw: *mut raw::git_odb_stream) -> OdbReader<'repo> {
1812 _marker: marker::PhantomData,
1817 unsafe fn from_raw(raw: *mut raw::git_odb_stream) -> OdbWriter<'repo> {
1821 _marker: marker::PhantomData,
1824 diff -urN rustc-1.56.0-src/vendor/git2/src/oid_array.rs rustc-1.56.0-src-git2/vendor/git2/src/oid_array.rs
1825 --- rustc-1.56.0-src/vendor/git2/src/oid_array.rs 2021-10-18 13:05:54.000000000 +0200
1826 +++ rustc-1.56.0-src-git2/vendor/git2/src/oid_array.rs 2021-10-23 20:47:39.255788944 +0200
1828 impl Binding for OidArray {
1829 type Raw = raw::git_oidarray;
1830 unsafe fn from_raw(raw: raw::git_oidarray) -> OidArray {
1831 - OidArray { raw: raw }
1834 fn raw(&self) -> raw::git_oidarray {
1836 diff -urN rustc-1.56.0-src/vendor/git2/src/oid.rs rustc-1.56.0-src-git2/vendor/git2/src/oid.rs
1837 --- rustc-1.56.0-src/vendor/git2/src/oid.rs 2021-10-18 13:05:54.000000000 +0200
1838 +++ rustc-1.56.0-src-git2/vendor/git2/src/oid.rs 2021-10-23 20:47:39.255788944 +0200
1840 s.len() as libc::size_t
1843 - Ok(Oid { raw: raw })
1847 /// Parse a raw object id into an Oid structure.
1850 try_call!(raw::git_oid_fromraw(&mut raw, bytes.as_ptr()));
1852 - Ok(Oid { raw: raw })
1857 diff -urN rustc-1.56.0-src/vendor/git2/src/opts.rs rustc-1.56.0-src-git2/vendor/git2/src/opts.rs
1858 --- rustc-1.56.0-src/vendor/git2/src/opts.rs 2021-10-18 13:05:54.000000000 +0200
1859 +++ rustc-1.56.0-src-git2/vendor/git2/src/opts.rs 2021-10-23 20:47:39.255788944 +0200
1861 use std::ffi::CString;
1863 use crate::util::Binding;
1864 -use crate::{call, raw, Buf, ConfigLevel, Error, IntoCString};
1865 +use crate::{raw, Buf, ConfigLevel, Error, IntoCString};
1867 /// Set the search path for a level of config data. The search path applied to
1868 /// shared attributes and ignore files, too.
1873 - call::c_try(raw::git_libgit2_opts(
1874 + try_call!(raw::git_libgit2_opts(
1875 raw::GIT_OPT_SET_SEARCH_PATH as libc::c_int,
1876 level as libc::c_int,
1877 - path.into_c_string()?.as_ptr(),
1879 + path.into_c_string()?.as_ptr()
1885 /// the global state.
1886 pub unsafe fn reset_search_path(level: ConfigLevel) -> Result<(), Error> {
1888 - call::c_try(raw::git_libgit2_opts(
1889 + try_call!(raw::git_libgit2_opts(
1890 raw::GIT_OPT_SET_SEARCH_PATH as libc::c_int,
1891 level as libc::c_int,
1892 - core::ptr::null::<u8>(),
1894 + core::ptr::null::<u8>()
1900 pub unsafe fn get_search_path(level: ConfigLevel) -> Result<CString, Error> {
1902 let buf = Buf::new();
1903 - call::c_try(raw::git_libgit2_opts(
1904 + try_call!(raw::git_libgit2_opts(
1905 raw::GIT_OPT_GET_SEARCH_PATH as libc::c_int,
1906 level as libc::c_int,
1909 + buf.raw() as *const _
1914 diff -urN rustc-1.56.0-src/vendor/git2/src/packbuilder.rs rustc-1.56.0-src-git2/vendor/git2/src/packbuilder.rs
1915 --- rustc-1.56.0-src/vendor/git2/src/packbuilder.rs 2021-10-18 13:05:54.000000000 +0200
1916 +++ rustc-1.56.0-src-git2/vendor/git2/src/packbuilder.rs 2021-10-23 20:47:39.255788944 +0200
1918 /// A builder for creating a packfile
1919 pub struct PackBuilder<'repo> {
1920 raw: *mut raw::git_packbuilder,
1921 - progress: Option<Box<Box<ProgressCb<'repo>>>>,
1922 + _progress: Option<Box<Box<ProgressCb<'repo>>>>,
1923 _marker: marker::PhantomData<&'repo Repository>,
1930 - self.progress = Some(progress);
1931 + self._progress = Some(progress);
1939 - self.progress = None;
1940 + self._progress = None;
1945 unsafe fn from_raw(ptr: *mut raw::git_packbuilder) -> PackBuilder<'repo> {
1950 _marker: marker::PhantomData,
1953 diff -urN rustc-1.56.0-src/vendor/git2/src/panic.rs rustc-1.56.0-src-git2/vendor/git2/src/panic.rs
1954 --- rustc-1.56.0-src/vendor/git2/src/panic.rs 2021-10-18 13:05:54.000000000 +0200
1955 +++ rustc-1.56.0-src-git2/vendor/git2/src/panic.rs 2021-10-23 20:47:39.255788944 +0200
1958 let err = LAST_ERROR.with(|slot| slot.borrow_mut().take());
1959 if let Some(err) = err {
1961 + std::panic::resume_unwind(err);
1965 diff -urN rustc-1.56.0-src/vendor/git2/src/patch.rs rustc-1.56.0-src-git2/vendor/git2/src/patch.rs
1966 --- rustc-1.56.0-src/vendor/git2/src/patch.rs 2021-10-18 13:05:54.000000000 +0200
1967 +++ rustc-1.56.0-src-git2/vendor/git2/src/patch.rs 2021-10-23 20:47:39.255788944 +0200
1969 type Raw = *mut raw::git_patch;
1970 unsafe fn from_raw(raw: Self::Raw) -> Self {
1974 buffers: PhantomData,
1977 diff -urN rustc-1.56.0-src/vendor/git2/src/pathspec.rs rustc-1.56.0-src-git2/vendor/git2/src/pathspec.rs
1978 --- rustc-1.56.0-src/vendor/git2/src/pathspec.rs 2021-10-18 13:05:54.000000000 +0200
1979 +++ rustc-1.56.0-src-git2/vendor/git2/src/pathspec.rs 2021-10-23 20:47:39.255788944 +0200
1981 type Raw = *mut raw::git_pathspec;
1983 unsafe fn from_raw(raw: *mut raw::git_pathspec) -> Pathspec {
1984 - Pathspec { raw: raw }
1987 fn raw(&self) -> *mut raw::git_pathspec {
1991 unsafe fn from_raw(raw: *mut raw::git_pathspec_match_list) -> PathspecMatchList<'ps> {
1995 _marker: marker::PhantomData,
1998 diff -urN rustc-1.56.0-src/vendor/git2/src/rebase.rs rustc-1.56.0-src-git2/vendor/git2/src/rebase.rs
1999 --- rustc-1.56.0-src/vendor/git2/src/rebase.rs 2021-10-18 13:05:54.000000000 +0200
2000 +++ rustc-1.56.0-src-git2/vendor/git2/src/rebase.rs 2021-10-23 20:47:39.255788944 +0200
2002 type Raw = *mut raw::git_rebase;
2003 unsafe fn from_raw(raw: *mut raw::git_rebase) -> Rebase<'repo> {
2007 _marker: marker::PhantomData,
2011 type Raw = *const raw::git_rebase_operation;
2012 unsafe fn from_raw(raw: *const raw::git_rebase_operation) -> RebaseOperation<'rebase> {
2016 _marker: marker::PhantomData,
2019 diff -urN rustc-1.56.0-src/vendor/git2/src/reference.rs rustc-1.56.0-src-git2/vendor/git2/src/reference.rs
2020 --- rustc-1.56.0-src/vendor/git2/src/reference.rs 2021-10-18 13:05:54.000000000 +0200
2021 +++ rustc-1.56.0-src-git2/vendor/git2/src/reference.rs 2021-10-23 20:47:39.255788944 +0200
2023 type Raw = *mut raw::git_reference;
2024 unsafe fn from_raw(raw: *mut raw::git_reference) -> Reference<'repo> {
2028 _marker: marker::PhantomData,
2032 type Raw = *mut raw::git_reference_iterator;
2033 unsafe fn from_raw(raw: *mut raw::git_reference_iterator) -> References<'repo> {
2037 _marker: marker::PhantomData,
2040 diff -urN rustc-1.56.0-src/vendor/git2/src/reflog.rs rustc-1.56.0-src-git2/vendor/git2/src/reflog.rs
2041 --- rustc-1.56.0-src/vendor/git2/src/reflog.rs 2021-10-18 13:05:54.000000000 +0200
2042 +++ rustc-1.56.0-src-git2/vendor/git2/src/reflog.rs 2021-10-23 20:47:39.255788944 +0200
2044 type Raw = *mut raw::git_reflog;
2046 unsafe fn from_raw(raw: *mut raw::git_reflog) -> Reflog {
2047 - Reflog { raw: raw }
2050 fn raw(&self) -> *mut raw::git_reflog {
2054 unsafe fn from_raw(raw: *const raw::git_reflog_entry) -> ReflogEntry<'reflog> {
2058 _marker: marker::PhantomData,
2061 diff -urN rustc-1.56.0-src/vendor/git2/src/refspec.rs rustc-1.56.0-src-git2/vendor/git2/src/refspec.rs
2062 --- rustc-1.56.0-src/vendor/git2/src/refspec.rs 2021-10-18 13:05:54.000000000 +0200
2063 +++ rustc-1.56.0-src-git2/vendor/git2/src/refspec.rs 2021-10-23 20:47:39.255788944 +0200
2066 unsafe fn from_raw(raw: *const raw::git_refspec) -> Refspec<'remote> {
2070 _marker: marker::PhantomData,
2073 diff -urN rustc-1.56.0-src/vendor/git2/src/remote.rs rustc-1.56.0-src-git2/vendor/git2/src/remote.rs
2074 --- rustc-1.56.0-src/vendor/git2/src/remote.rs 2021-10-18 13:05:54.000000000 +0200
2075 +++ rustc-1.56.0-src-git2/vendor/git2/src/remote.rs 2021-10-23 20:47:39.255788944 +0200
2078 -use std::ffi::CString;
2079 +use raw::git_strarray;
2082 use std::ops::Range;
2086 +use std::{ffi::CString, os::raw::c_char};
2088 use crate::string_array::StringArray;
2089 use crate::util::Binding;
2092 update_fetchhead: bool,
2093 download_tags: AutotagOption,
2094 + custom_headers: Vec<CString>,
2095 + custom_headers_ptrs: Vec<*const c_char>,
2098 /// Options to control the behavior of a git push.
2100 callbacks: Option<RemoteCallbacks<'cb>>,
2101 proxy: Option<ProxyOptions<'cb>>,
2102 pb_parallelism: u32,
2103 + custom_headers: Vec<CString>,
2104 + custom_headers_ptrs: Vec<*const c_char>,
2107 /// Holds callbacks for a connection to a `Remote`. Disconnects when dropped
2109 pub fn remote_into_raw(remote: Remote<'_>) -> *mut raw::git_remote {
2110 let ret = remote.raw;
2111 mem::forget(remote);
2116 impl<'repo> Remote<'repo> {
2117 @@ -221,6 +226,17 @@
2121 + /// Cancel the operation
2123 + /// At certain points in its operation, the network code checks whether the
2124 + /// operation has been cancelled and if so stops the operation.
2125 + pub fn stop(&mut self) -> Result<(), Error> {
2127 + try_call!(raw::git_remote_stop(self.raw));
2132 /// Get the number of refspecs for a remote
2133 pub fn refspecs(&self) -> Refspecs<'_> {
2134 let cnt = unsafe { raw::git_remote_refspec_count(&*self.raw) as usize };
2135 @@ -345,6 +361,15 @@
2139 + /// Prune tracking refs that are no longer present on remote
2140 + pub fn prune(&mut self, callbacks: Option<RemoteCallbacks<'_>>) -> Result<(), Error> {
2141 + let cbs = Box::new(callbacks.unwrap_or_else(RemoteCallbacks::new));
2143 + try_call!(raw::git_remote_prune(self.raw, &cbs.raw()));
2148 /// Get the remote's list of fetch refspecs
2149 pub fn fetch_refspecs(&self) -> Result<StringArray, Error> {
2153 unsafe fn from_raw(raw: *mut raw::git_remote) -> Remote<'repo> {
2157 _marker: marker::PhantomData,
2161 prune: FetchPrune::Unspecified,
2162 update_fetchhead: true,
2163 download_tags: AutotagOption::Unspecified,
2164 + custom_headers: Vec::new(),
2165 + custom_headers_ptrs: Vec::new(),
2169 @@ -491,6 +518,16 @@
2170 self.download_tags = opt;
2174 + /// Set extra headers for this fetch operation.
2175 + pub fn custom_headers(&mut self, custom_headers: &[&str]) -> &mut Self {
2176 + self.custom_headers = custom_headers
2178 + .map(|&s| CString::new(s).unwrap())
2180 + self.custom_headers_ptrs = self.custom_headers.iter().map(|s| s.as_ptr()).collect();
2185 impl<'cb> Binding for FetchOptions<'cb> {
2186 @@ -515,10 +552,9 @@
2187 prune: crate::call::convert(&self.prune),
2188 update_fetchhead: crate::call::convert(&self.update_fetchhead),
2189 download_tags: crate::call::convert(&self.download_tags),
2190 - // TODO: expose this as a builder option
2191 - custom_headers: raw::git_strarray {
2193 - strings: ptr::null_mut(),
2194 + custom_headers: git_strarray {
2195 + count: self.custom_headers_ptrs.len(),
2196 + strings: self.custom_headers_ptrs.as_ptr() as *mut _,
2204 + custom_headers: Vec::new(),
2205 + custom_headers_ptrs: Vec::new(),
2209 @@ -562,6 +600,16 @@
2210 self.pb_parallelism = parallel;
2214 + /// Set extra headers for this push operation.
2215 + pub fn custom_headers(&mut self, custom_headers: &[&str]) -> &mut Self {
2216 + self.custom_headers = custom_headers
2218 + .map(|&s| CString::new(s).unwrap())
2220 + self.custom_headers_ptrs = self.custom_headers.iter().map(|s| s.as_ptr()).collect();
2225 impl<'cb> Binding for PushOptions<'cb> {
2226 @@ -584,10 +632,9 @@
2228 .unwrap_or_else(|| ProxyOptions::new().raw()),
2229 pb_parallelism: self.pb_parallelism as libc::c_uint,
2230 - // TODO: expose this as a builder option
2231 - custom_headers: raw::git_strarray {
2233 - strings: ptr::null_mut(),
2234 + custom_headers: git_strarray {
2235 + count: self.custom_headers_ptrs.len(),
2236 + strings: self.custom_headers_ptrs.as_ptr() as *mut _,
2240 @@ -614,6 +661,11 @@
2241 pub fn default_branch(&self) -> Result<Buf, Error> {
2242 self.remote.default_branch()
2245 + /// access remote bound to this connection
2246 + pub fn remote(&mut self) -> &mut Remote<'repo> {
2251 impl<'repo, 'connection, 'cb> Drop for RemoteConnection<'repo, 'connection, 'cb> {
2255 let repo = t!(Repository::init(td.path()));
2256 - let origin = t!(repo.find_remote("origin"));
2257 + let mut origin = t!(repo.find_remote("origin"));
2258 assert_eq!(origin.name(), Some("origin"));
2259 assert_eq!(origin.url(), Some("/path/to/nowhere"));
2260 assert_eq!(origin.pushurl(), None);
2263 let stats = origin.stats();
2264 assert_eq!(stats.total_objects(), 0);
2266 + t!(origin.stop());
2270 @@ -847,4 +901,46 @@
2271 let commit = repo.find_commit(commit).unwrap();
2272 assert_eq!(commit.message(), Some("initial"));
2277 + let (td, remote_repo) = crate::test::repo_init();
2278 + let oid = remote_repo.head().unwrap().target().unwrap();
2279 + let commit = remote_repo.find_commit(oid).unwrap();
2280 + remote_repo.branch("stale", &commit, true).unwrap();
2282 + let td2 = TempDir::new().unwrap();
2283 + let url = crate::test::path2url(&td.path());
2284 + let repo = Repository::clone(&url, &td2).unwrap();
2286 + fn assert_branch_count(repo: &Repository, count: usize) {
2288 + repo.branches(Some(crate::BranchType::Remote))
2290 + .filter(|b| b.as_ref().unwrap().0.name().unwrap() == Some("origin/stale"))
2296 + assert_branch_count(&repo, 1);
2298 + // delete `stale` branch on remote repo
2299 + let mut stale_branch = remote_repo
2300 + .find_branch("stale", crate::BranchType::Local)
2302 + stale_branch.delete().unwrap();
2305 + let mut remote = repo.find_remote("origin").unwrap();
2306 + remote.connect(Direction::Push).unwrap();
2307 + let mut callbacks = RemoteCallbacks::new();
2308 + callbacks.update_tips(|refname, _a, b| {
2309 + assert_eq!(refname, "refs/remotes/origin/stale");
2310 + assert!(b.is_zero());
2313 + remote.prune(Some(callbacks)).unwrap();
2314 + assert_branch_count(&repo, 0);
2317 diff -urN rustc-1.56.0-src/vendor/git2/src/repo.rs rustc-1.56.0-src-git2/vendor/git2/src/repo.rs
2318 --- rustc-1.56.0-src/vendor/git2/src/repo.rs 2021-10-18 13:05:54.000000000 +0200
2319 +++ rustc-1.56.0-src-git2/vendor/git2/src/repo.rs 2021-10-23 20:47:39.255788944 +0200
2321 use crate::worktree::{Worktree, WorktreeAddOptions};
2322 use crate::CherrypickOptions;
2323 use crate::RevertOptions;
2324 +use crate::{mailmap::Mailmap, panic};
2326 raw, AttrCheckFlags, Buf, Error, Object, Remote, RepositoryOpenFlags, RepositoryState, Revspec,
2330 - AnnotatedCommit, MergeAnalysis, MergeOptions, MergePreference, SubmoduleIgnore, SubmoduleStatus,
2331 + AnnotatedCommit, MergeAnalysis, MergeOptions, MergePreference, SubmoduleIgnore,
2332 + SubmoduleStatus, SubmoduleUpdate,
2334 use crate::{ApplyLocation, ApplyOptions, Rebase, RebaseOptions};
2335 use crate::{Blame, BlameOptions, Reference, References, ResetType, Signature, Submodule};
2336 use crate::{Blob, BlobWriter, Branch, BranchType, Branches, Commit, Config, Index, Oid, Tree};
2337 use crate::{Describe, IntoCString, Reflog, RepositoryInitMode, RevparseMode};
2338 use crate::{DescribeOptions, Diff, DiffOptions, Odb, PackBuilder, TreeBuilder};
2339 -use crate::{Note, Notes, ObjectType, Revwalk, Status, StatusOptions, Statuses, Tag};
2340 +use crate::{Note, Notes, ObjectType, Revwalk, Status, StatusOptions, Statuses, Tag, Transaction};
2342 +type MergeheadForeachCb<'a> = dyn FnMut(&Oid) -> bool + 'a;
2343 +type FetchheadForeachCb<'a> = dyn FnMut(&str, &[u8], &Oid, bool) -> bool + 'a;
2345 +struct FetchheadForeachCbData<'a> {
2346 + callback: &'a mut FetchheadForeachCb<'a>,
2349 +struct MergeheadForeachCbData<'a> {
2350 + callback: &'a mut MergeheadForeachCb<'a>,
2353 +extern "C" fn mergehead_foreach_cb(oid: *const raw::git_oid, payload: *mut c_void) -> c_int {
2354 + panic::wrap(|| unsafe {
2355 + let data = &mut *(payload as *mut MergeheadForeachCbData<'_>);
2357 + let callback = &mut data.callback;
2358 + callback(&Binding::from_raw(oid))
2370 +extern "C" fn fetchhead_foreach_cb(
2371 + ref_name: *const c_char,
2372 + remote_url: *const c_char,
2373 + oid: *const raw::git_oid,
2375 + payload: *mut c_void,
2377 + panic::wrap(|| unsafe {
2378 + let data = &mut *(payload as *mut FetchheadForeachCbData<'_>);
2380 + let callback = &mut data.callback;
2382 + assert!(!ref_name.is_null());
2383 + assert!(!remote_url.is_null());
2384 + assert!(!oid.is_null());
2386 + let ref_name = str::from_utf8(CStr::from_ptr(ref_name).to_bytes()).unwrap();
2387 + let remote_url = CStr::from_ptr(remote_url).to_bytes();
2388 + let oid = Binding::from_raw(oid);
2389 + let is_merge = is_merge == 1;
2391 + callback(&ref_name, remote_url, &oid, is_merge)
2403 /// An owned git repository, representing all state associated with the
2404 /// underlying filesystem.
2405 @@ -952,6 +1015,14 @@
2408 /// Get the value of a git attribute for a path as a string.
2410 + /// This function will return a special string if the attribute is set to a special value.
2411 + /// Interpreting the special string is discouraged. You should always use
2412 + /// [`AttrValue::from_string`](crate::AttrValue::from_string) to interpret the return value
2413 + /// and avoid the special string.
2415 + /// As such, the return type of this function will probably be changed in the next major version
2416 + /// to prevent interpreting the returned string without checking whether it's special.
2420 @@ -964,6 +1035,14 @@
2423 /// Get the value of a git attribute for a path as a byte slice.
2425 + /// This function will return a special byte slice if the attribute is set to a special value.
2426 + /// Interpreting the special byte slice is discouraged. You should always use
2427 + /// [`AttrValue::from_bytes`](crate::AttrValue::from_bytes) to interpret the return value and
2428 + /// avoid the special string.
2430 + /// As such, the return type of this function will probably be changed in the next major version
2431 + /// to prevent interpreting the returned byte slice without checking whether it's special.
2432 pub fn get_attr_bytes(
2435 @@ -1619,6 +1698,62 @@
2436 Ok(SubmoduleStatus::from_bits_truncate(ret as u32))
2439 + /// Set the ignore rule for the submodule in the configuration
2441 + /// This does not affect any currently-loaded instances.
2442 + pub fn submodule_set_ignore(
2445 + ignore: SubmoduleIgnore,
2446 + ) -> Result<(), Error> {
2447 + let name = CString::new(name)?;
2449 + try_call!(raw::git_submodule_set_ignore(self.raw(), name, ignore));
2454 + /// Set the update rule for the submodule in the configuration
2456 + /// This setting won't affect any existing instances.
2457 + pub fn submodule_set_update(
2460 + update: SubmoduleUpdate,
2461 + ) -> Result<(), Error> {
2462 + let name = CString::new(name)?;
2464 + try_call!(raw::git_submodule_set_update(self.raw(), name, update));
2469 + /// Set the URL for the submodule in the configuration
2471 + /// After calling this, you may wish to call [`Submodule::sync`] to write
2472 + /// the changes to the checked out submodule repository.
2473 + pub fn submodule_set_url(&mut self, name: &str, url: &str) -> Result<(), Error> {
2474 + let name = CString::new(name)?;
2475 + let url = CString::new(url)?;
2477 + try_call!(raw::git_submodule_set_url(self.raw(), name, url));
2482 + /// Set the branch for the submodule in the configuration
2484 + /// After calling this, you may wish to call [`Submodule::sync`] to write
2485 + /// the changes to the checked out submodule repository.
2486 + pub fn submodule_set_branch(&mut self, name: &str, branch_name: &str) -> Result<(), Error> {
2487 + let name = CString::new(name)?;
2488 + let branch_name = CString::new(branch_name)?;
2490 + try_call!(raw::git_submodule_set_branch(self.raw(), name, branch_name));
2495 /// Lookup a reference to one of the objects in a repository.
2496 pub fn find_tree(&self, oid: Oid) -> Result<Tree<'_>, Error> {
2497 let mut raw = ptr::null_mut();
2498 @@ -2708,7 +2843,7 @@
2499 let raw_opts = options.map(|o| o.raw());
2500 let ptr_raw_opts = match raw_opts.as_ref() {
2502 - None => 0 as *const _,
2503 + None => std::ptr::null(),
2506 try_call!(raw::git_cherrypick(self.raw(), commit.raw(), ptr_raw_opts));
2507 @@ -2794,6 +2929,26 @@
2511 + /// Apply a Diff to the provided tree, and return the resulting Index.
2512 + pub fn apply_to_tree(
2516 + options: Option<&mut ApplyOptions<'_>>,
2517 + ) -> Result<Index, Error> {
2518 + let mut ret = ptr::null_mut();
2520 + try_call!(raw::git_apply_to_tree(
2525 + options.map(|s| s.raw()).unwrap_or(ptr::null())
2527 + Ok(Binding::from_raw(ret))
2531 /// Reverts the given commit, producing changes in the index and working directory.
2534 @@ -2880,6 +3035,70 @@
2535 Ok(Binding::from_raw(raw))
2539 + /// Create a new transaction
2540 + pub fn transaction<'a>(&'a self) -> Result<Transaction<'a>, Error> {
2541 + let mut raw = ptr::null_mut();
2543 + try_call!(raw::git_transaction_new(&mut raw, self.raw));
2544 + Ok(Binding::from_raw(raw))
2548 + /// Gets this repository's mailmap.
2549 + pub fn mailmap(&self) -> Result<Mailmap, Error> {
2550 + let mut ret = ptr::null_mut();
2552 + try_call!(raw::git_mailmap_from_repository(&mut ret, self.raw));
2553 + Ok(Binding::from_raw(ret))
2557 + /// If a merge is in progress, invoke 'callback' for each commit ID in the
2558 + /// MERGE_HEAD file.
2559 + pub fn mergehead_foreach<C>(&mut self, mut callback: C) -> Result<(), Error>
2561 + C: FnMut(&Oid) -> bool,
2564 + let mut data = MergeheadForeachCbData {
2565 + callback: &mut callback,
2567 + let cb: raw::git_repository_mergehead_foreach_cb = Some(mergehead_foreach_cb);
2568 + try_call!(raw::git_repository_mergehead_foreach(
2571 + &mut data as *mut _ as *mut _
2577 + /// Invoke 'callback' for each entry in the given FETCH_HEAD file.
2579 + /// `callback` will be called with with following arguments:
2581 + /// - `&str`: the reference name
2582 + /// - `&[u8]`: the remote url
2583 + /// - `&Oid`: the reference target OID
2584 + /// - `bool`: was the reference the result of a merge
2585 + pub fn fetchhead_foreach<C>(&self, mut callback: C) -> Result<(), Error>
2587 + C: FnMut(&str, &[u8], &Oid, bool) -> bool,
2590 + let mut data = FetchheadForeachCbData {
2591 + callback: &mut callback,
2593 + let cb: raw::git_repository_fetchhead_foreach_cb = Some(fetchhead_foreach_cb);
2594 + try_call!(raw::git_repository_fetchhead_foreach(
2597 + &mut data as *mut _ as *mut _
2604 impl Binding for Repository {
2605 @@ -3062,7 +3281,9 @@
2607 use crate::build::CheckoutBuilder;
2608 use crate::CherrypickOptions;
2609 - use crate::{ObjectType, Oid, Repository, ResetType};
2611 + ObjectType, Oid, Repository, ResetType, Signature, SubmoduleIgnore, SubmoduleUpdate,
2613 use std::ffi::OsStr;
2615 use std::path::Path;
2616 @@ -3705,4 +3926,143 @@
2622 + fn smoke_submodule_set() -> Result<(), crate::Error> {
2623 + let (td1, _repo) = crate::test::repo_init();
2624 + let (td2, mut repo2) = crate::test::repo_init();
2625 + let url = crate::test::path2url(td1.path());
2628 + let mut s = repo2.submodule(&url, Path::new(name), true)?;
2629 + fs::remove_dir_all(td2.path().join("bar")).unwrap();
2630 + Repository::clone(&url, td2.path().join("bar"))?;
2631 + s.add_to_index(false)?;
2632 + s.add_finalize()?;
2635 + // update strategy
2636 + repo2.submodule_set_update(name, SubmoduleUpdate::None)?;
2638 + repo2.find_submodule(name)?.update_strategy(),
2639 + SubmoduleUpdate::None
2641 + repo2.submodule_set_update(name, SubmoduleUpdate::Rebase)?;
2643 + repo2.find_submodule(name)?.update_strategy(),
2644 + SubmoduleUpdate::Rebase
2648 + repo2.submodule_set_ignore(name, SubmoduleIgnore::Untracked)?;
2650 + repo2.find_submodule(name)?.ignore_rule(),
2651 + SubmoduleIgnore::Untracked
2653 + repo2.submodule_set_ignore(name, SubmoduleIgnore::Dirty)?;
2655 + repo2.find_submodule(name)?.ignore_rule(),
2656 + SubmoduleIgnore::Dirty
2660 + repo2.submodule_set_url(name, "fake-url")?;
2661 + assert_eq!(repo2.find_submodule(name)?.url(), Some("fake-url"));
2664 + repo2.submodule_set_branch(name, "fake-branch")?;
2665 + assert_eq!(repo2.find_submodule(name)?.branch(), Some("fake-branch"));
2671 + fn smoke_mailmap_from_repository() {
2672 + let (_td, repo) = crate::test::repo_init();
2675 + let head = t!(repo.head()).target().unwrap();
2676 + t!(repo.find_commit(head))
2679 + // This is our baseline for HEAD.
2680 + let author = commit.author();
2681 + let committer = commit.committer();
2682 + assert_eq!(author.name(), Some("name"));
2683 + assert_eq!(author.email(), Some("email"));
2684 + assert_eq!(committer.name(), Some("name"));
2685 + assert_eq!(committer.email(), Some("email"));
2687 + // There is no .mailmap file in the test repo so all signature identities are equal.
2688 + let mailmap = t!(repo.mailmap());
2689 + let mailmapped_author = t!(commit.author_with_mailmap(&mailmap));
2690 + let mailmapped_committer = t!(commit.committer_with_mailmap(&mailmap));
2691 + assert_eq!(mailmapped_author.name(), author.name());
2692 + assert_eq!(mailmapped_author.email(), author.email());
2693 + assert_eq!(mailmapped_committer.name(), committer.name());
2694 + assert_eq!(mailmapped_committer.email(), committer.email());
2697 + // - Add a .mailmap file to the repository.
2698 + // - Commit with a signature identity different from the author's.
2699 + // - Include entries for both author and committer to prove we call
2700 + // the right raw functions.
2701 + let mailmap_file = Path::new(".mailmap");
2702 + let p = Path::new(repo.workdir().unwrap()).join(&mailmap_file);
2706 +Author Name <author.proper@email> name <email>
2707 +Committer Name <committer.proper@email> <committer@email>"#,
2709 + let mut index = t!(repo.index());
2710 + t!(index.add_path(&mailmap_file));
2711 + let id_mailmap = t!(index.write_tree());
2712 + let tree_mailmap = t!(repo.find_tree(id_mailmap));
2714 + let head = t!(repo.commit(
2717 + t!(&Signature::now("committer", "committer@email")),
2722 + t!(repo.find_commit(head))
2725 + // Sanity check that we're working with the right commit and that its
2726 + // author and committer identities differ.
2727 + let author = commit.author();
2728 + let committer = commit.committer();
2729 + assert_ne!(author.name(), committer.name());
2730 + assert_ne!(author.email(), committer.email());
2731 + assert_eq!(author.name(), Some("name"));
2732 + assert_eq!(author.email(), Some("email"));
2733 + assert_eq!(committer.name(), Some("committer"));
2734 + assert_eq!(committer.email(), Some("committer@email"));
2736 + // Fetch the newly added .mailmap from the repository.
2737 + let mailmap = t!(repo.mailmap());
2738 + let mailmapped_author = t!(commit.author_with_mailmap(&mailmap));
2739 + let mailmapped_committer = t!(commit.committer_with_mailmap(&mailmap));
2741 + let mm_resolve_author = t!(mailmap.resolve_signature(&author));
2742 + let mm_resolve_committer = t!(mailmap.resolve_signature(&committer));
2744 + // Mailmap Signature lifetime is independent of Commit lifetime.
2749 + // author_with_mailmap() + committer_with_mailmap() work
2750 + assert_eq!(mailmapped_author.name(), Some("Author Name"));
2751 + assert_eq!(mailmapped_author.email(), Some("author.proper@email"));
2752 + assert_eq!(mailmapped_committer.name(), Some("Committer Name"));
2753 + assert_eq!(mailmapped_committer.email(), Some("committer.proper@email"));
2755 + // resolve_signature() works
2756 + assert_eq!(mm_resolve_author.email(), mailmapped_author.email());
2757 + assert_eq!(mm_resolve_committer.email(), mailmapped_committer.email());
2760 diff -urN rustc-1.56.0-src/vendor/git2/src/revspec.rs rustc-1.56.0-src-git2/vendor/git2/src/revspec.rs
2761 --- rustc-1.56.0-src/vendor/git2/src/revspec.rs 2021-10-18 13:05:54.000000000 +0200
2762 +++ rustc-1.56.0-src-git2/vendor/git2/src/revspec.rs 2021-10-23 20:47:39.255788944 +0200
2764 to: Option<Object<'repo>>,
2766 ) -> Revspec<'repo> {
2772 + Revspec { from, to, mode }
2775 /// Access the `from` range of this revspec.
2776 diff -urN rustc-1.56.0-src/vendor/git2/src/revwalk.rs rustc-1.56.0-src-git2/vendor/git2/src/revwalk.rs
2777 --- rustc-1.56.0-src/vendor/git2/src/revwalk.rs 2021-10-18 13:05:54.000000000 +0200
2778 +++ rustc-1.56.0-src-git2/vendor/git2/src/revwalk.rs 2021-10-23 20:47:39.255788944 +0200
2781 +use libc::{c_int, c_uint, c_void};
2782 use std::ffi::CString;
2785 use crate::util::Binding;
2786 -use crate::{raw, Error, Oid, Repository, Sort};
2787 +use crate::{panic, raw, Error, Oid, Repository, Sort};
2789 /// A revwalk allows traversal of the commit graph defined by including one or
2790 /// more leaves and excluding one or more roots.
2792 _marker: marker::PhantomData<&'repo Repository>,
2795 +/// A `Revwalk` with an assiciated "hide callback", see `with_hide_callback`
2796 +pub struct RevwalkWithHideCb<'repo, 'cb, C>
2798 + C: FnMut(Oid) -> bool,
2800 + revwalk: Revwalk<'repo>,
2801 + _marker: marker::PhantomData<&'cb C>,
2804 +extern "C" fn revwalk_hide_cb<C>(commit_id: *const raw::git_oid, payload: *mut c_void) -> c_int
2806 + C: FnMut(Oid) -> bool,
2808 + panic::wrap(|| unsafe {
2809 + let hide_cb = payload as *mut C;
2810 + if (*hide_cb)(Oid::from_raw(commit_id)) {
2819 +impl<'repo, 'cb, C: FnMut(Oid) -> bool> RevwalkWithHideCb<'repo, 'cb, C> {
2820 + /// Consumes the `RevwalkWithHideCb` and returns the contained `Revwalk`.
2822 + /// Note that this will reset the `Revwalk`.
2823 + pub fn into_inner(mut self) -> Result<Revwalk<'repo>, Error> {
2824 + self.revwalk.reset()?;
2829 impl<'repo> Revwalk<'repo> {
2830 /// Reset a revwalk to allow re-configuring it.
2832 @@ -119,6 +153,29 @@
2836 + /// Hide all commits for which the callback returns true from
2838 + pub fn with_hide_callback<'cb, C>(
2841 + ) -> Result<RevwalkWithHideCb<'repo, 'cb, C>, Error>
2843 + C: FnMut(Oid) -> bool,
2845 + let r = RevwalkWithHideCb {
2847 + _marker: marker::PhantomData,
2850 + raw::git_revwalk_add_hide_cb(
2852 + Some(revwalk_hide_cb::<C>),
2853 + callback as *const _ as *mut c_void,
2859 /// Hide the repository's HEAD
2861 /// For more information, see `hide`.
2863 type Raw = *mut raw::git_revwalk;
2864 unsafe fn from_raw(raw: *mut raw::git_revwalk) -> Revwalk<'repo> {
2868 _marker: marker::PhantomData,
2871 @@ -191,6 +248,15 @@
2875 +impl<'repo, 'cb, C: FnMut(Oid) -> bool> Iterator for RevwalkWithHideCb<'repo, 'cb, C> {
2876 + type Item = Result<Oid, Error>;
2877 + fn next(&mut self) -> Option<Result<Oid, Error>> {
2878 + let out = self.revwalk.next();
2879 + crate::panic::check();
2887 @@ -216,4 +282,35 @@
2888 walk.hide_head().unwrap();
2889 assert_eq!(walk.by_ref().count(), 0);
2893 + fn smoke_hide_cb() {
2894 + let (_td, repo) = crate::test::repo_init();
2895 + let head = repo.head().unwrap();
2896 + let target = head.target().unwrap();
2898 + let mut walk = repo.revwalk().unwrap();
2899 + walk.push(target).unwrap();
2901 + let oids: Vec<crate::Oid> = walk.by_ref().collect::<Result<Vec<_>, _>>().unwrap();
2903 + assert_eq!(oids.len(), 1);
2904 + assert_eq!(oids[0], target);
2906 + walk.reset().unwrap();
2907 + walk.push_head().unwrap();
2908 + assert_eq!(walk.by_ref().count(), 1);
2910 + walk.reset().unwrap();
2911 + walk.push_head().unwrap();
2913 + let hide_cb = |oid| oid == target;
2914 + let mut walk = walk.with_hide_callback(&hide_cb).unwrap();
2916 + assert_eq!(walk.by_ref().count(), 0);
2918 + let mut walk = walk.into_inner().unwrap();
2919 + walk.push_head().unwrap();
2920 + assert_eq!(walk.by_ref().count(), 1);
2923 diff -urN rustc-1.56.0-src/vendor/git2/src/signature.rs rustc-1.56.0-src-git2/vendor/git2/src/signature.rs
2924 --- rustc-1.56.0-src/vendor/git2/src/signature.rs 2021-10-18 13:05:54.000000000 +0200
2925 +++ rustc-1.56.0-src-git2/vendor/git2/src/signature.rs 2021-10-23 20:47:39.255788944 +0200
2927 type Raw = *mut raw::git_signature;
2928 unsafe fn from_raw(raw: *mut raw::git_signature) -> Signature<'a> {
2932 _marker: marker::PhantomData,
2935 diff -urN rustc-1.56.0-src/vendor/git2/src/status.rs rustc-1.56.0-src-git2/vendor/git2/src/status.rs
2936 --- rustc-1.56.0-src/vendor/git2/src/status.rs 2021-10-18 13:05:54.000000000 +0200
2937 +++ rustc-1.56.0-src-git2/vendor/git2/src/status.rs 2021-10-23 20:47:39.255788944 +0200
2939 let r = raw::git_status_init_options(&mut raw, raw::GIT_STATUS_OPTIONS_VERSION);
2944 pathspec: Vec::new(),
2948 type Raw = *mut raw::git_status_list;
2949 unsafe fn from_raw(raw: *mut raw::git_status_list) -> Statuses<'repo> {
2953 _marker: marker::PhantomData,
2958 unsafe fn from_raw(raw: *const raw::git_status_entry) -> StatusEntry<'statuses> {
2962 _marker: marker::PhantomData,
2965 diff -urN rustc-1.56.0-src/vendor/git2/src/string_array.rs rustc-1.56.0-src-git2/vendor/git2/src/string_array.rs
2966 --- rustc-1.56.0-src/vendor/git2/src/string_array.rs 2021-10-18 13:05:54.000000000 +0200
2967 +++ rustc-1.56.0-src-git2/vendor/git2/src/string_array.rs 2021-10-23 20:47:39.255788944 +0200
2969 impl Binding for StringArray {
2970 type Raw = raw::git_strarray;
2971 unsafe fn from_raw(raw: raw::git_strarray) -> StringArray {
2972 - StringArray { raw: raw }
2973 + StringArray { raw }
2975 fn raw(&self) -> raw::git_strarray {
2977 diff -urN rustc-1.56.0-src/vendor/git2/src/submodule.rs rustc-1.56.0-src-git2/vendor/git2/src/submodule.rs
2978 --- rustc-1.56.0-src/vendor/git2/src/submodule.rs 2021-10-18 13:05:54.000000000 +0200
2979 +++ rustc-1.56.0-src-git2/vendor/git2/src/submodule.rs 2021-10-23 20:47:39.255788944 +0200
2984 -use crate::build::CheckoutBuilder;
2985 use crate::util::{self, Binding};
2986 +use crate::{build::CheckoutBuilder, SubmoduleIgnore, SubmoduleUpdate};
2987 use crate::{raw, Error, FetchOptions, Oid, Repository};
2989 /// A structure to represent a git [submodule][1]
2990 @@ -113,6 +113,16 @@
2991 unsafe { Binding::from_raw_opt(raw::git_submodule_wd_id(self.raw)) }
2994 + /// Get the ignore rule that will be used for the submodule.
2995 + pub fn ignore_rule(&self) -> SubmoduleIgnore {
2996 + SubmoduleIgnore::from_raw(unsafe { raw::git_submodule_ignore(self.raw) })
2999 + /// Get the update rule that will be used for the submodule.
3000 + pub fn update_strategy(&self) -> SubmoduleUpdate {
3001 + SubmoduleUpdate::from_raw(unsafe { raw::git_submodule_update_strategy(self.raw) })
3004 /// Copy submodule info into ".git/config" file.
3006 /// Just like "git submodule init", this copies information about the
3008 type Raw = *mut raw::git_submodule;
3009 unsafe fn from_raw(raw: *mut raw::git_submodule) -> Submodule<'repo> {
3013 _marker: marker::PhantomData,
3016 diff -urN rustc-1.56.0-src/vendor/git2/src/tag.rs rustc-1.56.0-src-git2/vendor/git2/src/tag.rs
3017 --- rustc-1.56.0-src/vendor/git2/src/tag.rs 2021-10-18 13:05:54.000000000 +0200
3018 +++ rustc-1.56.0-src-git2/vendor/git2/src/tag.rs 2021-10-23 20:47:39.255788944 +0200
3020 unsafe { Binding::from_raw(raw::git_tag_target_id(&*self.raw)) }
3023 - /// Get the OID of the tagged object of a tag
3024 + /// Get the ObjectType of the tagged object of a tag
3025 pub fn target_type(&self) -> Option<ObjectType> {
3026 unsafe { ObjectType::from_raw(raw::git_tag_target_type(&*self.raw)) }
3029 type Raw = *mut raw::git_tag;
3030 unsafe fn from_raw(raw: *mut raw::git_tag) -> Tag<'repo> {
3034 _marker: marker::PhantomData,
3037 diff -urN rustc-1.56.0-src/vendor/git2/src/time.rs rustc-1.56.0-src-git2/vendor/git2/src/time.rs
3038 --- rustc-1.56.0-src/vendor/git2/src/time.rs 2021-10-18 13:05:54.000000000 +0200
3039 +++ rustc-1.56.0-src-git2/vendor/git2/src/time.rs 2021-10-23 20:47:39.259122276 +0200
3041 impl Binding for Time {
3042 type Raw = raw::git_time;
3043 unsafe fn from_raw(raw: raw::git_time) -> Time {
3047 fn raw(&self) -> raw::git_time {
3050 pub fn new(seconds: i32, nanoseconds: u32) -> IndexTime {
3052 Binding::from_raw(raw::git_index_time {
3054 - nanoseconds: nanoseconds,
3061 impl Binding for IndexTime {
3062 type Raw = raw::git_index_time;
3063 unsafe fn from_raw(raw: raw::git_index_time) -> IndexTime {
3064 - IndexTime { raw: raw }
3067 fn raw(&self) -> raw::git_index_time {
3069 diff -urN rustc-1.56.0-src/vendor/git2/src/tracing.rs rustc-1.56.0-src-git2/vendor/git2/src/tracing.rs
3070 --- rustc-1.56.0-src/vendor/git2/src/tracing.rs 1970-01-01 01:00:00.000000000 +0100
3071 +++ rustc-1.56.0-src-git2/vendor/git2/src/tracing.rs 2021-10-23 20:47:39.259122276 +0200
3073 +use std::sync::atomic::{AtomicUsize, Ordering};
3077 +use crate::{panic, raw, util::Binding};
3079 +/// Available tracing levels. When tracing is set to a particular level,
3080 +/// callers will be provided tracing at the given level and all lower levels.
3081 +#[derive(Copy, Clone, Debug)]
3082 +pub enum TraceLevel {
3083 + /// No tracing will be performed.
3086 + /// Severe errors that may impact the program's execution
3089 + /// Errors that do not impact the program's execution
3092 + /// Warnings that suggest abnormal data
3095 + /// Informational messages about program execution
3098 + /// Detailed data that allows for debugging
3101 + /// Exceptionally detailed debugging data
3105 +impl Binding for TraceLevel {
3106 + type Raw = raw::git_trace_level_t;
3107 + unsafe fn from_raw(raw: raw::git_trace_level_t) -> Self {
3109 + raw::GIT_TRACE_NONE => Self::None,
3110 + raw::GIT_TRACE_FATAL => Self::Fatal,
3111 + raw::GIT_TRACE_ERROR => Self::Error,
3112 + raw::GIT_TRACE_WARN => Self::Warn,
3113 + raw::GIT_TRACE_INFO => Self::Info,
3114 + raw::GIT_TRACE_DEBUG => Self::Debug,
3115 + raw::GIT_TRACE_TRACE => Self::Trace,
3116 + _ => panic!("Unknown git trace level"),
3119 + fn raw(&self) -> raw::git_trace_level_t {
3121 + Self::None => raw::GIT_TRACE_NONE,
3122 + Self::Fatal => raw::GIT_TRACE_FATAL,
3123 + Self::Error => raw::GIT_TRACE_ERROR,
3124 + Self::Warn => raw::GIT_TRACE_WARN,
3125 + Self::Info => raw::GIT_TRACE_INFO,
3126 + Self::Debug => raw::GIT_TRACE_DEBUG,
3127 + Self::Trace => raw::GIT_TRACE_TRACE,
3132 +pub type TracingCb = fn(TraceLevel, &str);
3134 +static CALLBACK: AtomicUsize = AtomicUsize::new(0);
3137 +pub fn trace_set(level: TraceLevel, cb: TracingCb) -> bool {
3138 + CALLBACK.store(cb as usize, Ordering::SeqCst);
3141 + raw::git_trace_set(level.raw(), Some(tracing_cb_c));
3147 +extern "C" fn tracing_cb_c(level: raw::git_trace_level_t, msg: *const c_char) {
3148 + let cb = CALLBACK.load(Ordering::SeqCst);
3149 + panic::wrap(|| unsafe {
3150 + let cb: TracingCb = std::mem::transmute(cb);
3151 + let msg = std::ffi::CStr::from_ptr(msg).to_str().unwrap();
3152 + cb(Binding::from_raw(level), msg);
3155 diff -urN rustc-1.56.0-src/vendor/git2/src/transaction.rs rustc-1.56.0-src-git2/vendor/git2/src/transaction.rs
3156 --- rustc-1.56.0-src/vendor/git2/src/transaction.rs 1970-01-01 01:00:00.000000000 +0100
3157 +++ rustc-1.56.0-src-git2/vendor/git2/src/transaction.rs 2021-10-23 20:47:39.259122276 +0200
3159 +use std::ffi::CString;
3162 +use crate::{raw, util::Binding, Error, Oid, Reflog, Repository, Signature};
3164 +/// A structure representing a transactional update of a repository's references.
3166 +/// Transactions work by locking loose refs for as long as the [`Transaction`]
3167 +/// is held, and committing all changes to disk when [`Transaction::commit`] is
3168 +/// called. Note that comitting is not atomic: if an operation fails, the
3169 +/// transaction aborts, but previous successful operations are not rolled back.
3170 +pub struct Transaction<'repo> {
3171 + raw: *mut raw::git_transaction,
3172 + _marker: marker::PhantomData<&'repo Repository>,
3175 +impl Drop for Transaction<'_> {
3176 + fn drop(&mut self) {
3177 + unsafe { raw::git_transaction_free(self.raw) }
3181 +impl<'repo> Binding for Transaction<'repo> {
3182 + type Raw = *mut raw::git_transaction;
3184 + unsafe fn from_raw(ptr: *mut raw::git_transaction) -> Transaction<'repo> {
3187 + _marker: marker::PhantomData,
3191 + fn raw(&self) -> *mut raw::git_transaction {
3196 +impl<'repo> Transaction<'repo> {
3197 + /// Lock the specified reference by name.
3198 + pub fn lock_ref(&mut self, refname: &str) -> Result<(), Error> {
3199 + let refname = CString::new(refname).unwrap();
3201 + try_call!(raw::git_transaction_lock_ref(self.raw, refname));
3207 + /// Set the target of the specified reference.
3209 + /// The reference must have been locked via `lock_ref`.
3211 + /// If `reflog_signature` is `None`, the [`Signature`] is read from the
3212 + /// repository config.
3213 + pub fn set_target(
3217 + reflog_signature: Option<&Signature<'_>>,
3218 + reflog_message: &str,
3219 + ) -> Result<(), Error> {
3220 + let refname = CString::new(refname).unwrap();
3221 + let reflog_message = CString::new(reflog_message).unwrap();
3223 + try_call!(raw::git_transaction_set_target(
3227 + reflog_signature.map(|s| s.raw()),
3235 + /// Set the target of the specified symbolic reference.
3237 + /// The reference must have been locked via `lock_ref`.
3239 + /// If `reflog_signature` is `None`, the [`Signature`] is read from the
3240 + /// repository config.
3241 + pub fn set_symbolic_target(
3245 + reflog_signature: Option<&Signature<'_>>,
3246 + reflog_message: &str,
3247 + ) -> Result<(), Error> {
3248 + let refname = CString::new(refname).unwrap();
3249 + let target = CString::new(target).unwrap();
3250 + let reflog_message = CString::new(reflog_message).unwrap();
3252 + try_call!(raw::git_transaction_set_symbolic_target(
3256 + reflog_signature.map(|s| s.raw()),
3264 + /// Add a [`Reflog`] to the transaction.
3266 + /// This commit the in-memory [`Reflog`] to disk when the transaction commits.
3267 + /// Note that atomicty is **not* guaranteed: if the transaction fails to
3268 + /// modify `refname`, the reflog may still have been comitted to disk.
3270 + /// If this is combined with setting the target, that update won't be
3271 + /// written to the log (ie. the `reflog_signature` and `reflog_message`
3272 + /// parameters will be ignored).
3273 + pub fn set_reflog(&mut self, refname: &str, reflog: Reflog) -> Result<(), Error> {
3274 + let refname = CString::new(refname).unwrap();
3276 + try_call!(raw::git_transaction_set_reflog(
3286 + /// Remove a reference.
3288 + /// The reference must have been locked via `lock_ref`.
3289 + pub fn remove(&mut self, refname: &str) -> Result<(), Error> {
3290 + let refname = CString::new(refname).unwrap();
3292 + try_call!(raw::git_transaction_remove(self.raw, refname));
3298 + /// Commit the changes from the transaction.
3300 + /// The updates will be made one by one, and the first failure will stop the
3302 + pub fn commit(self) -> Result<(), Error> {
3304 + try_call!(raw::git_transaction_commit(self.raw));
3312 + use crate::{Error, ErrorClass, ErrorCode, Oid, Repository};
3316 + let (_td, repo) = crate::test::repo_init();
3318 + let mut tx = t!(repo.transaction());
3320 + t!(tx.lock_ref("refs/heads/main"));
3321 + t!(tx.lock_ref("refs/heads/next"));
3323 + t!(tx.set_target("refs/heads/main", Oid::zero(), None, "set main to zero"));
3324 + t!(tx.set_symbolic_target(
3325 + "refs/heads/next",
3326 + "refs/heads/main",
3328 + "set next to main",
3333 + assert_eq!(repo.refname_to_id("refs/heads/main").unwrap(), Oid::zero());
3335 + repo.find_reference("refs/heads/next")
3337 + .symbolic_target()
3344 + fn locks_same_repo_handle() {
3345 + let (_td, repo) = crate::test::repo_init();
3347 + let mut tx1 = t!(repo.transaction());
3348 + t!(tx1.lock_ref("refs/heads/seen"));
3350 + let mut tx2 = t!(repo.transaction());
3351 + assert!(matches!(tx2.lock_ref("refs/heads/seen"), Err(e) if e.code() == ErrorCode::Locked))
3355 + fn locks_across_repo_handles() {
3356 + let (td, repo1) = crate::test::repo_init();
3357 + let repo2 = t!(Repository::open(&td));
3359 + let mut tx1 = t!(repo1.transaction());
3360 + t!(tx1.lock_ref("refs/heads/seen"));
3362 + let mut tx2 = t!(repo2.transaction());
3363 + assert!(matches!(tx2.lock_ref("refs/heads/seen"), Err(e) if e.code() == ErrorCode::Locked))
3367 + fn drop_unlocks() {
3368 + let (_td, repo) = crate::test::repo_init();
3370 + let mut tx = t!(repo.transaction());
3371 + t!(tx.lock_ref("refs/heads/seen"));
3374 + let mut tx2 = t!(repo.transaction());
3375 + t!(tx2.lock_ref("refs/heads/seen"))
3379 + fn commit_unlocks() {
3380 + let (_td, repo) = crate::test::repo_init();
3382 + let mut tx = t!(repo.transaction());
3383 + t!(tx.lock_ref("refs/heads/seen"));
3386 + let mut tx2 = t!(repo.transaction());
3387 + t!(tx2.lock_ref("refs/heads/seen"));
3391 + fn prevents_non_transactional_updates() {
3392 + let (_td, repo) = crate::test::repo_init();
3393 + let head = t!(repo.refname_to_id("HEAD"));
3395 + let mut tx = t!(repo.transaction());
3396 + t!(tx.lock_ref("refs/heads/seen"));
3399 + repo.reference("refs/heads/seen", head, true, "competing with lock"),
3400 + Err(e) if e.code() == ErrorCode::Locked
3406 + let (_td, repo) = crate::test::repo_init();
3407 + let head = t!(repo.refname_to_id("HEAD"));
3408 + let next = "refs/heads/next";
3410 + t!(repo.reference(
3414 + "refs/heads/next@{0}: branch: Created from HEAD"
3418 + let mut tx = t!(repo.transaction());
3419 + t!(tx.lock_ref(next));
3420 + t!(tx.remove(next));
3423 + assert!(matches!(repo.refname_to_id(next), Err(e) if e.code() == ErrorCode::NotFound))
3427 + fn must_lock_ref() {
3428 + let (_td, repo) = crate::test::repo_init();
3431 + fn is_not_locked_err(e: &Error) -> bool {
3432 + e.code() == ErrorCode::NotFound
3433 + && e.class() == ErrorClass::Reference
3434 + && e.message() == "the specified reference is not locked"
3437 + let mut tx = t!(repo.transaction());
3439 + tx.set_target("refs/heads/main", Oid::zero(), None, "set main to zero"),
3440 + Err(e) if is_not_locked_err(&e)
3444 diff -urN rustc-1.56.0-src/vendor/git2/src/transport.rs rustc-1.56.0-src-git2/vendor/git2/src/transport.rs
3445 --- rustc-1.56.0-src/vendor/git2/src/transport.rs 2021-10-18 13:05:54.000000000 +0200
3446 +++ rustc-1.56.0-src-git2/vendor/git2/src/transport.rs 2021-10-23 20:47:39.259122276 +0200
3450 /// Actions that a smart transport can ask a subtransport to perform
3451 -#[derive(Copy, Clone)]
3452 +#[derive(Copy, Clone, PartialEq)]
3453 #[allow(missing_docs)]
3458 struct RawSmartSubtransport {
3459 raw: raw::git_smart_subtransport,
3460 + stream: Option<*mut raw::git_smart_subtransport_stream>,
3462 obj: Box<dyn SmartSubtransport>,
3466 close: Some(subtransport_close),
3467 free: Some(subtransport_free),
3471 obj: Box::new(subtransport),
3473 let mut defn = raw::git_smart_subtransport_definition {
3474 @@ -246,23 +250,36 @@
3475 raw::GIT_SERVICE_RECEIVEPACK => Service::ReceivePack,
3476 n => panic!("unknown action: {}", n),
3478 - let transport = &mut *(raw_transport as *mut RawSmartSubtransport);
3479 - let obj = match transport.obj.action(url, action) {
3483 - return e.raw_code() as c_int;
3485 + let mut transport = &mut *(raw_transport as *mut RawSmartSubtransport);
3486 + // Note: we only need to generate if rpc is on. Else, for receive-pack and upload-pack
3487 + // libgit2 reuses the stream generated for receive-pack-ls or upload-pack-ls.
3488 + let generate_stream =
3489 + transport.rpc || action == Service::UploadPackLs || action == Service::ReceivePackLs;
3490 + if generate_stream {
3491 + let obj = match transport.obj.action(url, action) {
3495 + return e.raw_code() as c_int;
3498 + *stream = mem::transmute(Box::new(RawSmartSubtransportStream {
3499 + raw: raw::git_smart_subtransport_stream {
3500 + subtransport: raw_transport,
3501 + read: Some(stream_read),
3502 + write: Some(stream_write),
3503 + free: Some(stream_free),
3507 + transport.stream = Some(*stream);
3509 + if transport.stream.is_none() {
3513 - *stream = mem::transmute(Box::new(RawSmartSubtransportStream {
3514 - raw: raw::git_smart_subtransport_stream {
3515 - subtransport: raw_transport,
3516 - read: Some(stream_read),
3517 - write: Some(stream_write),
3518 - free: Some(stream_free),
3522 + *stream = transport.stream.unwrap();
3527 diff -urN rustc-1.56.0-src/vendor/git2/src/treebuilder.rs rustc-1.56.0-src-git2/vendor/git2/src/treebuilder.rs
3528 --- rustc-1.56.0-src/vendor/git2/src/treebuilder.rs 2021-10-18 13:05:54.000000000 +0200
3529 +++ rustc-1.56.0-src-git2/vendor/git2/src/treebuilder.rs 2021-10-23 20:47:39.259122276 +0200
3532 unsafe fn from_raw(raw: *mut raw::git_treebuilder) -> TreeBuilder<'repo> {
3536 _marker: marker::PhantomData,
3539 diff -urN rustc-1.56.0-src/vendor/git2/src/tree.rs rustc-1.56.0-src-git2/vendor/git2/src/tree.rs
3540 --- rustc-1.56.0-src/vendor/git2/src/tree.rs 2021-10-18 13:05:54.000000000 +0200
3541 +++ rustc-1.56.0-src-git2/vendor/git2/src/tree.rs 2021-10-23 20:47:39.259122276 +0200
3544 unsafe fn from_raw(raw: *mut raw::git_tree) -> Tree<'repo> {
3548 _marker: marker::PhantomData,
3552 type Raw = *mut raw::git_tree_entry;
3553 unsafe fn from_raw(raw: *mut raw::git_tree_entry) -> TreeEntry<'a> {
3558 _marker: marker::PhantomData,
3560 diff -urN rustc-1.56.0-src/vendor/git2/src/version.rs rustc-1.56.0-src-git2/vendor/git2/src/version.rs
3561 --- rustc-1.56.0-src/vendor/git2/src/version.rs 1970-01-01 01:00:00.000000000 +0100
3562 +++ rustc-1.56.0-src-git2/vendor/git2/src/version.rs 2021-10-23 20:47:39.259122276 +0200
3568 +/// Version information about libgit2 and the capabilities it supports.
3569 +pub struct Version {
3576 +macro_rules! flag_test {
3577 + ($features:expr, $flag:expr) => {
3578 + ($features as u32 & $flag as u32) != 0
3583 + /// Returns a [`Version`] which provides information about libgit2.
3584 + pub fn get() -> Version {
3585 + let mut v = Version {
3592 + raw::git_libgit2_version(&mut v.major, &mut v.minor, &mut v.rev);
3593 + v.features = raw::git_libgit2_features();
3598 + /// Returns the version of libgit2.
3600 + /// The return value is a tuple of `(major, minor, rev)`
3601 + pub fn libgit2_version(&self) -> (u32, u32, u32) {
3602 + (self.major as u32, self.minor as u32, self.rev as u32)
3605 + /// Returns the version of the libgit2-sys crate.
3606 + pub fn crate_version(&self) -> &'static str {
3607 + env!("CARGO_PKG_VERSION")
3610 + /// Returns true if this was built with the vendored version of libgit2.
3611 + pub fn vendored(&self) -> bool {
3615 + /// Returns true if libgit2 was built thread-aware and can be safely used
3616 + /// from multiple threads.
3617 + pub fn threads(&self) -> bool {
3618 + flag_test!(self.features, raw::GIT_FEATURE_THREADS)
3621 + /// Returns true if libgit2 was built with and linked against a TLS implementation.
3623 + /// Custom TLS streams may still be added by the user to support HTTPS
3624 + /// regardless of this.
3625 + pub fn https(&self) -> bool {
3626 + flag_test!(self.features, raw::GIT_FEATURE_HTTPS)
3629 + /// Returns true if libgit2 was built with and linked against libssh2.
3631 + /// A custom transport may still be added by the user to support libssh2
3632 + /// regardless of this.
3633 + pub fn ssh(&self) -> bool {
3634 + flag_test!(self.features, raw::GIT_FEATURE_SSH)
3637 + /// Returns true if libgit2 was built with support for sub-second
3638 + /// resolution in file modification times.
3639 + pub fn nsec(&self) -> bool {
3640 + flag_test!(self.features, raw::GIT_FEATURE_NSEC)
3644 +impl fmt::Debug for Version {
3645 + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
3646 + let mut f = f.debug_struct("Version");
3647 + f.field("major", &self.major)
3648 + .field("minor", &self.minor)
3649 + .field("rev", &self.rev)
3650 + .field("crate_version", &self.crate_version())
3651 + .field("vendored", &self.vendored())
3652 + .field("threads", &self.threads())
3653 + .field("https", &self.https())
3654 + .field("ssh", &self.ssh())
3655 + .field("nsec", &self.nsec());
3659 diff -urN rustc-1.56.0-src/vendor/libgit2-sys/build.rs rustc-1.56.0-src-git2/vendor/libgit2-sys/build.rs
3660 --- rustc-1.56.0-src/vendor/libgit2-sys/build.rs 2021-10-18 13:05:54.000000000 +0200
3661 +++ rustc-1.56.0-src-git2/vendor/libgit2-sys/build.rs 2021-10-23 20:47:39.259122276 +0200
3664 let https = env::var("CARGO_FEATURE_HTTPS").is_ok();
3665 let ssh = env::var("CARGO_FEATURE_SSH").is_ok();
3666 + let vendored = env::var("CARGO_FEATURE_VENDORED").is_ok();
3667 let zlib_ng_compat = env::var("CARGO_FEATURE_ZLIB_NG_COMPAT").is_ok();
3669 // To use zlib-ng in zlib-compat mode, we have to build libgit2 ourselves.
3670 - if !zlib_ng_compat {
3671 + let try_to_use_system_libgit2 = !vendored && !zlib_ng_compat;
3672 + if try_to_use_system_libgit2 {
3673 let mut cfg = pkg_config::Config::new();
3674 if let Ok(lib) = cfg.atleast_version("1.1.0").probe("libgit2") {
3675 for include in &lib.include_paths {
3680 + println!("cargo:rustc-cfg=libgit2_vendored");
3682 if !Path::new("libgit2/.git").exists() {
3683 let _ = Command::new("git")
3684 .args(&["submodule", "update", "--init", "libgit2"])
3686 features.push_str("#ifndef INCLUDE_features_h\n");
3687 features.push_str("#define INCLUDE_features_h\n");
3688 features.push_str("#define GIT_THREADS 1\n");
3689 + features.push_str("#define GIT_TRACE 1\n");
3691 if !target.contains("android") {
3692 features.push_str("#define GIT_USE_NSEC 1\n");
3693 diff -urN rustc-1.56.0-src/vendor/libgit2-sys/Cargo.toml rustc-1.56.0-src-git2/vendor/libgit2-sys/Cargo.toml
3694 --- rustc-1.56.0-src/vendor/libgit2-sys/Cargo.toml 2021-10-18 13:05:54.000000000 +0200
3695 +++ rustc-1.56.0-src-git2/vendor/libgit2-sys/Cargo.toml 2021-10-23 20:47:39.259122276 +0200
3699 name = "libgit2-sys"
3700 -version = "0.12.18+1.1.0"
3701 +version = "0.12.24+1.3.0"
3702 authors = ["Josh Triplett <josh@joshtriplett.org>", "Alex Crichton <alex@alexcrichton.com>"]
3705 diff -urN rustc-1.56.0-src/vendor/libgit2-sys/lib.rs rustc-1.56.0-src-git2/vendor/libgit2-sys/lib.rs
3706 --- rustc-1.56.0-src/vendor/libgit2-sys/lib.rs 2021-10-18 13:05:54.000000000 +0200
3707 +++ rustc-1.56.0-src-git2/vendor/libgit2-sys/lib.rs 2021-10-23 20:47:39.259122276 +0200
3709 pub enum git_odb_stream {}
3710 pub enum git_odb_object {}
3711 pub enum git_worktree {}
3712 +pub enum git_transaction {}
3713 +pub enum git_mailmap {}
3716 pub struct git_revspec {
3719 pub type git_transfer_progress = git_indexer_progress;
3721 +pub type git_remote_ready_cb = Option<extern "C" fn(*mut git_remote, c_int, *mut c_void) -> c_int>;
3724 pub struct git_remote_callbacks {
3725 pub version: c_uint,
3727 pub push_update_reference: git_push_update_reference_cb,
3728 pub push_negotiation: git_push_negotiation,
3729 pub transport: git_transport_cb,
3730 + pub remote_ready: git_remote_ready_cb,
3731 pub payload: *mut c_void,
3732 pub resolve_url: git_url_resolve_cb,
3734 @@ -1167,6 +1172,7 @@
3735 pub const GIT_DIFF_INCLUDE_UNREADABLE: git_diff_option_t = 1 << 16;
3736 pub const GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED: git_diff_option_t = 1 << 17;
3737 pub const GIT_DIFF_INDENT_HEURISTIC: git_diff_option_t = 1 << 18;
3738 +pub const GIT_DIFF_IGNORE_BLANK_LINES: git_diff_option_t = 1 << 19;
3739 pub const GIT_DIFF_FORCE_TEXT: git_diff_option_t = 1 << 20;
3740 pub const GIT_DIFF_FORCE_BINARY: git_diff_option_t = 1 << 21;
3741 pub const GIT_DIFF_IGNORE_WHITESPACE: git_diff_option_t = 1 << 22;
3742 @@ -1247,6 +1253,13 @@
3743 pub const GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER: u32 = 1 << 0;
3746 +pub struct git_diff_patchid_options {
3747 + pub version: c_uint,
3750 +pub const GIT_DIFF_PATCHID_OPTIONS_VERSION: c_uint = 1;
3753 pub struct git_diff_binary {
3754 pub contains_data: c_uint,
3755 pub old_file: git_diff_binary_file,
3756 @@ -1477,6 +1490,8 @@
3760 + pub writemidx: Option<extern "C" fn(*mut git_odb_backend) -> c_int>,
3762 pub freshen: Option<extern "C" fn(*mut git_odb_backend, *const git_oid) -> c_int>,
3764 pub free: Option<extern "C" fn(*mut git_odb_backend)>,
3765 @@ -1736,6 +1751,20 @@
3769 +pub type git_commit_create_cb = Option<
3772 + *const git_signature,
3773 + *const git_signature,
3778 + *const git_commit,
3783 pub const GIT_REBASE_NO_OPERATION: usize = usize::max_value();
3786 @@ -1746,6 +1775,7 @@
3787 pub rewrite_notes_ref: *const c_char,
3788 pub merge_options: git_merge_options,
3789 pub checkout_options: git_checkout_options,
3790 + pub commit_create_cb: git_commit_create_cb,
3791 pub signing_cb: git_commit_signing_cb,
3792 pub payload: *mut c_void,
3794 @@ -1880,6 +1910,63 @@
3796 pub const GIT_WORKTREE_PRUNE_OPTIONS_VERSION: c_uint = 1;
3798 +pub type git_repository_mergehead_foreach_cb =
3799 + Option<extern "C" fn(oid: *const git_oid, payload: *mut c_void) -> c_int>;
3801 +pub type git_repository_fetchhead_foreach_cb = Option<
3802 + extern "C" fn(*const c_char, *const c_char, *const git_oid, c_uint, *mut c_void) -> c_int,
3806 + pub enum git_trace_level_t {
3807 + /* No tracing will be performed. */
3808 + GIT_TRACE_NONE = 0,
3810 + /* Severe errors that may impact the program's execution */
3811 + GIT_TRACE_FATAL = 1,
3813 + /* Errors that do not impact the program's execution */
3814 + GIT_TRACE_ERROR = 2,
3816 + /* Warnings that suggest abnormal data */
3817 + GIT_TRACE_WARN = 3,
3819 + /* Informational messages about program execution */
3820 + GIT_TRACE_INFO = 4,
3822 + /* Detailed data that allows for debugging */
3823 + GIT_TRACE_DEBUG = 5,
3825 + /* Exceptionally detailed debugging data */
3826 + GIT_TRACE_TRACE = 6,
3830 +pub type git_trace_cb = Option<extern "C" fn(level: git_trace_level_t, msg: *const c_char)>;
3833 + pub enum git_feature_t {
3834 + GIT_FEATURE_THREADS = 1 << 0,
3835 + GIT_FEATURE_HTTPS = 1 << 1,
3836 + GIT_FEATURE_SSH = 1 << 2,
3837 + GIT_FEATURE_NSEC = 1 << 3,
3842 +pub struct git_message_trailer {
3843 + pub key: *const c_char,
3844 + pub value: *const c_char,
3848 +#[derive(Copy, Clone)]
3849 +pub struct git_message_trailer_array {
3850 + pub trailers: *mut git_message_trailer,
3851 + pub count: size_t,
3852 + pub _trailer_block: *mut c_char,
3857 pub fn git_libgit2_init() -> c_int;
3858 @@ -1972,6 +2059,16 @@
3859 repo: *mut git_repository,
3860 recurse_submodules: c_int,
3862 + pub fn git_repository_mergehead_foreach(
3863 + repo: *mut git_repository,
3864 + callback: git_repository_mergehead_foreach_cb,
3865 + payload: *mut c_void,
3867 + pub fn git_repository_fetchhead_foreach(
3868 + repo: *mut git_repository,
3869 + callback: git_repository_fetchhead_foreach_cb,
3870 + payload: *mut c_void,
3872 pub fn git_ignore_add_rule(repo: *mut git_repository, rules: *const c_char) -> c_int;
3873 pub fn git_ignore_clear_internal_rules(repo: *mut git_repository) -> c_int;
3874 pub fn git_ignore_path_is_ignored(
3875 @@ -2409,6 +2506,7 @@
3877 pub fn git_submodule_free(submodule: *mut git_submodule);
3878 pub fn git_submodule_head_id(submodule: *mut git_submodule) -> *const git_oid;
3879 + pub fn git_submodule_ignore(submodule: *mut git_submodule) -> git_submodule_ignore_t;
3880 pub fn git_submodule_index_id(submodule: *mut git_submodule) -> *const git_oid;
3881 pub fn git_submodule_init(submodule: *mut git_submodule, overwrite: c_int) -> c_int;
3882 pub fn git_submodule_location(status: *mut c_uint, submodule: *mut git_submodule) -> c_int;
3883 @@ -2589,7 +2687,17 @@
3886 pub fn git_commit_author(commit: *const git_commit) -> *const git_signature;
3887 + pub fn git_commit_author_with_mailmap(
3888 + out: *mut *mut git_signature,
3889 + commit: *const git_commit,
3890 + mailmap: *const git_mailmap,
3892 pub fn git_commit_committer(commit: *const git_commit) -> *const git_signature;
3893 + pub fn git_commit_committer_with_mailmap(
3894 + out: *mut *mut git_signature,
3895 + commit: *const git_commit,
3896 + mailmap: *const git_mailmap,
3898 pub fn git_commit_free(commit: *mut git_commit);
3899 pub fn git_commit_id(commit: *const git_commit) -> *const git_oid;
3900 pub fn git_commit_lookup(
3901 @@ -2712,6 +2820,7 @@
3904 pub fn git_branch_name(out: *mut *const c_char, branch: *const git_reference) -> c_int;
3905 + pub fn git_branch_name_is_valid(valid: *mut c_int, name: *const c_char) -> c_int;
3906 pub fn git_branch_remote_name(
3908 repo: *mut git_repository,
3909 @@ -3434,6 +3543,16 @@
3913 + pub fn git_diff_patchid(
3914 + out: *mut git_oid,
3915 + diff: *mut git_diff,
3916 + opts: *mut git_diff_patchid_options,
3918 + pub fn git_diff_patchid_options_init(
3919 + opts: *mut git_diff_patchid_options,
3924 pub fn git_patch_from_diff(out: *mut *mut git_patch, diff: *mut git_diff, idx: size_t)
3926 @@ -3573,6 +3692,13 @@
3927 comment_char: c_char,
3930 + pub fn git_message_trailers(
3931 + out: *mut git_message_trailer_array,
3932 + message: *const c_char,
3935 + pub fn git_message_trailer_array_free(trailer: *mut git_message_trailer_array);
3938 pub fn git_packbuilder_new(out: *mut *mut git_packbuilder, repo: *mut git_repository) -> c_int;
3939 pub fn git_packbuilder_set_threads(pb: *mut git_packbuilder, n: c_uint) -> c_uint;
3940 @@ -3853,6 +3979,9 @@
3941 given_opts: *const git_revert_options,
3945 + pub fn git_libgit2_version(major: *mut c_int, minor: *mut c_int, rev: *mut c_int) -> c_int;
3946 + pub fn git_libgit2_features() -> c_int;
3947 pub fn git_libgit2_opts(option: c_int, ...) -> c_int;
3950 @@ -3896,6 +4025,59 @@
3951 wt: *mut git_worktree,
3952 opts: *mut git_worktree_prune_options,
3955 + // Ref transactions
3956 + pub fn git_transaction_new(out: *mut *mut git_transaction, repo: *mut git_repository) -> c_int;
3957 + pub fn git_transaction_lock_ref(tx: *mut git_transaction, refname: *const c_char) -> c_int;
3958 + pub fn git_transaction_set_target(
3959 + tx: *mut git_transaction,
3960 + refname: *const c_char,
3961 + target: *const git_oid,
3962 + sig: *const git_signature,
3963 + msg: *const c_char,
3965 + pub fn git_transaction_set_symbolic_target(
3966 + tx: *mut git_transaction,
3967 + refname: *const c_char,
3968 + target: *const c_char,
3969 + sig: *const git_signature,
3970 + msg: *const c_char,
3972 + pub fn git_transaction_set_reflog(
3973 + tx: *mut git_transaction,
3974 + refname: *const c_char,
3975 + reflog: *const git_reflog,
3977 + pub fn git_transaction_remove(tx: *mut git_transaction, refname: *const c_char) -> c_int;
3978 + pub fn git_transaction_commit(tx: *mut git_transaction) -> c_int;
3979 + pub fn git_transaction_free(tx: *mut git_transaction);
3982 + pub fn git_mailmap_new(out: *mut *mut git_mailmap) -> c_int;
3983 + pub fn git_mailmap_from_buffer(
3984 + out: *mut *mut git_mailmap,
3985 + buf: *const c_char,
3988 + pub fn git_mailmap_from_repository(
3989 + out: *mut *mut git_mailmap,
3990 + repo: *mut git_repository,
3992 + pub fn git_mailmap_free(mm: *mut git_mailmap);
3993 + pub fn git_mailmap_resolve_signature(
3994 + out: *mut *mut git_signature,
3995 + mm: *const git_mailmap,
3996 + sig: *const git_signature,
3998 + pub fn git_mailmap_add_entry(
3999 + mm: *mut git_mailmap,
4000 + real_name: *const c_char,
4001 + real_email: *const c_char,
4002 + replace_name: *const c_char,
4003 + replace_email: *const c_char,
4006 + pub fn git_trace_set(level: git_trace_level_t, cb: git_trace_cb) -> c_int;
4010 @@ -3944,3 +4126,8 @@
4012 #[cfg(not(feature = "ssh"))]
4016 +pub fn vendored() -> bool {
4017 + cfg!(libgit2_vendored)