Skip to content

Commit 7bba270

Browse files
committed
Merge branch 'adjustments-for-cargo'
2 parents 961264e + ea76bf5 commit 7bba270

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+5106
-1613
lines changed

git-config/tests/file/init/from_paths/includes/conditional/onbranch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ value = branch-override-by-include
287287
git::lock::acquire::Fail::Immediately,
288288
git::lock::acquire::Fail::Immediately,
289289
)?
290-
.commit(repo.committer().expect("pre-configured"))?;
290+
.commit(repo.committer().transpose()?)?;
291291

292292
let dir = assure_git_agrees(expect, dir)?;
293293
Ok(GitEnv { repo, dir })

git-date/src/parse.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
#[derive(thiserror::Error, Debug)]
1+
#[derive(thiserror::Error, Debug, Clone)]
22
#[allow(missing_docs)]
33
pub enum Error {
44
#[error("Cannot represent times before UNIX epoch at timestamp {timestamp}")]
55
TooEarly { timestamp: i64 },
66
#[error("Could not convert a duration into a date")]
77
RelativeTimeConversion,
88
#[error("Date string can not be parsed")]
9-
InvalidDateString,
9+
InvalidDateString { input: String },
1010
#[error("Dates past 2038 can not be represented.")]
1111
InvalidDate(#[from] std::num::TryFromIntError),
12-
#[error("Current time is missing.")]
12+
#[error("Current time is missing but required to handle relative dates.")]
1313
MissingCurrentTime,
1414
}
1515

@@ -56,7 +56,7 @@ pub(crate) mod function {
5656
} else if let Some(time) = relative::parse(input, now).transpose()? {
5757
Time::new(timestamp(time)?, time.offset().whole_seconds())
5858
} else {
59-
return Err(Error::InvalidDateString);
59+
return Err(Error::InvalidDateString { input: input.into() });
6060
})
6161
}
6262

git-date/tests/time/parse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn git_default() {
118118
fn invalid_dates_can_be_produced_without_current_time() {
119119
assert!(matches!(
120120
git_date::parse("foobar", None).unwrap_err(),
121-
git_date::parse::Error::InvalidDateString
121+
git_date::parse::Error::InvalidDateString { input } if input == "foobar"
122122
));
123123
}
124124

git-features/src/progress.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::io;
33

44
pub use prodash::{
55
messages::MessageLevel,
6+
progress::Id,
67
progress::{Discard, DoOrDiscard, Either, Step, StepShared, ThroughputOnDrop, UNKNOWN},
78
unit, Progress, Unit,
89
};

git-odb/src/store_impls/dynamic/verify.rs

+36-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::{
1414

1515
///
1616
pub mod integrity {
17+
use std::marker::PhantomData;
1718
use std::path::PathBuf;
1819

1920
use crate::pack;
@@ -81,6 +82,29 @@ pub mod integrity {
8182
/// The provided progress instance.
8283
pub progress: P,
8384
}
85+
86+
/// The progress ids used in [`Store::verify_integrity()`][crate::Store::verify_integrity()].
87+
///
88+
/// Use this information to selectively extract the progress of interest in case the parent application has custom visualization.
89+
#[derive(Debug, Copy, Clone)]
90+
pub enum ProgressId {
91+
/// Contains the path of the currently validated loose object database.
92+
VerifyLooseObjectDbPath,
93+
/// The root progress for all verification of an index. It doesn't contain any useful information itself.
94+
VerifyIndex(PhantomData<git_pack::index::verify::integrity::ProgressId>),
95+
/// The root progress for all verification of a multi-index. It doesn't contain any useful information itself.
96+
VerifyMultiIndex(PhantomData<git_pack::multi_index::verify::integrity::ProgressId>),
97+
}
98+
99+
impl From<ProgressId> for git_features::progress::Id {
100+
fn from(v: ProgressId) -> Self {
101+
match v {
102+
ProgressId::VerifyLooseObjectDbPath => *b"VISP",
103+
ProgressId::VerifyMultiIndex(_) => *b"VIMI",
104+
ProgressId::VerifyIndex(_) => *b"VISI",
105+
}
106+
}
107+
}
84108
}
85109

86110
impl super::Store {
@@ -154,7 +178,10 @@ impl super::Store {
154178
data,
155179
options: options.clone(),
156180
}),
157-
progress.add_child_with_id("never shown", git_features::progress::UNKNOWN),
181+
progress.add_child_with_id(
182+
"verify index",
183+
integrity::ProgressId::VerifyIndex(Default::default()).into(),
184+
),
158185
should_interrupt,
159186
)?;
160187
statistics.push(IndexStatistics {
@@ -177,7 +204,10 @@ impl super::Store {
177204
}
178205
};
179206
let outcome = index.verify_integrity(
180-
progress.add_child_with_id("never shown", git_features::progress::UNKNOWN),
207+
progress.add_child_with_id(
208+
"verify multi-index",
209+
integrity::ProgressId::VerifyMultiIndex(Default::default()).into(),
210+
),
181211
should_interrupt,
182212
options.clone(),
183213
)?;
@@ -216,7 +246,10 @@ impl super::Store {
216246
for loose_db in &*index.loose_dbs {
217247
let out = loose_db
218248
.verify_integrity(
219-
progress.add_child_with_id(loose_db.path().display().to_string(), *b"VISP"), /* Verify Integrity Store Path */
249+
progress.add_child_with_id(
250+
loose_db.path().display().to_string(),
251+
integrity::ProgressId::VerifyLooseObjectDbPath.into(),
252+
),
220253
should_interrupt,
221254
)
222255
.map(|statistics| integrity::LooseObjectStatistics {

git-odb/src/store_impls/loose/verify.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ pub mod integrity {
3838
/// The amount of loose objects we checked.
3939
pub num_objects: usize,
4040
}
41+
42+
/// The progress ids used in [`verify_integrity()`][super::Store::verify_integrity()].
43+
///
44+
/// Use this information to selectively extract the progress of interest in case the parent application has custom visualization.
45+
#[derive(Debug, Copy, Clone)]
46+
pub enum ProgressId {
47+
/// The amount of loose objects that have been verified.
48+
LooseObjects,
49+
}
50+
51+
impl From<ProgressId> for git_features::progress::Id {
52+
fn from(v: ProgressId) -> Self {
53+
match v {
54+
ProgressId::LooseObjects => *b"VILO",
55+
}
56+
}
57+
}
4158
}
4259

4360
impl Store {
@@ -52,7 +69,7 @@ impl Store {
5269

5370
let mut num_objects = 0;
5471
let start = Instant::now();
55-
let mut progress = progress.add_child_with_id("Validating", *b"VILO"); /* Verify Integrity Loose Objects */
72+
let mut progress = progress.add_child_with_id("Validating", integrity::ProgressId::LooseObjects.into());
5673
progress.init(None, git_features::progress::count("loose objects"));
5774
for id in self.iter().filter_map(Result::ok) {
5875
let object = self

git-pack/src/bundle/write/mod.rs

+29-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::marker::PhantomData;
12
use std::{
23
io,
34
io::Write,
@@ -23,6 +24,28 @@ type ThinPackLookupFn = Box<dyn for<'a> FnMut(git_hash::ObjectId, &'a mut Vec<u8
2324
type ThinPackLookupFnSend =
2425
Box<dyn for<'a> FnMut(git_hash::ObjectId, &'a mut Vec<u8>) -> Option<git_object::Data<'a>> + Send + 'static>;
2526

27+
/// The progress ids used in [`write_to_directory()`][crate::Bundle::write_to_directory()].
28+
///
29+
/// Use this information to selectively extract the progress of interest in case the parent application has custom visualization.
30+
#[derive(Debug, Copy, Clone)]
31+
pub enum ProgressId {
32+
/// The amount of bytes read from the input pack data file.
33+
ReadPackBytes,
34+
/// A root progress counting logical steps towards an index file on disk.
35+
///
36+
/// Underneath will be more progress information related to actually producing the index.
37+
IndexingSteps(PhantomData<crate::index::write::ProgressId>),
38+
}
39+
40+
impl From<ProgressId> for git_features::progress::Id {
41+
fn from(v: ProgressId) -> Self {
42+
match v {
43+
ProgressId::ReadPackBytes => *b"BWRB",
44+
ProgressId::IndexingSteps(_) => *b"BWCI",
45+
}
46+
}
47+
}
48+
2649
impl crate::Bundle {
2750
/// Given a `pack` data stream, write it along with a generated index into the `directory` if `Some` or discard all output if `None`.
2851
///
@@ -50,7 +73,7 @@ impl crate::Bundle {
5073
where
5174
P: Progress,
5275
{
53-
let mut read_progress = progress.add_child_with_id("read pack", *b"BWRB"); /* Bundle Write Read pack Bytes*/
76+
let mut read_progress = progress.add_child_with_id("read pack", ProgressId::ReadPackBytes.into());
5477
read_progress.init(None, progress::bytes());
5578
let pack = progress::Read {
5679
inner: pack,
@@ -163,7 +186,7 @@ impl crate::Bundle {
163186
P: Progress,
164187
P::SubProgress: 'static,
165188
{
166-
let mut read_progress = progress.add_child_with_id("read pack", *b"BWRB"); /* Bundle Write Read pack Bytes*/
189+
let mut read_progress = progress.add_child_with_id("read pack", ProgressId::ReadPackBytes.into()); /* Bundle Write Read pack Bytes*/
167190
read_progress.init(pack_size.map(|s| s as usize), progress::bytes());
168191
let pack = progress::Read {
169192
inner: pack,
@@ -260,7 +283,10 @@ impl crate::Bundle {
260283
should_interrupt: &AtomicBool,
261284
pack_version: data::Version,
262285
) -> Result<WriteOutcome, Error> {
263-
let indexing_progress = progress.add_child_with_id("create index file", *b"BWCI"); /* Bundle Write Create Index */
286+
let indexing_progress = progress.add_child_with_id(
287+
"create index file",
288+
ProgressId::IndexingSteps(Default::default()).into(),
289+
);
264290
Ok(match directory {
265291
Some(directory) => {
266292
let directory = directory.as_ref();

0 commit comments

Comments
 (0)