]> git.pld-linux.org Git - packages/rust.git/blame - libgit2.patch
- update git2 and libgit2 crates to latest versions, rel 3
[packages/rust.git] / libgit2.patch
CommitLineData
dfa5a2fd
JR
1diff -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
4@@ -1429,7 +1429,7 @@
5
6 [[package]]
7 name = "git2"
8-version = "0.13.17"
9+version = "0.13.23"
10 source = "registry+https://github.com/rust-lang/crates.io-index"
11 checksum = "1d250f5f82326884bd39c2853577e70a121775db76818ffa452ed1e80de12986"
12 dependencies = [
13@@ -1889,7 +1889,7 @@
14
15 [[package]]
16 name = "libgit2-sys"
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"
21 dependencies = [
22diff -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
25@@ -44,7 +44,7 @@
26 lazycell = "1.2.0"
27 libc = "0.2"
28 log = "0.4.6"
29-libgit2-sys = "0.12.18"
30+libgit2-sys = "0.12.24"
31 memchr = "2.1.3"
32 num_cpus = "1.0"
33 opener = "0.5"
34diff -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
37@@ -181,7 +181,7 @@
38
39 [[package]]
40 name = "git2"
41-version = "0.13.17"
42+version = "0.13.23"
43 source = "registry+https://github.com/rust-lang/crates.io-index"
44 checksum = "1d250f5f82326884bd39c2853577e70a121775db76818ffa452ed1e80de12986"
45 dependencies = [
46@@ -232,7 +232,7 @@
47
48 [[package]]
49 name = "libgit2-sys"
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"
54 dependencies = [
55diff -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
58@@ -854,7 +854,7 @@
59
60 [[package]]
61 name = "git2"
62-version = "0.13.17"
63+version = "0.13.23"
64 source = "registry+https://github.com/rust-lang/crates.io-index"
65 checksum = "1d250f5f82326884bd39c2853577e70a121775db76818ffa452ed1e80de12986"
66 dependencies = [
67@@ -1216,7 +1216,7 @@
68
69 [[package]]
70 name = "libgit2-sys"
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"
75 dependencies = [
76diff -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
79@@ -94,7 +94,7 @@
80
81 [[package]]
82 name = "git2"
83-version = "0.13.17"
84+version = "0.13.23"
85 dependencies = [
86 "bitflags",
87 "libc",
88@@ -162,7 +162,7 @@
89
90 [[package]]
91 name = "libgit2-sys"
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"
96 dependencies = [
97diff -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
100@@ -13,7 +13,7 @@
101 [package]
102 edition = "2018"
103 name = "git2"
104-version = "0.13.17"
105+version = "0.13.23"
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"
109@@ -29,7 +29,7 @@
110 version = "0.2"
111
112 [dependencies.libgit2-sys]
113-version = "0.12.18"
114+version = "0.12.24"
115
116 [dependencies.log]
117 version = "0.4.8"
118diff -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
121@@ -12,8 +12,7 @@
122 ## Rust version requirements
123
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.
128
129 ## Version of libgit2
130
131diff -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
134@@ -0,0 +1,175 @@
135+use crate::raw;
136+use std::ptr;
137+use std::str;
138+
139+/// All possible states of an attribute.
140+///
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.
147+ True,
148+ /// The attribute is unset (set to false).
149+ 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.
155+ Unspecified,
156+}
157+
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!(),
166+ }
167+ };
168+}
169+
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).
173+ ///
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()))
178+ }
179+
180+ /// Returns the state of an attribute by inspecting its [value](crate::Repository::get_attr_bytes)
181+ /// by a [byte](u8) [slice].
182+ ///
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);
190+ }
191+ }
192+ value
193+ }
194+
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()))
199+ }
200+}
201+
202+/// Compare two [`AttrValue`]s.
203+///
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,
216+ _ => false,
217+ }
218+ }
219+}
220+
221+#[cfg(test)]
222+mod tests {
223+ use super::AttrValue;
224+
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`.
233+ assert!(matches!(
234+ AttrValue::$function(Some(ATTR_TRUE.as_ref())),
235+ AttrValue::$variant(s) if as_bytes(s) == ATTR_TRUE.as_bytes()
236+ ));
237+ assert!(matches!(
238+ AttrValue::$function(Some(ATTR_FALSE.as_ref())),
239+ AttrValue::$variant(s) if as_bytes(s) == ATTR_FALSE.as_bytes()
240+ ));
241+ assert!(matches!(
242+ AttrValue::$function(Some(ATTR_UNSET.as_ref())),
243+ AttrValue::$variant(s) if as_bytes(s) == ATTR_UNSET.as_bytes()
244+ ));
245+ assert!(matches!(
246+ AttrValue::$function(Some("foo".as_ref())),
247+ AttrValue::$variant(s) if as_bytes(s) == b"foo"
248+ ));
249+ assert!(matches!(
250+ AttrValue::$function(Some("bar".as_ref())),
251+ AttrValue::$variant(s) if as_bytes(s) == b"bar"
252+ ));
253+ assert_eq!(AttrValue::$function(None), AttrValue::Unspecified);
254+ };
255+ }
256+
257+ #[test]
258+ fn attr_value_from_string() {
259+ test_attr_value!(from_string, String);
260+ }
261+
262+ #[test]
263+ fn attr_value_from_bytes() {
264+ test_attr_value!(from_bytes, String);
265+ assert!(matches!(
266+ AttrValue::from_bytes(Some(&[0xff])),
267+ AttrValue::Bytes(&[0xff])
268+ ));
269+ assert!(matches!(
270+ AttrValue::from_bytes(Some(b"\xffoobar")),
271+ AttrValue::Bytes(b"\xffoobar")
272+ ));
273+ }
274+
275+ #[test]
276+ fn attr_value_always_bytes() {
277+ test_attr_value!(always_bytes, Bytes);
278+ assert!(matches!(
279+ AttrValue::always_bytes(Some(&[0xff; 2])),
280+ AttrValue::Bytes(&[0xff, 0xff])
281+ ));
282+ assert!(matches!(
283+ AttrValue::always_bytes(Some(b"\xffoo")),
284+ AttrValue::Bytes(b"\xffoo")
285+ ));
286+ }
287+
288+ #[test]
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"));
308+ }
309+}
310diff -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
313@@ -228,6 +228,18 @@
314 }
315 self
316 }
317+
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;
321+ self
322+ }
323+
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;
327+ self
328+ }
329 }
330
331 impl<'repo> Binding for Blame<'repo> {
332@@ -235,7 +247,7 @@
333
334 unsafe fn from_raw(raw: *mut raw::git_blame) -> Blame<'repo> {
335 Blame {
336- raw: raw,
337+ raw,
338 _marker: marker::PhantomData,
339 }
340 }
341@@ -256,7 +268,7 @@
342
343 unsafe fn from_raw(raw: *mut raw::git_blame_hunk) -> BlameHunk<'blame> {
344 BlameHunk {
345- raw: raw,
346+ raw,
347 _marker: marker::PhantomData,
348 }
349 }
350diff -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
353@@ -56,7 +56,7 @@
354
355 unsafe fn from_raw(raw: *mut raw::git_blob) -> Blob<'repo> {
356 Blob {
357- raw: raw,
358+ raw,
359 _marker: marker::PhantomData,
360 }
361 }
362@@ -110,7 +110,7 @@
363
364 unsafe fn from_raw(raw: *mut raw::git_writestream) -> BlobWriter<'repo> {
365 BlobWriter {
366- raw: raw,
367+ raw,
368 need_cleanup: true,
369 _marker: marker::PhantomData,
370 }
371diff -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
374@@ -28,6 +28,17 @@
375 Branch { inner: reference }
376 }
377
378+ /// Ensure the branch name is well-formed.
379+ pub fn name_is_valid(name: &str) -> Result<bool, Error> {
380+ crate::init();
381+ let name = CString::new(name)?;
382+ let mut valid: libc::c_int = 0;
383+ unsafe {
384+ try_call!(raw::git_branch_name_is_valid(&mut valid, name.as_ptr()));
385+ }
386+ Ok(valid == 1)
387+ }
388+
389 /// Gain access to the reference that is this branch
390 pub fn get(&self) -> &Reference<'repo> {
391 &self.inner
392@@ -120,7 +131,7 @@
393 /// pointer.
394 pub unsafe fn from_raw(raw: *mut raw::git_branch_iterator) -> Branches<'repo> {
395 Branches {
396- raw: raw,
397+ raw,
398 _marker: marker::PhantomData,
399 }
400 }
401@@ -151,7 +162,7 @@
402
403 #[cfg(test)]
404 mod tests {
405- use crate::BranchType;
406+ use crate::{Branch, BranchType};
407
408 #[test]
409 fn smoke() {
410@@ -175,4 +186,12 @@
411
412 b1.delete().unwrap();
413 }
414+
415+ #[test]
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());
421+ }
422 }
423diff -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
426@@ -58,7 +58,9 @@
427
428 use crate::call::Convert;
429 use crate::{raw, BranchType, ConfigLevel, Direction, ObjectType, ResetType};
430- use crate::{AutotagOption, DiffFormat, FetchPrune, FileFavor, SubmoduleIgnore};
431+ use crate::{
432+ AutotagOption, DiffFormat, FetchPrune, FileFavor, SubmoduleIgnore, SubmoduleUpdate,
433+ };
434
435 impl<T: Copy> Convert<T> for T {
436 fn convert(&self) -> T {
437@@ -208,6 +210,18 @@
438 }
439 }
440 }
441+
442+ impl Convert<raw::git_submodule_update_t> for SubmoduleUpdate {
443+ fn convert(&self) -> raw::git_submodule_update_t {
444+ match *self {
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,
450+ }
451+ }
452+ }
453
454 impl Convert<raw::git_remote_autotag_option_t> for AutotagOption {
455 fn convert(&self) -> raw::git_remote_autotag_option_t {
456diff -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
459@@ -100,7 +100,7 @@
460 type Raw = *mut raw::git_cert;
461 unsafe fn from_raw(raw: *mut raw::git_cert) -> Cert<'a> {
462 Cert {
463- raw: raw,
464+ raw,
465 _marker: marker::PhantomData,
466 }
467 }
468diff -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
471@@ -6,7 +6,7 @@
472 use std::str;
473
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};
477
478 /// A structure to represent a git [commit][1]
479 ///
480@@ -105,6 +105,20 @@
481 str::from_utf8(self.raw_header_bytes()).ok()
482 }
483
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()?;
488+ unsafe {
489+ try_call!(raw::git_commit_header_field(
490+ buf.raw(),
491+ &*self.raw,
492+ raw_field
493+ ));
494+ }
495+ Ok(buf)
496+ }
497+
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() }
501@@ -169,6 +183,20 @@
502 }
503 }
504
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();
509+ unsafe {
510+ try_call!(raw::git_commit_author_with_mailmap(
511+ &mut ret,
512+ &*self.raw,
513+ &*mailmap.raw()
514+ ));
515+ Ok(Binding::from_raw(ret))
516+ }
517+ }
518+
519 /// Get the committer of this commit.
520 pub fn committer(&self) -> Signature<'_> {
521 unsafe {
522@@ -177,6 +205,20 @@
523 }
524 }
525
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();
530+ unsafe {
531+ try_call!(raw::git_commit_committer_with_mailmap(
532+ &mut ret,
533+ &*self.raw,
534+ &*mailmap.raw()
535+ ));
536+ Ok(Binding::from_raw(ret))
537+ }
538+ }
539+
540 /// Amend this existing commit with all non-`None` values
541 ///
542 /// This creates a new commit that is exactly the same as the old commit,
543@@ -271,7 +313,7 @@
544 type Raw = *mut raw::git_commit;
545 unsafe fn from_raw(raw: *mut raw::git_commit) -> Commit<'repo> {
546 Commit {
547- raw: raw,
548+ raw,
549 _marker: marker::PhantomData,
550 }
551 }
552@@ -367,6 +409,11 @@
553 commit.tree().unwrap();
554 assert_eq!(commit.parents().count(), 0);
555
556+ let tree_header_bytes = commit.header_field_bytes("tree").unwrap();
557+ assert_eq!(
558+ crate::Oid::from_str(tree_header_bytes.as_str().unwrap()).unwrap(),
559+ commit.tree_id()
560+ );
561 assert_eq!(commit.author().name(), Some("name"));
562 assert_eq!(commit.author().email(), Some("email"));
563 assert_eq!(commit.committer().name(), Some("name"));
564diff -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
567@@ -465,7 +465,7 @@
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 }
572+ Config { raw }
573 }
574 fn raw(&self) -> *mut raw::git_config {
575 self.raw
576@@ -534,7 +534,7 @@
577
578 unsafe fn from_raw(raw: *mut raw::git_config_entry) -> ConfigEntry<'cfg> {
579 ConfigEntry {
580- raw: raw,
581+ raw,
582 _marker: marker::PhantomData,
583 owned: true,
584 }
585@@ -549,7 +549,7 @@
586
587 unsafe fn from_raw(raw: *mut raw::git_config_iterator) -> ConfigEntries<'cfg> {
588 ConfigEntries {
589- raw: raw,
590+ raw,
591 _marker: marker::PhantomData,
592 }
593 }
594@@ -571,7 +571,7 @@
595 try_call_iter!(raw::git_config_next(&mut raw, self.raw));
596 Some(Ok(ConfigEntry {
597 owned: false,
598- raw: raw,
599+ raw,
600 _marker: marker::PhantomData,
601 }))
602 }
603diff -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
606@@ -22,6 +22,7 @@
607 pub username: Option<String>,
608 protocol: Option<String>,
609 host: Option<String>,
610+ port: Option<u16>,
611 path: Option<String>,
612 url: String,
613 commands: Vec<String>,
614@@ -170,7 +171,7 @@
615 type Raw = *mut raw::git_cred;
616
617 unsafe fn from_raw(raw: *mut raw::git_cred) -> Cred {
618- Cred { raw: raw }
619+ Cred { raw }
620 }
621 fn raw(&self) -> *mut raw::git_cred {
622 self.raw
623@@ -199,6 +200,7 @@
624 let mut ret = CredentialHelper {
625 protocol: None,
626 host: None,
627+ port: None,
628 path: None,
629 username: None,
630 url: url.to_string(),
631@@ -210,6 +212,7 @@
632 if let Some(url::Host::Domain(s)) = url.host() {
633 ret.host = Some(s.to_string());
634 }
635+ ret.port = url.port();
636 ret.protocol = Some(url.scheme().to_string());
637 }
638 ret
639@@ -408,7 +411,11 @@
640 let _ = writeln!(stdin, "protocol={}", p);
641 }
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);
646+ } else {
647+ let _ = writeln!(stdin, "host={}", p);
648+ }
649 }
650 if let Some(ref p) = self.path {
651 let _ = writeln!(stdin, "path={}", p);
652@@ -640,6 +647,19 @@
653 }
654
655 #[test]
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"
659+ };
660+ let (u, p) = CredentialHelper::new("https://example.com:3000/foo/bar")
661+ .config(&cfg)
662+ .execute()
663+ .unwrap();
664+ assert_eq!(u, "a");
665+ assert_eq!(p, "b");
666+ }
667+
668+ #[test]
669 #[cfg(feature = "ssh")]
670 fn ssh_key_from_memory() {
671 let cred = Cred::ssh_key_from_memory(
672diff -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
675@@ -44,7 +44,7 @@
676
677 unsafe fn from_raw(raw: *mut raw::git_describe_result) -> Describe<'repo> {
678 Describe {
679- raw: raw,
680+ raw,
681 _marker: marker::PhantomData,
682 }
683 }
684diff -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
687@@ -58,6 +58,11 @@
688 raw: raw::git_diff_format_email_options,
689 }
690
691+/// Control behavior of formatting emails
692+pub struct DiffPatchidOptions {
693+ raw: raw::git_diff_patchid_options,
694+}
695+
696 /// An iterator over the diffs in a delta
697 pub struct Deltas<'diff> {
698 range: Range<usize>,
699@@ -278,6 +283,21 @@
700 Ok(buf)
701 }
702
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],
707+ };
708+ unsafe {
709+ try_call!(raw::git_diff_patchid(
710+ &mut raw,
711+ self.raw,
712+ opts.map(|o| &mut o.raw)
713+ ));
714+ Ok(Binding::from_raw(&raw as *const _))
715+ }
716+ }
717+
718 // TODO: num_deltas_of_type, find_similar
719 }
720 impl Diff<'static> {
721@@ -289,6 +309,7 @@
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> {
725+ crate::init();
726 let mut diff: *mut raw::git_diff = std::ptr::null_mut();
727 unsafe {
728 // NOTE: Doesn't depend on repo, so lifetime can be 'static
729@@ -318,9 +339,9 @@
730 (*data)(delta, hunk, line)
731 });
732 if r == Some(true) {
733- 0
734+ raw::GIT_OK
735 } else {
736- -1
737+ raw::GIT_EUSER
738 }
739 }
740 }
741@@ -341,9 +362,9 @@
742 }
743 });
744 if r == Some(true) {
745- 0
746+ raw::GIT_OK
747 } else {
748- -1
749+ raw::GIT_EUSER
750 }
751 }
752 }
753@@ -365,9 +386,9 @@
754 }
755 });
756 if r == Some(true) {
757- 0
758+ raw::GIT_OK
759 } else {
760- -1
761+ raw::GIT_EUSER
762 }
763 }
764 }
765@@ -389,9 +410,9 @@
766 }
767 });
768 if r == Some(true) {
769- 0
770+ raw::GIT_OK
771 } else {
772- -1
773+ raw::GIT_EUSER
774 }
775 }
776 }
777@@ -415,9 +436,9 @@
778 }
779 });
780 if r == Some(true) {
781- 0
782+ raw::GIT_OK
783 } else {
784- -1
785+ raw::GIT_EUSER
786 }
787 }
788 }
789@@ -426,7 +447,7 @@
790 type Raw = *mut raw::git_diff;
791 unsafe fn from_raw(raw: *mut raw::git_diff) -> Diff<'repo> {
792 Diff {
793- raw: raw,
794+ raw,
795 _marker: marker::PhantomData,
796 }
797 }
798@@ -524,7 +545,7 @@
799 type Raw = *mut raw::git_diff_delta;
800 unsafe fn from_raw(raw: *mut raw::git_diff_delta) -> DiffDelta<'a> {
801 DiffDelta {
802- raw: raw,
803+ raw,
804 _marker: marker::PhantomData,
805 }
806 }
807@@ -609,7 +630,7 @@
808 type Raw = *const raw::git_diff_file;
809 unsafe fn from_raw(raw: *const raw::git_diff_file) -> DiffFile<'a> {
810 DiffFile {
811- raw: raw,
812+ raw,
813 _marker: marker::PhantomData,
814 }
815 }
816@@ -793,6 +814,11 @@
817 self.flag(raw::GIT_DIFF_IGNORE_WHITESPACE_EOL, ignore)
818 }
819
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)
823+ }
824+
825 /// When generating patch text, include the content of untracked files.
826 ///
827 /// This automatically turns on `include_untracked` but it does not turn on
828@@ -931,6 +957,61 @@
829 }
830 impl<'diff> ExactSizeIterator for Deltas<'diff> {}
831
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
836+ Context,
837+ ///
838+ Addition,
839+ ///
840+ Deletion,
841+ /// Both files have no LF at end
842+ ContextEOFNL,
843+ /// Old has no LF at end, new does
844+ AddEOFNL,
845+ /// Old has LF at end, new does not
846+ DeleteEOFNL,
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`.
849+ FileHeader,
850+ ///
851+ HunkHeader,
852+ /// For "Binary files x and y differ"
853+ Binary,
854+}
855+
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 {
859+ match raw {
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"),
870+ }
871+ }
872+ fn raw(&self) -> raw::git_diff_line_t {
873+ match *self {
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,
883+ }
884+ }
885+}
886+
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 @@
891 }
892 }
893
894+ /// origin of this `DiffLine`.
895+ ///
896+ pub fn origin_value(&self) -> DiffLineType {
897+ unsafe { Binding::from_raw((*self.raw).origin as raw::git_diff_line_t) }
898+ }
899+
900 /// Sigil showing the origin of this `DiffLine`.
901 ///
902 /// * ` ` - Line context
903@@ -999,7 +1086,7 @@
904 type Raw = *const raw::git_diff_line;
905 unsafe fn from_raw(raw: *const raw::git_diff_line) -> DiffLine<'a> {
906 DiffLine {
907- raw: raw,
908+ raw,
909 _marker: marker::PhantomData,
910 }
911 }
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> {
915 DiffHunk {
916- raw: raw,
917+ raw,
918 _marker: marker::PhantomData,
919 }
920 }
921@@ -1083,7 +1170,7 @@
922 }
923
924 impl DiffStats {
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 }
929 }
930@@ -1117,7 +1204,7 @@
931 type Raw = *mut raw::git_diff_stats;
932
933 unsafe fn from_raw(raw: *mut raw::git_diff_stats) -> DiffStats {
934- DiffStats { raw: raw }
935+ DiffStats { raw }
936 }
937 fn raw(&self) -> *mut raw::git_diff_stats {
938 self.raw
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> {
942 DiffBinary {
943- raw: raw,
944+ raw,
945 _marker: marker::PhantomData,
946 }
947 }
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> {
951 DiffBinaryFile {
952- raw: raw,
953+ raw,
954 _marker: marker::PhantomData,
955 }
956 }
957@@ -1433,9 +1520,29 @@
958 }
959 }
960
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() },
967+ };
968+ assert_eq!(
969+ unsafe {
970+ raw::git_diff_patchid_options_init(
971+ &mut opts.raw,
972+ raw::GIT_DIFF_PATCHID_OPTIONS_VERSION,
973+ )
974+ },
975+ 0
976+ );
977+ opts
978+ }
979+}
980+
981 #[cfg(test)]
982 mod tests {
983- use crate::{DiffOptions, Signature, Time};
984+ use crate::{DiffLineType, DiffOptions, Oid, Signature, Time};
985 use std::borrow::Borrow;
986 use std::fs::File;
987 use std::io::Write;
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());
994 }
995
996 #[test]
997@@ -1684,4 +1793,58 @@
998 assert_eq!(line.trim(), "")
999 }
1000 }
1001+
1002+ #[test]
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();
1013+ t!(diff.foreach(
1014+ &mut |_file, _progress| { true },
1015+ None,
1016+ None,
1017+ Some(&mut |_file, _hunk, line| {
1018+ origin_values.push(line.origin_value());
1019+ true
1020+ })
1021+ ));
1022+ assert_eq!(origin_values.len(), 1);
1023+ assert_eq!(origin_values[0], DiffLineType::Addition);
1024+ }
1025+
1026+ #[test]
1027+ fn foreach_exits_with_euser() {
1028+ let foo_path = Path::new("foo");
1029+ let bar_path = Path::new("foo");
1030+
1031+ let (td, repo) = crate::test::repo_init();
1032+ t!(t!(File::create(&td.path().join(foo_path))).write_all(b"bar\n"));
1033+
1034+ let mut index = t!(repo.index());
1035+ t!(index.add_path(foo_path));
1036+ t!(index.add_path(bar_path));
1037+
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)));
1041+
1042+ let mut calls = 0;
1043+ let result = diff.foreach(
1044+ &mut |_file, _progress| {
1045+ calls += 1;
1046+ false
1047+ },
1048+ None,
1049+ None,
1050+ None,
1051+ );
1052+
1053+ assert_eq!(result.unwrap_err().code(), crate::ErrorCode::User);
1054+ }
1055 }
1056diff -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
1059@@ -69,12 +69,12 @@
1060 }
1061
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();
1067 Error {
1068- code: code,
1069+ code,
1070 klass: (*ptr).klass,
1071- message: msg,
1072+ message,
1073 }
1074 }
1075
1076diff -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
1079@@ -166,7 +166,7 @@
1080 gid: entry.gid,
1081 file_size: entry.file_size,
1082 id: *entry.id.raw(),
1083- flags: flags,
1084+ flags,
1085 flags_extended: entry.flags_extended,
1086 path: path.as_ptr(),
1087 mtime: raw::git_index_time {
1088@@ -223,7 +223,7 @@
1089 gid: entry.gid,
1090 file_size: entry.file_size,
1091 id: *entry.id.raw(),
1092- flags: flags,
1093+ flags,
1094 flags_extended: entry.flags_extended,
1095 path: path.as_ptr(),
1096 mtime: raw::git_index_time {
1097@@ -600,7 +600,7 @@
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 }
1102+ Index { raw }
1103 }
1104 fn raw(&self) -> *mut raw::git_index {
1105 self.raw
1106@@ -718,15 +718,15 @@
1107 let path = slice::from_raw_parts(path as *const u8, pathlen);
1108
1109 IndexEntry {
1110- dev: dev,
1111- ino: ino,
1112- mode: mode,
1113- uid: uid,
1114- gid: gid,
1115- file_size: file_size,
1116+ dev,
1117+ ino,
1118+ mode,
1119+ uid,
1120+ gid,
1121+ file_size,
1122 id: Binding::from_raw(&id as *const _),
1123- flags: flags,
1124- flags_extended: flags_extended,
1125+ flags,
1126+ flags_extended,
1127 path: path.to_vec(),
1128 mtime: Binding::from_raw(mtime),
1129 ctime: Binding::from_raw(ctime),
1130diff -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
1133@@ -80,6 +80,7 @@
1134 use std::sync::Once;
1135
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};
1141@@ -91,15 +92,20 @@
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,
1150 };
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,
1160+};
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};
1175
1176 // Create a convinience method on bitflag struct which checks the given flag
1177@@ -633,6 +642,7 @@
1178 mod test;
1179 #[macro_use]
1180 mod panic;
1181+mod attr;
1182 mod call;
1183 mod util;
1184
1185@@ -657,6 +667,7 @@
1186 mod error;
1187 mod index;
1188 mod indexer;
1189+mod mailmap;
1190 mod mempack;
1191 mod merge;
1192 mod message;
1193@@ -685,8 +696,11 @@
1194 mod tag;
1195 mod tagforeach;
1196 mod time;
1197+mod tracing;
1198+mod transaction;
1199 mod tree;
1200 mod treebuilder;
1201+mod version;
1202 mod worktree;
1203
1204 fn init() {
1205@@ -929,6 +943,34 @@
1206 }
1207 }
1208
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 {
1212+ match raw {
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),
1219+ }
1220+ }
1221+}
1222+
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 {
1226+ match raw {
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),
1233+ }
1234+ }
1235+}
1236+
1237 bitflags! {
1238 /// Status flags for a single file
1239 ///
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.
1244+#[derive(Debug)]
1245 pub enum SubmoduleIgnore {
1246 /// Use the submodule's configuration
1247 Unspecified,
1248@@ -1184,6 +1227,31 @@
1249 All,
1250 }
1251
1252+/// Submodule update values
1253+///
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.
1258+#[derive(Debug)]
1259+pub enum SubmoduleUpdate {
1260+ /// The default; when a submodule is updated, checkout the new detached
1261+ /// HEAD to the submodule directory.
1262+ Checkout,
1263+ /// Update by rebasing the current checked out branch onto the commit from
1264+ /// the superproject.
1265+ Rebase,
1266+ /// Update by merging the commit in the superproject into the current
1267+ /// checkout out branch of the submodule.
1268+ Merge,
1269+ /// Do not update this submodule even when the commit in the superproject
1270+ /// is updated.
1271+ None,
1272+ /// Not used except as static initializer when we don't want any particular
1273+ /// update rule to be specified.
1274+ Default,
1275+}
1276+
1277 bitflags! {
1278 /// ...
1279 pub struct PathspecFlags: u32 {
1280diff -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
1283@@ -0,0 +1,134 @@
1284+use std::ffi::CString;
1285+use std::ptr;
1286+
1287+use crate::util::Binding;
1288+use crate::{raw, Error, Signature};
1289+
1290+/// A structure to represent a repository's .mailmap file.
1291+///
1292+/// The representation cannot be written to disk.
1293+pub struct Mailmap {
1294+ raw: *mut raw::git_mailmap,
1295+}
1296+
1297+impl Binding for Mailmap {
1298+ type Raw = *mut raw::git_mailmap;
1299+
1300+ unsafe fn from_raw(ptr: *mut raw::git_mailmap) -> Mailmap {
1301+ Mailmap { raw: ptr }
1302+ }
1303+
1304+ fn raw(&self) -> *mut raw::git_mailmap {
1305+ self.raw
1306+ }
1307+}
1308+
1309+impl Drop for Mailmap {
1310+ fn drop(&mut self) {
1311+ unsafe {
1312+ raw::git_mailmap_free(self.raw);
1313+ }
1314+ }
1315+}
1316+
1317+impl Mailmap {
1318+ /// Creates an empty, in-memory mailmap object.
1319+ pub fn new() -> Result<Mailmap, Error> {
1320+ crate::init();
1321+ let mut ret = ptr::null_mut();
1322+ unsafe {
1323+ try_call!(raw::git_mailmap_new(&mut ret));
1324+ Ok(Binding::from_raw(ret))
1325+ }
1326+ }
1327+
1328+ /// Creates an in-memory mailmap object representing the given buffer.
1329+ pub fn from_buffer(buf: &str) -> Result<Mailmap, Error> {
1330+ crate::init();
1331+ let mut ret = ptr::null_mut();
1332+ let len = buf.len();
1333+ let buf = CString::new(buf)?;
1334+ unsafe {
1335+ try_call!(raw::git_mailmap_from_buffer(&mut ret, buf, len));
1336+ Ok(Binding::from_raw(ret))
1337+ }
1338+ }
1339+
1340+ /// Adds a new entry to this in-memory mailmap object.
1341+ pub fn add_entry(
1342+ &mut self,
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)?;
1352+ unsafe {
1353+ try_call!(raw::git_mailmap_add_entry(
1354+ self.raw,
1355+ real_name,
1356+ real_email,
1357+ replace_name,
1358+ replace_email
1359+ ));
1360+ Ok(())
1361+ }
1362+ }
1363+
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();
1367+ unsafe {
1368+ try_call!(raw::git_mailmap_resolve_signature(
1369+ &mut ret,
1370+ &*self.raw,
1371+ sig.raw()
1372+ ));
1373+ Ok(Binding::from_raw(ret))
1374+ }
1375+ }
1376+}
1377+
1378+#[cfg(test)]
1379+mod tests {
1380+ use super::*;
1381+
1382+ #[test]
1383+ fn smoke() {
1384+ let sig_name = "name";
1385+ let sig_email = "email";
1386+ let sig = t!(Signature::now(sig_name, sig_email));
1387+
1388+ let mut mm = t!(Mailmap::new());
1389+
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));
1393+
1394+ t!(mm.add_entry(None, None, None, sig_email));
1395+ t!(mm.add_entry(
1396+ Some("real name"),
1397+ Some("real@email"),
1398+ Some(sig_name),
1399+ sig_email,
1400+ ));
1401+
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"));
1405+ }
1406+
1407+ #[test]
1408+ fn from_buffer() {
1409+ let buf = "<prøper@emæil> <email>";
1410+ let mm = t!(Mailmap::from_buffer(&buf));
1411+
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"));
1416+ }
1417+}
1418diff -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
1421@@ -16,7 +16,7 @@
1422
1423 unsafe fn from_raw(raw: *mut raw::git_odb_backend) -> Mempack<'odb> {
1424 Mempack {
1425- raw: raw,
1426+ raw,
1427 _marker: marker::PhantomData,
1428 }
1429 }
1430diff -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
1433@@ -178,7 +178,7 @@
1434 type Raw = *mut raw::git_annotated_commit;
1435 unsafe fn from_raw(raw: *mut raw::git_annotated_commit) -> AnnotatedCommit<'repo> {
1436 AnnotatedCommit {
1437- raw: raw,
1438+ raw,
1439 _marker: marker::PhantomData,
1440 }
1441 }
1442diff -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
1445@@ -1,4 +1,7 @@
1446+use core::ops::Range;
1447+use std::ffi::CStr;
1448 use std::ffi::CString;
1449+use std::ptr;
1450
1451 use libc::{c_char, c_int};
1452
1453@@ -31,12 +34,216 @@
1454 /// The default comment character for `message_prettify` ('#')
1455 pub const DEFAULT_COMMENT_CHAR: Option<u8> = Some(b'#');
1456
1457+/// Get the trailers for the given message.
1458+///
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))
1462+}
1463+
1464+/// Get the trailers for the given message.
1465+///
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
1468+/// as bytes.
1469+pub fn message_trailers_bytes<S: IntoCString>(message: S) -> Result<MessageTrailersBytes, Error> {
1470+ _message_trailers(message.into_c_string()?).map(|res| MessageTrailersBytes(res))
1471+}
1472+
1473+fn _message_trailers(message: CString) -> Result<MessageTrailers, Error> {
1474+ let ret = MessageTrailers::new();
1475+ unsafe {
1476+ try_call!(raw::git_message_trailers(ret.raw(), message));
1477+ }
1478+ Ok(ret)
1479+}
1480+
1481+/// Collection of UTF-8-encoded trailers.
1482+///
1483+/// Use `iter()` to get access to the values.
1484+pub struct MessageTrailersStrs(MessageTrailers);
1485+
1486+impl MessageTrailersStrs {
1487+ /// Create a borrowed iterator.
1488+ pub fn iter(&self) -> MessageTrailersStrsIterator<'_> {
1489+ MessageTrailersStrsIterator(self.0.iter())
1490+ }
1491+ /// The number of trailer key–value pairs.
1492+ pub fn len(&self) -> usize {
1493+ self.0.len()
1494+ }
1495+ /// Convert to the “bytes” variant.
1496+ pub fn to_bytes(self) -> MessageTrailersBytes {
1497+ MessageTrailersBytes(self.0)
1498+ }
1499+}
1500+
1501+/// Collection of unencoded (bytes) trailers.
1502+///
1503+/// Use `iter()` to get access to the values.
1504+pub struct MessageTrailersBytes(MessageTrailers);
1505+
1506+impl MessageTrailersBytes {
1507+ /// Create a borrowed iterator.
1508+ pub fn iter(&self) -> MessageTrailersBytesIterator<'_> {
1509+ MessageTrailersBytesIterator(self.0.iter())
1510+ }
1511+ /// The number of trailer key–value pairs.
1512+ pub fn len(&self) -> usize {
1513+ self.0.len()
1514+ }
1515+}
1516+
1517+struct MessageTrailers {
1518+ raw: raw::git_message_trailer_array,
1519+}
1520+
1521+impl MessageTrailers {
1522+ fn new() -> MessageTrailers {
1523+ crate::init();
1524+ unsafe {
1525+ Binding::from_raw(&mut raw::git_message_trailer_array {
1526+ trailers: ptr::null_mut(),
1527+ count: 0,
1528+ _trailer_block: ptr::null_mut(),
1529+ } as *mut _)
1530+ }
1531+ }
1532+ fn iter(&self) -> MessageTrailersIterator<'_> {
1533+ MessageTrailersIterator {
1534+ trailers: self,
1535+ range: Range {
1536+ start: 0,
1537+ end: self.raw.count,
1538+ },
1539+ }
1540+ }
1541+ fn len(&self) -> usize {
1542+ self.raw.count
1543+ }
1544+}
1545+
1546+impl Drop for MessageTrailers {
1547+ fn drop(&mut self) {
1548+ unsafe {
1549+ raw::git_message_trailer_array_free(&mut self.raw);
1550+ }
1551+ }
1552+}
1553+
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 }
1558+ }
1559+ fn raw(&self) -> *mut raw::git_message_trailer_array {
1560+ &self.raw as *const _ as *mut _
1561+ }
1562+}
1563+
1564+struct MessageTrailersIterator<'a> {
1565+ trailers: &'a MessageTrailers,
1566+ range: Range<usize>,
1567+}
1568+
1569+fn to_raw_tuple(trailers: &MessageTrailers, index: usize) -> (*const c_char, *const c_char) {
1570+ unsafe {
1571+ let addr = trailers.raw.trailers.wrapping_add(index);
1572+ ((*addr).key, (*addr).value)
1573+ }
1574+}
1575+
1576+/// Borrowed iterator over the UTF-8-encoded trailers.
1577+pub struct MessageTrailersStrsIterator<'a>(MessageTrailersIterator<'a>);
1578+
1579+impl<'pair> Iterator for MessageTrailersStrsIterator<'pair> {
1580+ type Item = (&'pair str, &'pair str);
1581+
1582+ fn next(&mut self) -> Option<Self::Item> {
1583+ self.0
1584+ .range
1585+ .next()
1586+ .map(|index| to_str_tuple(&self.0.trailers, index))
1587+ }
1588+
1589+ fn size_hint(&self) -> (usize, Option<usize>) {
1590+ self.0.range.size_hint()
1591+ }
1592+}
1593+
1594+impl ExactSizeIterator for MessageTrailersStrsIterator<'_> {
1595+ fn len(&self) -> usize {
1596+ self.0.range.len()
1597+ }
1598+}
1599+
1600+impl DoubleEndedIterator for MessageTrailersStrsIterator<'_> {
1601+ fn next_back(&mut self) -> Option<Self::Item> {
1602+ self.0
1603+ .range
1604+ .next_back()
1605+ .map(|index| to_str_tuple(&self.0.trailers, index))
1606+ }
1607+}
1608+
1609+fn to_str_tuple(trailers: &MessageTrailers, index: usize) -> (&str, &str) {
1610+ unsafe {
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();
1614+ (key, value)
1615+ }
1616+}
1617+
1618+/// Borrowed iterator over the raw (bytes) trailers.
1619+pub struct MessageTrailersBytesIterator<'a>(MessageTrailersIterator<'a>);
1620+
1621+impl<'pair> Iterator for MessageTrailersBytesIterator<'pair> {
1622+ type Item = (&'pair [u8], &'pair [u8]);
1623+
1624+ fn next(&mut self) -> Option<Self::Item> {
1625+ self.0
1626+ .range
1627+ .next()
1628+ .map(|index| to_bytes_tuple(&self.0.trailers, index))
1629+ }
1630+
1631+ fn size_hint(&self) -> (usize, Option<usize>) {
1632+ self.0.range.size_hint()
1633+ }
1634+}
1635+
1636+impl ExactSizeIterator for MessageTrailersBytesIterator<'_> {
1637+ fn len(&self) -> usize {
1638+ self.0.range.len()
1639+ }
1640+}
1641+
1642+impl DoubleEndedIterator for MessageTrailersBytesIterator<'_> {
1643+ fn next_back(&mut self) -> Option<Self::Item> {
1644+ self.0
1645+ .range
1646+ .next_back()
1647+ .map(|index| to_bytes_tuple(&self.0.trailers, index))
1648+ }
1649+}
1650+
1651+fn to_bytes_tuple(trailers: &MessageTrailers, index: usize) -> (&[u8], &[u8]) {
1652+ unsafe {
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();
1656+ (key, value)
1657+ }
1658+}
1659+
1660 #[cfg(test)]
1661 mod tests {
1662- use crate::{message_prettify, DEFAULT_COMMENT_CHAR};
1663
1664 #[test]
1665 fn prettify() {
1666+ use crate::{message_prettify, DEFAULT_COMMENT_CHAR};
1667+
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.
1671@@ -58,4 +265,80 @@
1672 "1\n"
1673 );
1674 }
1675+
1676+ #[test]
1677+ fn trailers() {
1678+ use crate::{message_trailers_bytes, message_trailers_strs, MessageTrailersStrs};
1679+ use std::collections::HashMap;
1680+
1681+ // no trailers
1682+ let message1 = "
1683+WHAT ARE WE HERE FOR
1684+
1685+What are we here for?
1686+
1687+Just to be eaten?
1688+";
1689+ let expected: HashMap<&str, &str> = HashMap::new();
1690+ assert_eq!(expected, to_map(&message_trailers_strs(message1).unwrap()));
1691+
1692+ // standard PSA
1693+ let message2 = "
1694+Attention all
1695+
1696+We are out of tomatoes.
1697+
1698+Spoken-by: Major Turnips
1699+Transcribed-by: Seargant Persimmons
1700+Signed-off-by: Colonel Kale
1701+";
1702+ let expected: HashMap<&str, &str> = vec![
1703+ ("Spoken-by", "Major Turnips"),
1704+ ("Transcribed-by", "Seargant Persimmons"),
1705+ ("Signed-off-by", "Colonel Kale"),
1706+ ]
1707+ .into_iter()
1708+ .collect();
1709+ assert_eq!(expected, to_map(&message_trailers_strs(message2).unwrap()));
1710+
1711+ // ignore everything after `---`
1712+ let message3 = "
1713+The fate of Seargant Green-Peppers
1714+
1715+Seargant Green-Peppers was killed by Caterpillar Battalion 44.
1716+
1717+Signed-off-by: Colonel Kale
1718+---
1719+I never liked that guy, anyway.
1720+
1721+Opined-by: Corporal Garlic
1722+";
1723+ let expected: HashMap<&str, &str> = vec![("Signed-off-by", "Colonel Kale")]
1724+ .into_iter()
1725+ .collect();
1726+ assert_eq!(expected, to_map(&message_trailers_strs(message3).unwrap()));
1727+
1728+ // Raw bytes message; not valid UTF-8
1729+ // Source: https://stackoverflow.com/a/3886015/1725151
1730+ let message4 = b"
1731+Be honest guys
1732+
1733+Am I a malformed brussels sprout?
1734+
1735+Signed-off-by: Lieutenant \xe2\x28\xa1prout
1736+";
1737+
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);
1742+
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);
1747+ }
1748+ map
1749+ }
1750+ }
1751 }
1752diff -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
1755@@ -53,7 +53,7 @@
1756 type Raw = *mut raw::git_note;
1757 unsafe fn from_raw(raw: *mut raw::git_note) -> Note<'repo> {
1758 Note {
1759- raw: raw,
1760+ raw,
1761 _marker: marker::PhantomData,
1762 }
1763 }
1764@@ -80,7 +80,7 @@
1765 type Raw = *mut raw::git_note_iterator;
1766 unsafe fn from_raw(raw: *mut raw::git_note_iterator) -> Notes<'repo> {
1767 Notes {
1768- raw: raw,
1769+ raw,
1770 _marker: marker::PhantomData,
1771 }
1772 }
1773diff -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
1776@@ -232,7 +232,7 @@
1777
1778 unsafe fn from_raw(raw: *mut raw::git_object) -> Object<'repo> {
1779 Object {
1780- raw: raw,
1781+ raw,
1782 _marker: marker::PhantomData,
1783 }
1784 }
1785diff -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
1788@@ -23,7 +23,7 @@
1789
1790 unsafe fn from_raw(raw: *mut raw::git_odb) -> Odb<'repo> {
1791 Odb {
1792- raw: raw,
1793+ raw,
1794 _marker: marker::PhantomData,
1795 }
1796 }
1797@@ -273,7 +273,7 @@
1798
1799 unsafe fn from_raw(raw: *mut raw::git_odb_object) -> OdbObject<'a> {
1800 OdbObject {
1801- raw: raw,
1802+ raw,
1803 _marker: marker::PhantomData,
1804 }
1805 }
1806@@ -327,7 +327,7 @@
1807
1808 unsafe fn from_raw(raw: *mut raw::git_odb_stream) -> OdbReader<'repo> {
1809 OdbReader {
1810- raw: raw,
1811+ raw,
1812 _marker: marker::PhantomData,
1813 }
1814 }
1815@@ -386,7 +386,7 @@
1816
1817 unsafe fn from_raw(raw: *mut raw::git_odb_stream) -> OdbWriter<'repo> {
1818 OdbWriter {
1819- raw: raw,
1820+ raw,
1821 _marker: marker::PhantomData,
1822 }
1823 }
1824diff -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
1827@@ -32,7 +32,7 @@
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 }
1832+ OidArray { raw }
1833 }
1834 fn raw(&self) -> raw::git_oidarray {
1835 self.raw
1836diff -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
1839@@ -35,7 +35,7 @@
1840 s.len() as libc::size_t
1841 ));
1842 }
1843- Ok(Oid { raw: raw })
1844+ Ok(Oid { raw })
1845 }
1846
1847 /// Parse a raw object id into an Oid structure.
1848@@ -52,7 +52,7 @@
1849 unsafe {
1850 try_call!(raw::git_oid_fromraw(&mut raw, bytes.as_ptr()));
1851 }
1852- Ok(Oid { raw: raw })
1853+ Ok(Oid { raw })
1854 }
1855 }
1856
1857diff -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
1860@@ -3,7 +3,7 @@
1861 use std::ffi::CString;
1862
1863 use crate::util::Binding;
1864-use crate::{call, raw, Buf, ConfigLevel, Error, IntoCString};
1865+use crate::{raw, Buf, ConfigLevel, Error, IntoCString};
1866
1867 /// Set the search path for a level of config data. The search path applied to
1868 /// shared attributes and ignore files, too.
1869@@ -23,11 +23,11 @@
1870 P: IntoCString,
1871 {
1872 crate::init();
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(),
1878- ))?;
1879+ path.into_c_string()?.as_ptr()
1880+ ));
1881 Ok(())
1882 }
1883
1884@@ -42,11 +42,11 @@
1885 /// the global state.
1886 pub unsafe fn reset_search_path(level: ConfigLevel) -> Result<(), Error> {
1887 crate::init();
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>(),
1893- ))?;
1894+ core::ptr::null::<u8>()
1895+ ));
1896 Ok(())
1897 }
1898
1899@@ -61,11 +61,11 @@
1900 pub unsafe fn get_search_path(level: ConfigLevel) -> Result<CString, Error> {
1901 crate::init();
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,
1907- buf.raw(),
1908- ))?;
1909+ buf.raw() as *const _
1910+ ));
1911 buf.into_c_string()
1912 }
1913
1914diff -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
1917@@ -21,7 +21,7 @@
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>,
1924 }
1925
1926@@ -122,7 +122,7 @@
1927 ptr as *mut _
1928 ));
1929 }
1930- self.progress = Some(progress);
1931+ self._progress = Some(progress);
1932 Ok(())
1933 }
1934
1935@@ -135,7 +135,7 @@
1936 None,
1937 ptr::null_mut()
1938 ));
1939- self.progress = None;
1940+ self._progress = None;
1941 }
1942 Ok(())
1943 }
1944@@ -174,7 +174,7 @@
1945 unsafe fn from_raw(ptr: *mut raw::git_packbuilder) -> PackBuilder<'repo> {
1946 PackBuilder {
1947 raw: ptr,
1948- progress: None,
1949+ _progress: None,
1950 _marker: marker::PhantomData,
1951 }
1952 }
1953diff -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
1956@@ -24,7 +24,7 @@
1957 pub fn check() {
1958 let err = LAST_ERROR.with(|slot| slot.borrow_mut().take());
1959 if let Some(err) = err {
1960- panic!(err)
1961+ std::panic::resume_unwind(err);
1962 }
1963 }
1964
1965diff -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
1968@@ -21,7 +21,7 @@
1969 type Raw = *mut raw::git_patch;
1970 unsafe fn from_raw(raw: Self::Raw) -> Self {
1971 Patch {
1972- raw: raw,
1973+ raw,
1974 buffers: PhantomData,
1975 }
1976 }
1977diff -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
1980@@ -168,7 +168,7 @@
1981 type Raw = *mut raw::git_pathspec;
1982
1983 unsafe fn from_raw(raw: *mut raw::git_pathspec) -> Pathspec {
1984- Pathspec { raw: raw }
1985+ Pathspec { raw }
1986 }
1987 fn raw(&self) -> *mut raw::git_pathspec {
1988 self.raw
1989@@ -268,7 +268,7 @@
1990
1991 unsafe fn from_raw(raw: *mut raw::git_pathspec_match_list) -> PathspecMatchList<'ps> {
1992 PathspecMatchList {
1993- raw: raw,
1994+ raw,
1995 _marker: marker::PhantomData,
1996 }
1997 }
1998diff -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
2001@@ -230,7 +230,7 @@
2002 type Raw = *mut raw::git_rebase;
2003 unsafe fn from_raw(raw: *mut raw::git_rebase) -> Rebase<'repo> {
2004 Rebase {
2005- raw: raw,
2006+ raw,
2007 _marker: marker::PhantomData,
2008 }
2009 }
2010@@ -324,7 +324,7 @@
2011 type Raw = *const raw::git_rebase_operation;
2012 unsafe fn from_raw(raw: *const raw::git_rebase_operation) -> RebaseOperation<'rebase> {
2013 RebaseOperation {
2014- raw: raw,
2015+ raw,
2016 _marker: marker::PhantomData,
2017 }
2018 }
2019diff -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
2022@@ -387,7 +387,7 @@
2023 type Raw = *mut raw::git_reference;
2024 unsafe fn from_raw(raw: *mut raw::git_reference) -> Reference<'repo> {
2025 Reference {
2026- raw: raw,
2027+ raw,
2028 _marker: marker::PhantomData,
2029 }
2030 }
2031@@ -419,7 +419,7 @@
2032 type Raw = *mut raw::git_reference_iterator;
2033 unsafe fn from_raw(raw: *mut raw::git_reference_iterator) -> References<'repo> {
2034 References {
2035- raw: raw,
2036+ raw,
2037 _marker: marker::PhantomData,
2038 }
2039 }
2040diff -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
2043@@ -103,7 +103,7 @@
2044 type Raw = *mut raw::git_reflog;
2045
2046 unsafe fn from_raw(raw: *mut raw::git_reflog) -> Reflog {
2047- Reflog { raw: raw }
2048+ Reflog { raw }
2049 }
2050 fn raw(&self) -> *mut raw::git_reflog {
2051 self.raw
2052@@ -151,7 +151,7 @@
2053
2054 unsafe fn from_raw(raw: *const raw::git_reflog_entry) -> ReflogEntry<'reflog> {
2055 ReflogEntry {
2056- raw: raw,
2057+ raw,
2058 _marker: marker::PhantomData,
2059 }
2060 }
2061diff -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
2064@@ -112,7 +112,7 @@
2065
2066 unsafe fn from_raw(raw: *const raw::git_refspec) -> Refspec<'remote> {
2067 Refspec {
2068- raw: raw,
2069+ raw,
2070 _marker: marker::PhantomData,
2071 }
2072 }
2073diff -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
2076@@ -1,11 +1,12 @@
2077 use libc;
2078-use std::ffi::CString;
2079+use raw::git_strarray;
2080 use std::marker;
2081 use std::mem;
2082 use std::ops::Range;
2083 use std::ptr;
2084 use std::slice;
2085 use std::str;
2086+use std::{ffi::CString, os::raw::c_char};
2087
2088 use crate::string_array::StringArray;
2089 use crate::util::Binding;
2090@@ -43,6 +44,8 @@
2091 prune: FetchPrune,
2092 update_fetchhead: bool,
2093 download_tags: AutotagOption,
2094+ custom_headers: Vec<CString>,
2095+ custom_headers_ptrs: Vec<*const c_char>,
2096 }
2097
2098 /// Options to control the behavior of a git push.
2099@@ -50,6 +53,8 @@
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>,
2105 }
2106
2107 /// Holds callbacks for a connection to a `Remote`. Disconnects when dropped
2108@@ -62,7 +67,7 @@
2109 pub fn remote_into_raw(remote: Remote<'_>) -> *mut raw::git_remote {
2110 let ret = remote.raw;
2111 mem::forget(remote);
2112- return ret;
2113+ ret
2114 }
2115
2116 impl<'repo> Remote<'repo> {
2117@@ -221,6 +226,17 @@
2118 Ok(())
2119 }
2120
2121+ /// Cancel the operation
2122+ ///
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> {
2126+ unsafe {
2127+ try_call!(raw::git_remote_stop(self.raw));
2128+ }
2129+ Ok(())
2130+ }
2131+
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 @@
2136 }
2137 }
2138
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));
2142+ unsafe {
2143+ try_call!(raw::git_remote_prune(self.raw, &cbs.raw()));
2144+ }
2145+ Ok(())
2146+ }
2147+
2148 /// Get the remote's list of fetch refspecs
2149 pub fn fetch_refspecs(&self) -> Result<StringArray, Error> {
2150 unsafe {
2151@@ -381,7 +406,7 @@
2152
2153 unsafe fn from_raw(raw: *mut raw::git_remote) -> Remote<'repo> {
2154 Remote {
2155- raw: raw,
2156+ raw,
2157 _marker: marker::PhantomData,
2158 }
2159 }
2160@@ -454,6 +479,8 @@
2161 prune: FetchPrune::Unspecified,
2162 update_fetchhead: true,
2163 download_tags: AutotagOption::Unspecified,
2164+ custom_headers: Vec::new(),
2165+ custom_headers_ptrs: Vec::new(),
2166 }
2167 }
2168
2169@@ -491,6 +518,16 @@
2170 self.download_tags = opt;
2171 self
2172 }
2173+
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
2177+ .iter()
2178+ .map(|&s| CString::new(s).unwrap())
2179+ .collect();
2180+ self.custom_headers_ptrs = self.custom_headers.iter().map(|s| s.as_ptr()).collect();
2181+ self
2182+ }
2183 }
2184
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 {
2192- count: 0,
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 _,
2197 },
2198 }
2199 }
2200@@ -537,6 +573,8 @@
2201 callbacks: None,
2202 proxy: None,
2203 pb_parallelism: 1,
2204+ custom_headers: Vec::new(),
2205+ custom_headers_ptrs: Vec::new(),
2206 }
2207 }
2208
2209@@ -562,6 +600,16 @@
2210 self.pb_parallelism = parallel;
2211 self
2212 }
2213+
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
2217+ .iter()
2218+ .map(|&s| CString::new(s).unwrap())
2219+ .collect();
2220+ self.custom_headers_ptrs = self.custom_headers.iter().map(|s| s.as_ptr()).collect();
2221+ self
2222+ }
2223 }
2224
2225 impl<'cb> Binding for PushOptions<'cb> {
2226@@ -584,10 +632,9 @@
2227 .map(|m| m.raw())
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 {
2232- count: 0,
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 _,
2237 },
2238 }
2239 }
2240@@ -614,6 +661,11 @@
2241 pub fn default_branch(&self) -> Result<Buf, Error> {
2242 self.remote.default_branch()
2243 }
2244+
2245+ /// access remote bound to this connection
2246+ pub fn remote(&mut self) -> &mut Remote<'repo> {
2247+ self.remote
2248+ }
2249 }
2250
2251 impl<'repo, 'connection, 'cb> Drop for RemoteConnection<'repo, 'connection, 'cb> {
2252@@ -636,7 +688,7 @@
2253 drop(repo);
2254
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);
2261@@ -646,6 +698,8 @@
2262
2263 let stats = origin.stats();
2264 assert_eq!(stats.total_objects(), 0);
2265+
2266+ t!(origin.stop());
2267 }
2268
2269 #[test]
2270@@ -847,4 +901,46 @@
2271 let commit = repo.find_commit(commit).unwrap();
2272 assert_eq!(commit.message(), Some("initial"));
2273 }
2274+
2275+ #[test]
2276+ fn prune() {
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();
2281+
2282+ let td2 = TempDir::new().unwrap();
2283+ let url = crate::test::path2url(&td.path());
2284+ let repo = Repository::clone(&url, &td2).unwrap();
2285+
2286+ fn assert_branch_count(repo: &Repository, count: usize) {
2287+ assert_eq!(
2288+ repo.branches(Some(crate::BranchType::Remote))
2289+ .unwrap()
2290+ .filter(|b| b.as_ref().unwrap().0.name().unwrap() == Some("origin/stale"))
2291+ .count(),
2292+ count,
2293+ );
2294+ }
2295+
2296+ assert_branch_count(&repo, 1);
2297+
2298+ // delete `stale` branch on remote repo
2299+ let mut stale_branch = remote_repo
2300+ .find_branch("stale", crate::BranchType::Local)
2301+ .unwrap();
2302+ stale_branch.delete().unwrap();
2303+
2304+ // prune
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());
2311+ true
2312+ });
2313+ remote.prune(Some(callbacks)).unwrap();
2314+ assert_branch_count(&repo, 0);
2315+ }
2316 }
2317diff -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
2320@@ -19,19 +19,82 @@
2321 use crate::worktree::{Worktree, WorktreeAddOptions};
2322 use crate::CherrypickOptions;
2323 use crate::RevertOptions;
2324+use crate::{mailmap::Mailmap, panic};
2325 use crate::{
2326 raw, AttrCheckFlags, Buf, Error, Object, Remote, RepositoryOpenFlags, RepositoryState, Revspec,
2327 StashFlags,
2328 };
2329 use crate::{
2330- AnnotatedCommit, MergeAnalysis, MergeOptions, MergePreference, SubmoduleIgnore, SubmoduleStatus,
2331+ AnnotatedCommit, MergeAnalysis, MergeOptions, MergePreference, SubmoduleIgnore,
2332+ SubmoduleStatus, SubmoduleUpdate,
2333 };
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};
2341+
2342+type MergeheadForeachCb<'a> = dyn FnMut(&Oid) -> bool + 'a;
2343+type FetchheadForeachCb<'a> = dyn FnMut(&str, &[u8], &Oid, bool) -> bool + 'a;
2344+
2345+struct FetchheadForeachCbData<'a> {
2346+ callback: &'a mut FetchheadForeachCb<'a>,
2347+}
2348+
2349+struct MergeheadForeachCbData<'a> {
2350+ callback: &'a mut MergeheadForeachCb<'a>,
2351+}
2352+
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<'_>);
2356+ let res = {
2357+ let callback = &mut data.callback;
2358+ callback(&Binding::from_raw(oid))
2359+ };
2360+
2361+ if res {
2362+ 0
2363+ } else {
2364+ 1
2365+ }
2366+ })
2367+ .unwrap_or(1)
2368+}
2369+
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,
2374+ is_merge: c_uint,
2375+ payload: *mut c_void,
2376+) -> c_int {
2377+ panic::wrap(|| unsafe {
2378+ let data = &mut *(payload as *mut FetchheadForeachCbData<'_>);
2379+ let res = {
2380+ let callback = &mut data.callback;
2381+
2382+ assert!(!ref_name.is_null());
2383+ assert!(!remote_url.is_null());
2384+ assert!(!oid.is_null());
2385+
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;
2390+
2391+ callback(&ref_name, remote_url, &oid, is_merge)
2392+ };
2393+
2394+ if res {
2395+ 0
2396+ } else {
2397+ 1
2398+ }
2399+ })
2400+ .unwrap_or(1)
2401+}
2402
2403 /// An owned git repository, representing all state associated with the
2404 /// underlying filesystem.
2405@@ -952,6 +1015,14 @@
2406 }
2407
2408 /// Get the value of a git attribute for a path as a string.
2409+ ///
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.
2414+ ///
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.
2417 pub fn get_attr(
2418 &self,
2419 path: &Path,
2420@@ -964,6 +1035,14 @@
2421 }
2422
2423 /// Get the value of a git attribute for a path as a byte slice.
2424+ ///
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.
2429+ ///
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(
2433 &self,
2434 path: &Path,
2435@@ -1619,6 +1698,62 @@
2436 Ok(SubmoduleStatus::from_bits_truncate(ret as u32))
2437 }
2438
2439+ /// Set the ignore rule for the submodule in the configuration
2440+ ///
2441+ /// This does not affect any currently-loaded instances.
2442+ pub fn submodule_set_ignore(
2443+ &mut self,
2444+ name: &str,
2445+ ignore: SubmoduleIgnore,
2446+ ) -> Result<(), Error> {
2447+ let name = CString::new(name)?;
2448+ unsafe {
2449+ try_call!(raw::git_submodule_set_ignore(self.raw(), name, ignore));
2450+ }
2451+ Ok(())
2452+ }
2453+
2454+ /// Set the update rule for the submodule in the configuration
2455+ ///
2456+ /// This setting won't affect any existing instances.
2457+ pub fn submodule_set_update(
2458+ &mut self,
2459+ name: &str,
2460+ update: SubmoduleUpdate,
2461+ ) -> Result<(), Error> {
2462+ let name = CString::new(name)?;
2463+ unsafe {
2464+ try_call!(raw::git_submodule_set_update(self.raw(), name, update));
2465+ }
2466+ Ok(())
2467+ }
2468+
2469+ /// Set the URL for the submodule in the configuration
2470+ ///
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)?;
2476+ unsafe {
2477+ try_call!(raw::git_submodule_set_url(self.raw(), name, url));
2478+ }
2479+ Ok(())
2480+ }
2481+
2482+ /// Set the branch for the submodule in the configuration
2483+ ///
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)?;
2489+ unsafe {
2490+ try_call!(raw::git_submodule_set_branch(self.raw(), name, branch_name));
2491+ }
2492+ Ok(())
2493+ }
2494+
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() {
2501 Some(v) => v,
2502- None => 0 as *const _,
2503+ None => std::ptr::null(),
2504 };
2505 unsafe {
2506 try_call!(raw::git_cherrypick(self.raw(), commit.raw(), ptr_raw_opts));
2507@@ -2794,6 +2929,26 @@
2508 }
2509 }
2510
2511+ /// Apply a Diff to the provided tree, and return the resulting Index.
2512+ pub fn apply_to_tree(
2513+ &self,
2514+ tree: &Tree<'_>,
2515+ diff: &Diff<'_>,
2516+ options: Option<&mut ApplyOptions<'_>>,
2517+ ) -> Result<Index, Error> {
2518+ let mut ret = ptr::null_mut();
2519+ unsafe {
2520+ try_call!(raw::git_apply_to_tree(
2521+ &mut ret,
2522+ self.raw,
2523+ tree.raw(),
2524+ diff.raw(),
2525+ options.map(|s| s.raw()).unwrap_or(ptr::null())
2526+ ));
2527+ Ok(Binding::from_raw(ret))
2528+ }
2529+ }
2530+
2531 /// Reverts the given commit, producing changes in the index and working directory.
2532 pub fn revert(
2533 &self,
2534@@ -2880,6 +3035,70 @@
2535 Ok(Binding::from_raw(raw))
2536 }
2537 }
2538+
2539+ /// Create a new transaction
2540+ pub fn transaction<'a>(&'a self) -> Result<Transaction<'a>, Error> {
2541+ let mut raw = ptr::null_mut();
2542+ unsafe {
2543+ try_call!(raw::git_transaction_new(&mut raw, self.raw));
2544+ Ok(Binding::from_raw(raw))
2545+ }
2546+ }
2547+
2548+ /// Gets this repository's mailmap.
2549+ pub fn mailmap(&self) -> Result<Mailmap, Error> {
2550+ let mut ret = ptr::null_mut();
2551+ unsafe {
2552+ try_call!(raw::git_mailmap_from_repository(&mut ret, self.raw));
2553+ Ok(Binding::from_raw(ret))
2554+ }
2555+ }
2556+
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>
2560+ where
2561+ C: FnMut(&Oid) -> bool,
2562+ {
2563+ unsafe {
2564+ let mut data = MergeheadForeachCbData {
2565+ callback: &mut callback,
2566+ };
2567+ let cb: raw::git_repository_mergehead_foreach_cb = Some(mergehead_foreach_cb);
2568+ try_call!(raw::git_repository_mergehead_foreach(
2569+ self.raw(),
2570+ cb,
2571+ &mut data as *mut _ as *mut _
2572+ ));
2573+ Ok(())
2574+ }
2575+ }
2576+
2577+ /// Invoke 'callback' for each entry in the given FETCH_HEAD file.
2578+ ///
2579+ /// `callback` will be called with with following arguments:
2580+ ///
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>
2586+ where
2587+ C: FnMut(&str, &[u8], &Oid, bool) -> bool,
2588+ {
2589+ unsafe {
2590+ let mut data = FetchheadForeachCbData {
2591+ callback: &mut callback,
2592+ };
2593+ let cb: raw::git_repository_fetchhead_foreach_cb = Some(fetchhead_foreach_cb);
2594+ try_call!(raw::git_repository_fetchhead_foreach(
2595+ self.raw(),
2596+ cb,
2597+ &mut data as *mut _ as *mut _
2598+ ));
2599+ Ok(())
2600+ }
2601+ }
2602 }
2603
2604 impl Binding for Repository {
2605@@ -3062,7 +3281,9 @@
2606 mod tests {
2607 use crate::build::CheckoutBuilder;
2608 use crate::CherrypickOptions;
2609- use crate::{ObjectType, Oid, Repository, ResetType};
2610+ use crate::{
2611+ ObjectType, Oid, Repository, ResetType, Signature, SubmoduleIgnore, SubmoduleUpdate,
2612+ };
2613 use std::ffi::OsStr;
2614 use std::fs;
2615 use std::path::Path;
2616@@ -3705,4 +3926,143 @@
2617
2618 Ok(())
2619 }
2620+
2621+ #[test]
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());
2626+ let name = "bar";
2627+ {
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()?;
2633+ }
2634+
2635+ // update strategy
2636+ repo2.submodule_set_update(name, SubmoduleUpdate::None)?;
2637+ assert!(matches!(
2638+ repo2.find_submodule(name)?.update_strategy(),
2639+ SubmoduleUpdate::None
2640+ ));
2641+ repo2.submodule_set_update(name, SubmoduleUpdate::Rebase)?;
2642+ assert!(matches!(
2643+ repo2.find_submodule(name)?.update_strategy(),
2644+ SubmoduleUpdate::Rebase
2645+ ));
2646+
2647+ // ignore rule
2648+ repo2.submodule_set_ignore(name, SubmoduleIgnore::Untracked)?;
2649+ assert!(matches!(
2650+ repo2.find_submodule(name)?.ignore_rule(),
2651+ SubmoduleIgnore::Untracked
2652+ ));
2653+ repo2.submodule_set_ignore(name, SubmoduleIgnore::Dirty)?;
2654+ assert!(matches!(
2655+ repo2.find_submodule(name)?.ignore_rule(),
2656+ SubmoduleIgnore::Dirty
2657+ ));
2658+
2659+ // url
2660+ repo2.submodule_set_url(name, "fake-url")?;
2661+ assert_eq!(repo2.find_submodule(name)?.url(), Some("fake-url"));
2662+
2663+ // branch
2664+ repo2.submodule_set_branch(name, "fake-branch")?;
2665+ assert_eq!(repo2.find_submodule(name)?.branch(), Some("fake-branch"));
2666+
2667+ Ok(())
2668+ }
2669+
2670+ #[test]
2671+ fn smoke_mailmap_from_repository() {
2672+ let (_td, repo) = crate::test::repo_init();
2673+
2674+ let commit = {
2675+ let head = t!(repo.head()).target().unwrap();
2676+ t!(repo.find_commit(head))
2677+ };
2678+
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"));
2686+
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());
2695+
2696+ let commit = {
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);
2703+ t!(fs::write(
2704+ p,
2705+ r#"
2706+Author Name <author.proper@email> name <email>
2707+Committer Name <committer.proper@email> <committer@email>"#,
2708+ ));
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));
2713+
2714+ let head = t!(repo.commit(
2715+ Some("HEAD"),
2716+ &author,
2717+ t!(&Signature::now("committer", "committer@email")),
2718+ "Add mailmap",
2719+ &tree_mailmap,
2720+ &[&commit],
2721+ ));
2722+ t!(repo.find_commit(head))
2723+ };
2724+
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"));
2735+
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));
2740+
2741+ let mm_resolve_author = t!(mailmap.resolve_signature(&author));
2742+ let mm_resolve_committer = t!(mailmap.resolve_signature(&committer));
2743+
2744+ // Mailmap Signature lifetime is independent of Commit lifetime.
2745+ drop(author);
2746+ drop(committer);
2747+ drop(commit);
2748+
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"));
2754+
2755+ // resolve_signature() works
2756+ assert_eq!(mm_resolve_author.email(), mailmapped_author.email());
2757+ assert_eq!(mm_resolve_committer.email(), mailmapped_committer.email());
2758+ }
2759 }
2760diff -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
2763@@ -14,11 +14,7 @@
2764 to: Option<Object<'repo>>,
2765 mode: RevparseMode,
2766 ) -> Revspec<'repo> {
2767- Revspec {
2768- from: from,
2769- to: to,
2770- mode: mode,
2771- }
2772+ Revspec { from, to, mode }
2773 }
2774
2775 /// Access the `from` range of this revspec.
2776diff -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
2779@@ -1,9 +1,9 @@
2780-use libc::c_uint;
2781+use libc::{c_int, c_uint, c_void};
2782 use std::ffi::CString;
2783 use std::marker;
2784
2785 use crate::util::Binding;
2786-use crate::{raw, Error, Oid, Repository, Sort};
2787+use crate::{panic, raw, Error, Oid, Repository, Sort};
2788
2789 /// A revwalk allows traversal of the commit graph defined by including one or
2790 /// more leaves and excluding one or more roots.
2791@@ -12,6 +12,40 @@
2792 _marker: marker::PhantomData<&'repo Repository>,
2793 }
2794
2795+/// A `Revwalk` with an assiciated "hide callback", see `with_hide_callback`
2796+pub struct RevwalkWithHideCb<'repo, 'cb, C>
2797+where
2798+ C: FnMut(Oid) -> bool,
2799+{
2800+ revwalk: Revwalk<'repo>,
2801+ _marker: marker::PhantomData<&'cb C>,
2802+}
2803+
2804+extern "C" fn revwalk_hide_cb<C>(commit_id: *const raw::git_oid, payload: *mut c_void) -> c_int
2805+where
2806+ C: FnMut(Oid) -> bool,
2807+{
2808+ panic::wrap(|| unsafe {
2809+ let hide_cb = payload as *mut C;
2810+ if (*hide_cb)(Oid::from_raw(commit_id)) {
2811+ 1
2812+ } else {
2813+ 0
2814+ }
2815+ })
2816+ .unwrap_or(-1)
2817+}
2818+
2819+impl<'repo, 'cb, C: FnMut(Oid) -> bool> RevwalkWithHideCb<'repo, 'cb, C> {
2820+ /// Consumes the `RevwalkWithHideCb` and returns the contained `Revwalk`.
2821+ ///
2822+ /// Note that this will reset the `Revwalk`.
2823+ pub fn into_inner(mut self) -> Result<Revwalk<'repo>, Error> {
2824+ self.revwalk.reset()?;
2825+ Ok(self.revwalk)
2826+ }
2827+}
2828+
2829 impl<'repo> Revwalk<'repo> {
2830 /// Reset a revwalk to allow re-configuring it.
2831 ///
2832@@ -119,6 +153,29 @@
2833 Ok(())
2834 }
2835
2836+ /// Hide all commits for which the callback returns true from
2837+ /// the walk.
2838+ pub fn with_hide_callback<'cb, C>(
2839+ self,
2840+ callback: &'cb C,
2841+ ) -> Result<RevwalkWithHideCb<'repo, 'cb, C>, Error>
2842+ where
2843+ C: FnMut(Oid) -> bool,
2844+ {
2845+ let r = RevwalkWithHideCb {
2846+ revwalk: self,
2847+ _marker: marker::PhantomData,
2848+ };
2849+ unsafe {
2850+ raw::git_revwalk_add_hide_cb(
2851+ r.revwalk.raw(),
2852+ Some(revwalk_hide_cb::<C>),
2853+ callback as *const _ as *mut c_void,
2854+ );
2855+ };
2856+ Ok(r)
2857+ }
2858+
2859 /// Hide the repository's HEAD
2860 ///
2861 /// For more information, see `hide`.
2862@@ -163,7 +220,7 @@
2863 type Raw = *mut raw::git_revwalk;
2864 unsafe fn from_raw(raw: *mut raw::git_revwalk) -> Revwalk<'repo> {
2865 Revwalk {
2866- raw: raw,
2867+ raw,
2868 _marker: marker::PhantomData,
2869 }
2870 }
2871@@ -191,6 +248,15 @@
2872 }
2873 }
2874
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();
2880+ out
2881+ }
2882+}
2883+
2884 #[cfg(test)]
2885 mod tests {
2886 #[test]
2887@@ -216,4 +282,35 @@
2888 walk.hide_head().unwrap();
2889 assert_eq!(walk.by_ref().count(), 0);
2890 }
2891+
2892+ #[test]
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();
2897+
2898+ let mut walk = repo.revwalk().unwrap();
2899+ walk.push(target).unwrap();
2900+
2901+ let oids: Vec<crate::Oid> = walk.by_ref().collect::<Result<Vec<_>, _>>().unwrap();
2902+
2903+ assert_eq!(oids.len(), 1);
2904+ assert_eq!(oids[0], target);
2905+
2906+ walk.reset().unwrap();
2907+ walk.push_head().unwrap();
2908+ assert_eq!(walk.by_ref().count(), 1);
2909+
2910+ walk.reset().unwrap();
2911+ walk.push_head().unwrap();
2912+
2913+ let hide_cb = |oid| oid == target;
2914+ let mut walk = walk.with_hide_callback(&hide_cb).unwrap();
2915+
2916+ assert_eq!(walk.by_ref().count(), 0);
2917+
2918+ let mut walk = walk.into_inner().unwrap();
2919+ walk.push_head().unwrap();
2920+ assert_eq!(walk.by_ref().count(), 1);
2921+ }
2922 }
2923diff -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
2926@@ -105,7 +105,7 @@
2927 type Raw = *mut raw::git_signature;
2928 unsafe fn from_raw(raw: *mut raw::git_signature) -> Signature<'a> {
2929 Signature {
2930- raw: raw,
2931+ raw,
2932 _marker: marker::PhantomData,
2933 owned: true,
2934 }
2935diff -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
2938@@ -72,7 +72,7 @@
2939 let r = raw::git_status_init_options(&mut raw, raw::GIT_STATUS_OPTIONS_VERSION);
2940 assert_eq!(r, 0);
2941 StatusOptions {
2942- raw: raw,
2943+ raw,
2944 pathspec: Vec::new(),
2945 ptrs: Vec::new(),
2946 }
2947@@ -264,7 +264,7 @@
2948 type Raw = *mut raw::git_status_list;
2949 unsafe fn from_raw(raw: *mut raw::git_status_list) -> Statuses<'repo> {
2950 Statuses {
2951- raw: raw,
2952+ raw,
2953 _marker: marker::PhantomData,
2954 }
2955 }
2956@@ -340,7 +340,7 @@
2957
2958 unsafe fn from_raw(raw: *const raw::git_status_entry) -> StatusEntry<'statuses> {
2959 StatusEntry {
2960- raw: raw,
2961+ raw,
2962 _marker: marker::PhantomData,
2963 }
2964 }
2965diff -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
2968@@ -79,7 +79,7 @@
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 }
2974 }
2975 fn raw(&self) -> raw::git_strarray {
2976 self.raw
2977diff -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
2980@@ -5,8 +5,8 @@
2981 use std::ptr;
2982 use std::str;
2983
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};
2988
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)) }
2992 }
2993
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) })
2997+ }
2998+
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) })
3002+ }
3003+
3004 /// Copy submodule info into ".git/config" file.
3005 ///
3006 /// Just like "git submodule init", this copies information about the
3007@@ -223,7 +233,7 @@
3008 type Raw = *mut raw::git_submodule;
3009 unsafe fn from_raw(raw: *mut raw::git_submodule) -> Submodule<'repo> {
3010 Submodule {
3011- raw: raw,
3012+ raw,
3013 _marker: marker::PhantomData,
3014 }
3015 }
3016diff -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
3019@@ -86,7 +86,7 @@
3020 unsafe { Binding::from_raw(raw::git_tag_target_id(&*self.raw)) }
3021 }
3022
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)) }
3027 }
3028@@ -118,7 +118,7 @@
3029 type Raw = *mut raw::git_tag;
3030 unsafe fn from_raw(raw: *mut raw::git_tag) -> Tag<'repo> {
3031 Tag {
3032- raw: raw,
3033+ raw,
3034 _marker: marker::PhantomData,
3035 }
3036 }
3037diff -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
3040@@ -61,7 +61,7 @@
3041 impl Binding for Time {
3042 type Raw = raw::git_time;
3043 unsafe fn from_raw(raw: raw::git_time) -> Time {
3044- Time { raw: raw }
3045+ Time { raw }
3046 }
3047 fn raw(&self) -> raw::git_time {
3048 self.raw
3049@@ -73,8 +73,8 @@
3050 pub fn new(seconds: i32, nanoseconds: u32) -> IndexTime {
3051 unsafe {
3052 Binding::from_raw(raw::git_index_time {
3053- seconds: seconds,
3054- nanoseconds: nanoseconds,
3055+ seconds,
3056+ nanoseconds,
3057 })
3058 }
3059 }
3060@@ -92,7 +92,7 @@
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 }
3065+ IndexTime { raw }
3066 }
3067 fn raw(&self) -> raw::git_index_time {
3068 self.raw
3069diff -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
3072@@ -0,0 +1,82 @@
3073+use std::sync::atomic::{AtomicUsize, Ordering};
3074+
3075+use libc::c_char;
3076+
3077+use crate::{panic, raw, util::Binding};
3078+
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.
3084+ None,
3085+
3086+ /// Severe errors that may impact the program's execution
3087+ Fatal,
3088+
3089+ /// Errors that do not impact the program's execution
3090+ Error,
3091+
3092+ /// Warnings that suggest abnormal data
3093+ Warn,
3094+
3095+ /// Informational messages about program execution
3096+ Info,
3097+
3098+ /// Detailed data that allows for debugging
3099+ Debug,
3100+
3101+ /// Exceptionally detailed debugging data
3102+ Trace,
3103+}
3104+
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 {
3108+ match raw {
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"),
3117+ }
3118+ }
3119+ fn raw(&self) -> raw::git_trace_level_t {
3120+ match *self {
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,
3128+ }
3129+ }
3130+}
3131+
3132+pub type TracingCb = fn(TraceLevel, &str);
3133+
3134+static CALLBACK: AtomicUsize = AtomicUsize::new(0);
3135+
3136+///
3137+pub fn trace_set(level: TraceLevel, cb: TracingCb) -> bool {
3138+ CALLBACK.store(cb as usize, Ordering::SeqCst);
3139+
3140+ unsafe {
3141+ raw::git_trace_set(level.raw(), Some(tracing_cb_c));
3142+ }
3143+
3144+ return true;
3145+}
3146+
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);
3153+ });
3154+}
3155diff -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
3158@@ -0,0 +1,285 @@
3159+use std::ffi::CString;
3160+use std::marker;
3161+
3162+use crate::{raw, util::Binding, Error, Oid, Reflog, Repository, Signature};
3163+
3164+/// A structure representing a transactional update of a repository's references.
3165+///
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>,
3173+}
3174+
3175+impl Drop for Transaction<'_> {
3176+ fn drop(&mut self) {
3177+ unsafe { raw::git_transaction_free(self.raw) }
3178+ }
3179+}
3180+
3181+impl<'repo> Binding for Transaction<'repo> {
3182+ type Raw = *mut raw::git_transaction;
3183+
3184+ unsafe fn from_raw(ptr: *mut raw::git_transaction) -> Transaction<'repo> {
3185+ Transaction {
3186+ raw: ptr,
3187+ _marker: marker::PhantomData,
3188+ }
3189+ }
3190+
3191+ fn raw(&self) -> *mut raw::git_transaction {
3192+ self.raw
3193+ }
3194+}
3195+
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();
3200+ unsafe {
3201+ try_call!(raw::git_transaction_lock_ref(self.raw, refname));
3202+ }
3203+
3204+ Ok(())
3205+ }
3206+
3207+ /// Set the target of the specified reference.
3208+ ///
3209+ /// The reference must have been locked via `lock_ref`.
3210+ ///
3211+ /// If `reflog_signature` is `None`, the [`Signature`] is read from the
3212+ /// repository config.
3213+ pub fn set_target(
3214+ &mut self,
3215+ refname: &str,
3216+ target: Oid,
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();
3222+ unsafe {
3223+ try_call!(raw::git_transaction_set_target(
3224+ self.raw,
3225+ refname,
3226+ target.raw(),
3227+ reflog_signature.map(|s| s.raw()),
3228+ reflog_message
3229+ ));
3230+ }
3231+
3232+ Ok(())
3233+ }
3234+
3235+ /// Set the target of the specified symbolic reference.
3236+ ///
3237+ /// The reference must have been locked via `lock_ref`.
3238+ ///
3239+ /// If `reflog_signature` is `None`, the [`Signature`] is read from the
3240+ /// repository config.
3241+ pub fn set_symbolic_target(
3242+ &mut self,
3243+ refname: &str,
3244+ target: &str,
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();
3251+ unsafe {
3252+ try_call!(raw::git_transaction_set_symbolic_target(
3253+ self.raw,
3254+ refname,
3255+ target,
3256+ reflog_signature.map(|s| s.raw()),
3257+ reflog_message
3258+ ));
3259+ }
3260+
3261+ Ok(())
3262+ }
3263+
3264+ /// Add a [`Reflog`] to the transaction.
3265+ ///
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.
3269+ ///
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();
3275+ unsafe {
3276+ try_call!(raw::git_transaction_set_reflog(
3277+ self.raw,
3278+ refname,
3279+ reflog.raw()
3280+ ));
3281+ }
3282+
3283+ Ok(())
3284+ }
3285+
3286+ /// Remove a reference.
3287+ ///
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();
3291+ unsafe {
3292+ try_call!(raw::git_transaction_remove(self.raw, refname));
3293+ }
3294+
3295+ Ok(())
3296+ }
3297+
3298+ /// Commit the changes from the transaction.
3299+ ///
3300+ /// The updates will be made one by one, and the first failure will stop the
3301+ /// processing.
3302+ pub fn commit(self) -> Result<(), Error> {
3303+ unsafe {
3304+ try_call!(raw::git_transaction_commit(self.raw));
3305+ }
3306+ Ok(())
3307+ }
3308+}
3309+
3310+#[cfg(test)]
3311+mod tests {
3312+ use crate::{Error, ErrorClass, ErrorCode, Oid, Repository};
3313+
3314+ #[test]
3315+ fn smoke() {
3316+ let (_td, repo) = crate::test::repo_init();
3317+
3318+ let mut tx = t!(repo.transaction());
3319+
3320+ t!(tx.lock_ref("refs/heads/main"));
3321+ t!(tx.lock_ref("refs/heads/next"));
3322+
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",
3327+ None,
3328+ "set next to main",
3329+ ));
3330+
3331+ t!(tx.commit());
3332+
3333+ assert_eq!(repo.refname_to_id("refs/heads/main").unwrap(), Oid::zero());
3334+ assert_eq!(
3335+ repo.find_reference("refs/heads/next")
3336+ .unwrap()
3337+ .symbolic_target()
3338+ .unwrap(),
3339+ "refs/heads/main"
3340+ );
3341+ }
3342+
3343+ #[test]
3344+ fn locks_same_repo_handle() {
3345+ let (_td, repo) = crate::test::repo_init();
3346+
3347+ let mut tx1 = t!(repo.transaction());
3348+ t!(tx1.lock_ref("refs/heads/seen"));
3349+
3350+ let mut tx2 = t!(repo.transaction());
3351+ assert!(matches!(tx2.lock_ref("refs/heads/seen"), Err(e) if e.code() == ErrorCode::Locked))
3352+ }
3353+
3354+ #[test]
3355+ fn locks_across_repo_handles() {
3356+ let (td, repo1) = crate::test::repo_init();
3357+ let repo2 = t!(Repository::open(&td));
3358+
3359+ let mut tx1 = t!(repo1.transaction());
3360+ t!(tx1.lock_ref("refs/heads/seen"));
3361+
3362+ let mut tx2 = t!(repo2.transaction());
3363+ assert!(matches!(tx2.lock_ref("refs/heads/seen"), Err(e) if e.code() == ErrorCode::Locked))
3364+ }
3365+
3366+ #[test]
3367+ fn drop_unlocks() {
3368+ let (_td, repo) = crate::test::repo_init();
3369+
3370+ let mut tx = t!(repo.transaction());
3371+ t!(tx.lock_ref("refs/heads/seen"));
3372+ drop(tx);
3373+
3374+ let mut tx2 = t!(repo.transaction());
3375+ t!(tx2.lock_ref("refs/heads/seen"))
3376+ }
3377+
3378+ #[test]
3379+ fn commit_unlocks() {
3380+ let (_td, repo) = crate::test::repo_init();
3381+
3382+ let mut tx = t!(repo.transaction());
3383+ t!(tx.lock_ref("refs/heads/seen"));
3384+ t!(tx.commit());
3385+
3386+ let mut tx2 = t!(repo.transaction());
3387+ t!(tx2.lock_ref("refs/heads/seen"));
3388+ }
3389+
3390+ #[test]
3391+ fn prevents_non_transactional_updates() {
3392+ let (_td, repo) = crate::test::repo_init();
3393+ let head = t!(repo.refname_to_id("HEAD"));
3394+
3395+ let mut tx = t!(repo.transaction());
3396+ t!(tx.lock_ref("refs/heads/seen"));
3397+
3398+ assert!(matches!(
3399+ repo.reference("refs/heads/seen", head, true, "competing with lock"),
3400+ Err(e) if e.code() == ErrorCode::Locked
3401+ ));
3402+ }
3403+
3404+ #[test]
3405+ fn remove() {
3406+ let (_td, repo) = crate::test::repo_init();
3407+ let head = t!(repo.refname_to_id("HEAD"));
3408+ let next = "refs/heads/next";
3409+
3410+ t!(repo.reference(
3411+ next,
3412+ head,
3413+ true,
3414+ "refs/heads/next@{0}: branch: Created from HEAD"
3415+ ));
3416+
3417+ {
3418+ let mut tx = t!(repo.transaction());
3419+ t!(tx.lock_ref(next));
3420+ t!(tx.remove(next));
3421+ t!(tx.commit());
3422+ }
3423+ assert!(matches!(repo.refname_to_id(next), Err(e) if e.code() == ErrorCode::NotFound))
3424+ }
3425+
3426+ #[test]
3427+ fn must_lock_ref() {
3428+ let (_td, repo) = crate::test::repo_init();
3429+
3430+ // 🤷
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"
3435+ }
3436+
3437+ let mut tx = t!(repo.transaction());
3438+ assert!(matches!(
3439+ tx.set_target("refs/heads/main", Oid::zero(), None, "set main to zero"),
3440+ Err(e) if is_not_locked_err(&e)
3441+ ))
3442+ }
3443+}
3444diff -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
3447@@ -54,7 +54,7 @@
3448 }
3449
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)]
3454 pub enum Service {
3455 UploadPackLs,
3456@@ -87,6 +87,8 @@
3457 #[repr(C)]
3458 struct RawSmartSubtransport {
3459 raw: raw::git_smart_subtransport,
3460+ stream: Option<*mut raw::git_smart_subtransport_stream>,
3461+ rpc: bool,
3462 obj: Box<dyn SmartSubtransport>,
3463 }
3464
3465@@ -142,6 +144,8 @@
3466 close: Some(subtransport_close),
3467 free: Some(subtransport_free),
3468 },
3469+ stream: None,
3470+ rpc,
3471 obj: Box::new(subtransport),
3472 });
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),
3477 };
3478- let transport = &mut *(raw_transport as *mut RawSmartSubtransport);
3479- let obj = match transport.obj.action(url, action) {
3480- Ok(s) => s,
3481- Err(e) => {
3482- set_err(&e);
3483- return e.raw_code() as c_int;
3484+
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) {
3492+ Ok(s) => s,
3493+ Err(e) => {
3494+ set_err(&e);
3495+ return e.raw_code() as c_int;
3496+ }
3497+ };
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),
3504+ },
3505+ obj,
3506+ }));
3507+ transport.stream = Some(*stream);
3508+ } else {
3509+ if transport.stream.is_none() {
3510+ return -1;
3511 }
3512- };
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),
3519- },
3520- obj: obj,
3521- }));
3522+ *stream = transport.stream.unwrap();
3523+ }
3524 0
3525 })
3526 .unwrap_or(-1)
3527diff -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
3530@@ -141,7 +141,7 @@
3531
3532 unsafe fn from_raw(raw: *mut raw::git_treebuilder) -> TreeBuilder<'repo> {
3533 TreeBuilder {
3534- raw: raw,
3535+ raw,
3536 _marker: marker::PhantomData,
3537 }
3538 }
3539diff -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
3542@@ -225,7 +225,7 @@
3543
3544 unsafe fn from_raw(raw: *mut raw::git_tree) -> Tree<'repo> {
3545 Tree {
3546- raw: raw,
3547+ raw,
3548 _marker: marker::PhantomData,
3549 }
3550 }
3551@@ -334,7 +334,7 @@
3552 type Raw = *mut raw::git_tree_entry;
3553 unsafe fn from_raw(raw: *mut raw::git_tree_entry) -> TreeEntry<'a> {
3554 TreeEntry {
3555- raw: raw,
3556+ raw,
3557 owned: true,
3558 _marker: marker::PhantomData,
3559 }
3560diff -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
3563@@ -0,0 +1,95 @@
3564+use crate::raw;
3565+use libc::c_int;
3566+use std::fmt;
3567+
3568+/// Version information about libgit2 and the capabilities it supports.
3569+pub struct Version {
3570+ major: c_int,
3571+ minor: c_int,
3572+ rev: c_int,
3573+ features: c_int,
3574+}
3575+
3576+macro_rules! flag_test {
3577+ ($features:expr, $flag:expr) => {
3578+ ($features as u32 & $flag as u32) != 0
3579+ };
3580+}
3581+
3582+impl Version {
3583+ /// Returns a [`Version`] which provides information about libgit2.
3584+ pub fn get() -> Version {
3585+ let mut v = Version {
3586+ major: 0,
3587+ minor: 0,
3588+ rev: 0,
3589+ features: 0,
3590+ };
3591+ unsafe {
3592+ raw::git_libgit2_version(&mut v.major, &mut v.minor, &mut v.rev);
3593+ v.features = raw::git_libgit2_features();
3594+ }
3595+ v
3596+ }
3597+
3598+ /// Returns the version of libgit2.
3599+ ///
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)
3603+ }
3604+
3605+ /// Returns the version of the libgit2-sys crate.
3606+ pub fn crate_version(&self) -> &'static str {
3607+ env!("CARGO_PKG_VERSION")
3608+ }
3609+
3610+ /// Returns true if this was built with the vendored version of libgit2.
3611+ pub fn vendored(&self) -> bool {
3612+ raw::vendored()
3613+ }
3614+
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)
3619+ }
3620+
3621+ /// Returns true if libgit2 was built with and linked against a TLS implementation.
3622+ ///
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)
3627+ }
3628+
3629+ /// Returns true if libgit2 was built with and linked against libssh2.
3630+ ///
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)
3635+ }
3636+
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)
3641+ }
3642+}
3643+
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());
3656+ f.finish()
3657+ }
3658+}
3659diff -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
3662@@ -7,10 +7,12 @@
3663 fn main() {
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();
3668
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 {
3676@@ -20,6 +22,8 @@
3677 }
3678 }
3679
3680+ println!("cargo:rustc-cfg=libgit2_vendored");
3681+
3682 if !Path::new("libgit2/.git").exists() {
3683 let _ = Command::new("git")
3684 .args(&["submodule", "update", "--init", "libgit2"])
3685@@ -107,6 +111,7 @@
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");
3690
3691 if !target.contains("android") {
3692 features.push_str("#define GIT_USE_NSEC 1\n");
3693diff -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
3696@@ -13,7 +13,7 @@
3697 [package]
3698 edition = "2018"
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>"]
3703 build = "build.rs"
3704 links = "git2"
3705diff -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
3708@@ -89,6 +89,8 @@
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 {}
3714
3715 #[repr(C)]
3716 pub struct git_revspec {
3717@@ -351,6 +353,8 @@
3718 )]
3719 pub type git_transfer_progress = git_indexer_progress;
3720
3721+pub type git_remote_ready_cb = Option<extern "C" fn(*mut git_remote, c_int, *mut c_void) -> c_int>;
3722+
3723 #[repr(C)]
3724 pub struct git_remote_callbacks {
3725 pub version: c_uint,
3726@@ -366,6 +370,7 @@
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,
3733 }
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;
3744
3745 #[repr(C)]
3746+pub struct git_diff_patchid_options {
3747+ pub version: c_uint,
3748+}
3749+
3750+pub const GIT_DIFF_PATCHID_OPTIONS_VERSION: c_uint = 1;
3751+
3752+#[repr(C)]
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 @@
3757 ) -> c_int,
3758 >,
3759
3760+ pub writemidx: Option<extern "C" fn(*mut git_odb_backend) -> c_int>,
3761+
3762 pub freshen: Option<extern "C" fn(*mut git_odb_backend, *const git_oid) -> c_int>,
3763
3764 pub free: Option<extern "C" fn(*mut git_odb_backend)>,
3765@@ -1736,6 +1751,20 @@
3766 ) -> c_int,
3767 >;
3768
3769+pub type git_commit_create_cb = Option<
3770+ extern "C" fn(
3771+ *mut git_oid,
3772+ *const git_signature,
3773+ *const git_signature,
3774+ *const c_char,
3775+ *const c_char,
3776+ *const git_tree,
3777+ usize,
3778+ *const git_commit,
3779+ *mut c_void,
3780+ ) -> c_int,
3781+>;
3782+
3783 pub const GIT_REBASE_NO_OPERATION: usize = usize::max_value();
3784
3785 #[repr(C)]
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,
3793 }
3794@@ -1880,6 +1910,63 @@
3795
3796 pub const GIT_WORKTREE_PRUNE_OPTIONS_VERSION: c_uint = 1;
3797
3798+pub type git_repository_mergehead_foreach_cb =
3799+ Option<extern "C" fn(oid: *const git_oid, payload: *mut c_void) -> c_int>;
3800+
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,
3803+>;
3804+
3805+git_enum! {
3806+ pub enum git_trace_level_t {
3807+ /* No tracing will be performed. */
3808+ GIT_TRACE_NONE = 0,
3809+
3810+ /* Severe errors that may impact the program's execution */
3811+ GIT_TRACE_FATAL = 1,
3812+
3813+ /* Errors that do not impact the program's execution */
3814+ GIT_TRACE_ERROR = 2,
3815+
3816+ /* Warnings that suggest abnormal data */
3817+ GIT_TRACE_WARN = 3,
3818+
3819+ /* Informational messages about program execution */
3820+ GIT_TRACE_INFO = 4,
3821+
3822+ /* Detailed data that allows for debugging */
3823+ GIT_TRACE_DEBUG = 5,
3824+
3825+ /* Exceptionally detailed debugging data */
3826+ GIT_TRACE_TRACE = 6,
3827+ }
3828+}
3829+
3830+pub type git_trace_cb = Option<extern "C" fn(level: git_trace_level_t, msg: *const c_char)>;
3831+
3832+git_enum! {
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,
3838+ }
3839+}
3840+
3841+#[repr(C)]
3842+pub struct git_message_trailer {
3843+ pub key: *const c_char,
3844+ pub value: *const c_char,
3845+}
3846+
3847+#[repr(C)]
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,
3853+}
3854+
3855 extern "C" {
3856 // threads
3857 pub fn git_libgit2_init() -> c_int;
3858@@ -1972,6 +2059,16 @@
3859 repo: *mut git_repository,
3860 recurse_submodules: c_int,
3861 ) -> 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,
3866+ ) -> c_int;
3867+ pub fn git_repository_fetchhead_foreach(
3868+ repo: *mut git_repository,
3869+ callback: git_repository_fetchhead_foreach_cb,
3870+ payload: *mut c_void,
3871+ ) -> c_int;
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 @@
3876 ) -> c_int;
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 @@
3884
3885 // commit
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,
3891+ ) -> c_int;
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,
3897+ ) -> c_int;
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 @@
3902 force: c_int,
3903 ) -> c_int;
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(
3907 out: *mut git_buf,
3908 repo: *mut git_repository,
3909@@ -3434,6 +3543,16 @@
3910 version: c_uint,
3911 ) -> c_int;
3912
3913+ pub fn git_diff_patchid(
3914+ out: *mut git_oid,
3915+ diff: *mut git_diff,
3916+ opts: *mut git_diff_patchid_options,
3917+ ) -> c_int;
3918+ pub fn git_diff_patchid_options_init(
3919+ opts: *mut git_diff_patchid_options,
3920+ version: c_uint,
3921+ ) -> c_int;
3922+
3923 // patch
3924 pub fn git_patch_from_diff(out: *mut *mut git_patch, diff: *mut git_diff, idx: size_t)
3925 -> c_int;
3926@@ -3573,6 +3692,13 @@
3927 comment_char: c_char,
3928 ) -> c_int;
3929
3930+ pub fn git_message_trailers(
3931+ out: *mut git_message_trailer_array,
3932+ message: *const c_char,
3933+ ) -> c_int;
3934+
3935+ pub fn git_message_trailer_array_free(trailer: *mut git_message_trailer_array);
3936+
3937 // packbuilder
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,
3942 ) -> c_int;
3943
3944+ // Common
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;
3948
3949 // Worktrees
3950@@ -3896,6 +4025,59 @@
3951 wt: *mut git_worktree,
3952 opts: *mut git_worktree_prune_options,
3953 ) -> c_int;
3954+
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,
3964+ ) -> c_int;
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,
3971+ ) -> c_int;
3972+ pub fn git_transaction_set_reflog(
3973+ tx: *mut git_transaction,
3974+ refname: *const c_char,
3975+ reflog: *const git_reflog,
3976+ ) -> c_int;
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);
3980+
3981+ // Mailmap
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,
3986+ len: size_t,
3987+ ) -> c_int;
3988+ pub fn git_mailmap_from_repository(
3989+ out: *mut *mut git_mailmap,
3990+ repo: *mut git_repository,
3991+ ) -> c_int;
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,
3997+ ) -> c_int;
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,
4004+ ) -> c_int;
4005+
4006+ pub fn git_trace_set(level: git_trace_level_t, cb: git_trace_cb) -> c_int;
4007 }
4008
4009 pub fn init() {
4010@@ -3944,3 +4126,8 @@
4011
4012 #[cfg(not(feature = "ssh"))]
4013 fn ssh_init() {}
4014+
4015+#[doc(hidden)]
4016+pub fn vendored() -> bool {
4017+ cfg!(libgit2_vendored)
4018+}
This page took 0.501575 seconds and 4 git commands to generate.