Unified · Split
| @@ -82,7 +82,7 @@ mod ignore { · 81 unmodified lines | |||
| 82 | ); | 82 | ); |
| 83 | } | 83 | } |
| 84 | (None, None) => {} | 84 | (None, None) => {} |
| 85 | (actual, expected) => panic!("actual {:?} should match {:?} with path '{}'", actual, expected, path), | 85 | (actual, expected) => panic!("actual {actual:?} should match {expected:?} with path '{path}'"), |
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | Ok(()) | 88 | Ok(()) |
| @@ -275,7 +275,7 @@ fn unspecified(attr: &str) -> (BString, StateRef) { · 274 unmodified lines | |||
| 275 | (attr.into(), StateRef::Unspecified) | 275 | (attr.into(), StateRef::Unspecified) |
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | fn value<'a, 'b>(attr: &'a str, value: &'b str) -> (BString, StateRef<'b>) { | 278 | fn value<'b>(attr: &str, value: &'b str) -> (BString, StateRef<'b>) { |
| 279 | (attr.into(), StateRef::Value(value.as_bytes().as_bstr())) | 279 | (attr.into(), StateRef::Value(value.as_bytes().as_bstr())) |
| 280 | } | 280 | } |
| 281 | 281 | ||
| @@ -148,7 +148,7 @@ impl TryFrom<&Path> for File { · 147 unmodified lines | |||
| 148 | if chunk_size % entry_size != 0 { | 148 | if chunk_size % entry_size != 0 { |
| 149 | return Err(Error::InvalidChunkSize { | 149 | return Err(Error::InvalidChunkSize { |
| 150 | id: COMMIT_DATA_CHUNK_ID, | 150 | id: COMMIT_DATA_CHUNK_ID, |
| 151 | msg: format!("chunk size {} is not a multiple of {}", chunk_size, entry_size), | 151 | msg: format!("chunk size {chunk_size} is not a multiple of {entry_size}"), |
| 152 | }); | 152 | }); |
| 153 | } | 153 | } |
| 154 | Ok(( | 154 | Ok(( |
| @@ -166,7 +166,7 @@ impl TryFrom<&Path> for File { · 11 unmodified lines | |||
| 166 | if chunk_size != expected_size { | 166 | if chunk_size != expected_size { |
| 167 | return Err(Error::InvalidChunkSize { | 167 | return Err(Error::InvalidChunkSize { |
| 168 | id: OID_FAN_CHUNK_ID, | 168 | id: OID_FAN_CHUNK_ID, |
| 169 | msg: format!("expected chunk length {}, got {}", expected_size, chunk_size), | 169 | msg: format!("expected chunk length {expected_size}, got {chunk_size}"), |
| 170 | }); | 170 | }); |
| 171 | } | 171 | } |
| 172 | Ok(chunk_range.start) | 172 | Ok(chunk_range.start) |
| @@ -62,7 +62,7 @@ impl Graph { · 61 unmodified lines | |||
| 62 | err: e, | 62 | err: e, |
| 63 | path: chain_file_path.clone(), | 63 | path: chain_file_path.clone(), |
| 64 | })?; | 64 | })?; |
| 65 | let graph_file_path = commit_graphs_dir.join(format!("graph-{}.graph", hash)); | 65 | let graph_file_path = commit_graphs_dir.join(format!("graph-{hash}.graph")); |
| 66 | files.push(File::at(&graph_file_path).map_err(|e| Error::File { | 66 | files.push(File::at(&graph_file_path).map_err(|e| Error::File { |
| 67 | err: e, | 67 | err: e, |
| 68 | path: graph_file_path.clone(), | 68 | path: graph_file_path.clone(), |
| @@ -148,7 +148,7 @@ impl Display for Name { · 147 unmodified lines | |||
| 148 | Self::White => write!(f, "white"), | 148 | Self::White => write!(f, "white"), |
| 149 | Self::BrightWhite => write!(f, "brightwhite"), | 149 | Self::BrightWhite => write!(f, "brightwhite"), |
| 150 | Self::Ansi(num) => num.fmt(f), | 150 | Self::Ansi(num) => num.fmt(f), |
| 151 | Self::Rgb(r, g, b) => write!(f, "#{:02x}{:02x}{:02x}", r, g, b), | 151 | Self::Rgb(r, g, b) => write!(f, "#{r:02x}{g:02x}{b:02x}"), |
| 152 | } | 152 | } |
| 153 | } | 153 | } |
| 154 | } | 154 | } |
| @@ -26,7 +26,7 @@ impl Display for Integer { · 25 unmodified lines | |||
| 26 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 26 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 27 | write!(f, "{}", self.value)?; | 27 | write!(f, "{}", self.value)?; |
| 28 | if let Some(suffix) = self.suffix { | 28 | if let Some(suffix) = self.suffix { |
| 29 | write!(f, "{}", suffix) | 29 | write!(f, "{suffix}") |
| 30 | } else { | 30 | } else { |
| 31 | Ok(()) | 31 | Ok(()) |
| 32 | } | 32 | } |
| @@ -56,10 +56,10 @@ impl File<'static> { · 55 unmodified lines | |||
| 56 | let mut config = File::new(meta); | 56 | let mut config = File::new(meta); |
| 57 | for i in 0..count { | 57 | for i in 0..count { |
| 58 | let key = git_path::os_string_into_bstring( | 58 | let key = git_path::os_string_into_bstring( |
| 59 | env::var_os(format!("GIT_CONFIG_KEY_{}", i)).ok_or(Error::InvalidKeyId { key_id: i })?, | 59 | env::var_os(format!("GIT_CONFIG_KEY_{i}")).ok_or(Error::InvalidKeyId { key_id: i })?, |
| 60 | ) | 60 | ) |
| 61 | .map_err(|_| Error::IllformedUtf8 { index: i, kind: "key" })?; | 61 | .map_err(|_| Error::IllformedUtf8 { index: i, kind: "key" })?; |
| 62 | let value = env::var_os(format!("GIT_CONFIG_VALUE_{}", i)).ok_or(Error::InvalidValueId { value_id: i })?; | 62 | let value = env::var_os(format!("GIT_CONFIG_VALUE_{i}")).ok_or(Error::InvalidValueId { value_id: i })?; |
| 63 | let key = parse::key(<_ as AsRef<BStr>>::as_ref(&key)).ok_or_else(|| Error::InvalidKeyValue { | 63 | let key = parse::key(<_ as AsRef<BStr>>::as_ref(&key)).ok_or_else(|| Error::InvalidKeyValue { |
| 64 | key_id: i, | 64 | key_id: i, |
| 65 | key_val: key.to_string(), | 65 | key_val: key.to_string(), |
| @@ -217,9 +217,9 @@ impl<'a, 'event> SectionMut<'a, 'event> { · 216 unmodified lines | |||
| 217 | } | 217 | } |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | pub(crate) fn get<'key>( | 220 | pub(crate) fn get( |
| 221 | &self, | 221 | &self, |
| 222 | key: &Key<'key>, | 222 | key: &Key<'_>, |
| 223 | start: Index, | 223 | start: Index, |
| 224 | end: Index, | 224 | end: Index, |
| 225 | ) -> Result<Cow<'_, BStr>, lookup::existing::Error> { | 225 | ) -> Result<Cow<'_, BStr>, lookup::existing::Error> { |
| @@ -67,7 +67,7 @@ pub(crate) fn ends_with_newline(e: &[crate::parse::Event<'_>], nl: impl AsRef<[u · 66 unmodified lines | |||
| 67 | .unwrap_or(false) | 67 | .unwrap_or(false) |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | pub(crate) fn extract_newline<'a, 'b>(e: &'a Event<'b>) -> Option<&'a BStr> { | 70 | pub(crate) fn extract_newline<'a>(e: &'a Event<'_>) -> Option<&'a BStr> { |
| 71 | match e { | 71 | match e { |
| 72 | Event::Newline(b) => b.as_ref().into(), | 72 | Event::Newline(b) => b.as_ref().into(), |
| 73 | _ => None, | 73 | _ => None, |
| @@ -55,7 +55,7 @@ impl Display for Error { · 54 unmodified lines | |||
| 55 | data_size - 10 | 55 | data_size - 10 |
| 56 | ) | 56 | ) |
| 57 | } | 57 | } |
| 58 | (Ok(data), _) => write!(f, "'{}'", data), | 58 | (Ok(data), _) => write!(f, "'{data}'"), |
| 59 | (Err(_), _) => self.parsed_until.fmt(f), | 59 | (Err(_), _) => self.parsed_until.fmt(f), |
| 60 | } | 60 | } |
| 61 | } | 61 | } |
| @@ -62,7 +62,7 @@ mod mutate { · 61 unmodified lines | |||
| 62 | self.host = url.host().map(ToOwned::to_owned).map(|mut host| { | 62 | self.host = url.host().map(ToOwned::to_owned).map(|mut host| { |
| 63 | if let Some(port) = url.port { | 63 | if let Some(port) = url.port { |
| 64 | use std::fmt::Write; | 64 | use std::fmt::Write; |
| 65 | write!(host, ":{}", port).expect("infallible"); | 65 | write!(host, ":{port}").expect("infallible"); |
| 66 | } | 66 | } |
| 67 | host | 67 | host |
| 68 | }); | 68 | }); |
| @@ -163,7 +163,7 @@ mod invoke { · 162 unmodified lines | |||
| 163 | fn fixtures<'a>(names: impl IntoIterator<Item = &'a str>) -> Vec<Program> { | 163 | fn fixtures<'a>(names: impl IntoIterator<Item = &'a str>) -> Vec<Program> { |
| 164 | names | 164 | names |
| 165 | .into_iter() | 165 | .into_iter() |
| 166 | .map(|name| git_path::realpath(fixture_path(format!("{}.sh", name))).unwrap()) | 166 | .map(|name| git_path::realpath(fixture_path(format!("{name}.sh"))).unwrap()) |
| 167 | .map(|path| { | 167 | .map(|path| { |
| 168 | let mut script = git_path::to_unix_separators_on_windows(git_path::into_bstr(path)).into_owned(); | 168 | let mut script = git_path::to_unix_separators_on_windows(git_path::into_bstr(path)).into_owned(); |
| 169 | script.insert_str(0, "sh "); | 169 | script.insert_str(0, "sh "); |
| @@ -95,21 +95,19 @@ username=bob"; · 94 unmodified lines | |||
| 95 | #[test] | 95 | #[test] |
| 96 | fn quit_supports_git_config_boolean_values() { | 96 | fn quit_supports_git_config_boolean_values() { |
| 97 | for true_value in ["1", "42", "-42", "true", "on", "yes"] { | 97 | for true_value in ["1", "42", "-42", "true", "on", "yes"] { |
| 98 | let input = format!("quit={}", true_value); | 98 | let input = format!("quit={true_value}"); |
| 99 | assert_eq!( | 99 | assert_eq!( |
| 100 | Context::from_bytes(input.as_bytes()).unwrap().quit, | 100 | Context::from_bytes(input.as_bytes()).unwrap().quit, |
| 101 | Some(true), | 101 | Some(true), |
| 102 | "{}", | 102 | "{input}" |
| 103 | input | ||
| 104 | ) | 103 | ) |
| 105 | } | 104 | } |
| 106 | for false_value in ["0", "false", "off", "no"] { | 105 | for false_value in ["0", "false", "off", "no"] { |
| 107 | let input = format!("quit={}", false_value); | 106 | let input = format!("quit={false_value}"); |
| 108 | assert_eq!( | 107 | assert_eq!( |
| 109 | Context::from_bytes(input.as_bytes()).unwrap().quit, | 108 | Context::from_bytes(input.as_bytes()).unwrap().quit, |
| 110 | Some(false), | 109 | Some(false), |
| 111 | "{}", | 110 | "{input}" |
| 112 | input | ||
| 113 | ) | 111 | ) |
| 114 | } | 112 | } |
| 115 | } | 113 | } |
| @@ -126,7 +126,7 @@ mod program { · 125 unmodified lines | |||
| 126 | 126 | ||
| 127 | pub fn script_helper(name: &str) -> Program { | 127 | pub fn script_helper(name: &str) -> Program { |
| 128 | let mut script = git_path::to_unix_separators_on_windows(git_path::into_bstr( | 128 | let mut script = git_path::to_unix_separators_on_windows(git_path::into_bstr( |
| 129 | git_path::realpath(fixture_path(format!("{}.sh", name))).unwrap(), | 129 | git_path::realpath(fixture_path(format!("{name}.sh"))).unwrap(), |
| 130 | )) | 130 | )) |
| 131 | .into_owned(); | 131 | .into_owned(); |
| 132 | script.insert_str(0, "sh "); | 132 | script.insert_str(0, "sh "); |
| @@ -26,7 +26,7 @@ impl Time { · 25 unmodified lines | |||
| 26 | const SECONDS_PER_HOUR: i32 = 60 * 60; | 26 | const SECONDS_PER_HOUR: i32 = 60 * 60; |
| 27 | let offset = self.offset_in_seconds.abs(); | 27 | let offset = self.offset_in_seconds.abs(); |
| 28 | let hours = offset / SECONDS_PER_HOUR; | 28 | let hours = offset / SECONDS_PER_HOUR; |
| 29 | assert!(hours < 25, "offset is more than a day: {}", hours); | 29 | assert!(hours < 25, "offset is more than a day: {hours}"); |
| 30 | let minutes = (offset - (hours * SECONDS_PER_HOUR)) / 60; | 30 | let minutes = (offset - (hours * SECONDS_PER_HOUR)) / 60; |
| 31 | 31 | ||
| 32 | if hours < 10 { | 32 | if hours < 10 { |
| @@ -81,8 +81,7 @@ mod tests { · 80 unmodified lines | |||
| 81 | let actual = std::mem::size_of::<Change>(); | 81 | let actual = std::mem::size_of::<Change>(); |
| 82 | assert!( | 82 | assert!( |
| 83 | actual <= 46, | 83 | actual <= 46, |
| 84 | "{} <= 46: this type shouldn't grow without us knowing", | 84 | "{actual} <= 46: this type shouldn't grow without us knowing" |
| 85 | actual | ||
| 86 | ) | 85 | ) |
| 87 | } | 86 | } |
| 88 | } | 87 | } |
| @@ -25,7 +25,7 @@ mod changes { · 24 unmodified lines | |||
| 25 | ) -> crate::Result<TreeRefIter<'a>> { | 25 | ) -> crate::Result<TreeRefIter<'a>> { |
| 26 | let tree_id = db | 26 | let tree_id = db |
| 27 | .try_find(commit, buf)? | 27 | .try_find(commit, buf)? |
| 28 | .ok_or_else(|| format!("start commit {:?} to be present", commit))? | 28 | .ok_or_else(|| format!("start commit {commit:?} to be present"))? |
| 29 | .0 | 29 | .0 |
| 30 | .decode()? | 30 | .decode()? |
| 31 | .into_commit() | 31 | .into_commit() |
| @@ -66,7 +66,7 @@ mod changes { · 34 unmodified lines | |||
| 66 | let (main_tree_id, parent_commit_id) = { | 66 | let (main_tree_id, parent_commit_id) = { |
| 67 | let commit = db | 67 | let commit = db |
| 68 | .try_find(commit_id, &mut buf)? | 68 | .try_find(commit_id, &mut buf)? |
| 69 | .ok_or_else(|| format!("start commit {:?} to be present", commit_id))? | 69 | .ok_or_else(|| format!("start commit {commit_id:?} to be present"))? |
| 70 | .0 | 70 | .0 |
| 71 | .decode()? | 71 | .decode()? |
| 72 | .into_commit() | 72 | .into_commit() |
| @@ -138,7 +138,7 @@ mod tests { · 137 unmodified lines | |||
| 138 | 138 | ||
| 139 | // Parse & build ceiling dirs string | 139 | // Parse & build ceiling dirs string |
| 140 | let symlink_str = symlink_path.to_str().expect("symlink path is valid utf8"); | 140 | let symlink_str = symlink_path.to_str().expect("symlink path is valid utf8"); |
| 141 | let ceiling_dir_string = format!("{}:relative::{}", symlink_str, symlink_str); | 141 | let ceiling_dir_string = format!("{symlink_str}:relative::{symlink_str}"); |
| 142 | let ceiling_dirs = parse_ceiling_dirs(OsStr::new(ceiling_dir_string.as_str())); | 142 | let ceiling_dirs = parse_ceiling_dirs(OsStr::new(ceiling_dir_string.as_str())); |
| 143 | 143 | ||
| 144 | assert_eq!(ceiling_dirs.len(), 2, "Relative path is discarded"); | 144 | assert_eq!(ceiling_dirs.len(), 2, "Relative path is discarded"); |
| @@ -316,19 +316,13 @@ mod submodules { · 315 unmodified lines | |||
| 316 | let (path, _trust) = git_discover::upwards(&submodule_m1_workdir)?; | 316 | let (path, _trust) = git_discover::upwards(&submodule_m1_workdir)?; |
| 317 | assert!( | 317 | assert!( |
| 318 | matches!(path, git_discover::repository::Path::LinkedWorkTree{ref work_dir, ref git_dir} if work_dir == &submodule_m1_workdir && git_dir == &submodule_m1_gitdir), | 318 | matches!(path, git_discover::repository::Path::LinkedWorkTree{ref work_dir, ref git_dir} if work_dir == &submodule_m1_workdir && git_dir == &submodule_m1_gitdir), |
| 319 | "{:?} should match {:?} {:?}", | 319 | "{path:?} should match {submodule_m1_workdir:?} {submodule_m1_gitdir:?}" |
| 320 | path, | ||
| 321 | submodule_m1_workdir, | ||
| 322 | submodule_m1_gitdir | ||
| 323 | ); | 320 | ); |
| 324 | 321 | ||
| 325 | let (path, _trust) = git_discover::upwards(submodule_m1_workdir.join("subdir"))?; | 322 | let (path, _trust) = git_discover::upwards(submodule_m1_workdir.join("subdir"))?; |
| 326 | assert!( | 323 | assert!( |
| 327 | matches!(path, git_discover::repository::Path::LinkedWorkTree{ref work_dir, ref git_dir} if work_dir == &submodule_m1_workdir && git_dir == &submodule_m1_gitdir), | 324 | matches!(path, git_discover::repository::Path::LinkedWorkTree{ref work_dir, ref git_dir} if work_dir == &submodule_m1_workdir && git_dir == &submodule_m1_gitdir), |
| 328 | "{:?} should match {:?} {:?}", | 325 | "{path:?} should match {submodule_m1_workdir:?} {submodule_m1_gitdir:?}" |
| 329 | path, | ||
| 330 | submodule_m1_workdir, | ||
| 331 | submodule_m1_gitdir | ||
| 332 | ); | 326 | ); |
| 333 | } | 327 | } |
| 334 | Ok(()) | 328 | Ok(()) |
| @@ -343,9 +337,7 @@ mod submodules { · 8 unmodified lines | |||
| 343 | let (path, _trust) = git_discover::upwards(&submodule_m1_gitdir)?; | 337 | let (path, _trust) = git_discover::upwards(&submodule_m1_gitdir)?; |
| 344 | assert!( | 338 | assert!( |
| 345 | matches!(path, git_discover::repository::Path::Repository(ref dir) if dir == &submodule_m1_gitdir), | 339 | matches!(path, git_discover::repository::Path::Repository(ref dir) if dir == &submodule_m1_gitdir), |
| 346 | "{:?} should match {:?}", | 340 | "{path:?} should match {submodule_m1_gitdir:?}" |
| 347 | path, | ||
| 348 | submodule_m1_gitdir | ||
| 349 | ); | 341 | ); |
| 350 | } | 342 | } |
| 351 | Ok(()) | 343 | Ok(()) |
| @@ -61,11 +61,10 @@ fn compare_baseline_with_ours() { · 60 unmodified lines | |||
| 61 | } in Baseline::new(&input) | 61 | } in Baseline::new(&input) |
| 62 | { | 62 | { |
| 63 | total_matches += 1; | 63 | total_matches += 1; |
| 64 | assert!(seen.insert(m), "duplicate match entry: {:?}", m); | 64 | assert!(seen.insert(m), "duplicate match entry: {m:?}"); |
| 65 | assert_eq!( | 65 | assert_eq!( |
| 66 | is_match, *expected_matches, | 66 | is_match, *expected_matches, |
| 67 | "baseline for matches must be {} - check baseline and git version: {:?}", | 67 | "baseline for matches must be {expected_matches} - check baseline and git version: {m:?}" |
| 68 | expected_matches, m | ||
| 69 | ); | 68 | ); |
| 70 | match std::panic::catch_unwind(|| { | 69 | match std::panic::catch_unwind(|| { |
| 71 | let pattern = pat(pattern); | 70 | let pattern = pat(pattern); |
| @@ -157,7 +157,7 @@ impl std::fmt::Debug for ObjectId { · 156 unmodified lines | |||
| 157 | ObjectId::Sha1(_hash) => f.write_str("Sha1(")?, | 157 | ObjectId::Sha1(_hash) => f.write_str("Sha1(")?, |
| 158 | } | 158 | } |
| 159 | for b in self.as_bytes() { | 159 | for b in self.as_bytes() { |
| 160 | write!(f, "{:02x}", b)?; | 160 | write!(f, "{b:02x}")?; |
| 161 | } | 161 | } |
| 162 | f.write_str(")") | 162 | f.write_str(")") |
| 163 | } | 163 | } |
| @@ -173,7 +173,7 @@ impl From<&[u8]> for ObjectId { · 9 unmodified lines | |||
| 173 | fn from(v: &[u8]) -> Self { | 173 | fn from(v: &[u8]) -> Self { |
| 174 | match v.len() { | 174 | match v.len() { |
| 175 | 20 => Self::Sha1(v.try_into().expect("prior length validation")), | 175 | 20 => Self::Sha1(v.try_into().expect("prior length validation")), |
| 176 | other => panic!("BUG: unsupported hash len: {}", other), | 176 | other => panic!("BUG: unsupported hash len: {other}"), |
| 177 | } | 177 | } |
| 178 | } | 178 | } |
| 179 | } | 179 | } |
| @@ -180,7 +180,7 @@ impl<'a> From<&'a [u8; SIZE_OF_SHA1_DIGEST]> for &'a oid { · 179 unmodified lines | |||
| 180 | impl fmt::Display for &oid { | 180 | impl fmt::Display for &oid { |
| 181 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | 181 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 182 | for b in self.as_bytes() { | 182 | for b in self.as_bytes() { |
| 183 | write!(f, "{:02x}", b)?; | 183 | write!(f, "{b:02x}")?; |
| 184 | } | 184 | } |
| 185 | Ok(()) | 185 | Ok(()) |
| 186 | } | 186 | } |
| @@ -47,7 +47,7 @@ mod new { · 46 unmodified lines | |||
| 47 | let num_of_zeros = oid.kind().len_in_hex() - hex_len; | 47 | let num_of_zeros = oid.kind().len_in_hex() - hex_len; |
| 48 | expected.extend(std::iter::repeat('0').take(num_of_zeros)); | 48 | expected.extend(std::iter::repeat('0').take(num_of_zeros)); |
| 49 | let prefix = git_hash::Prefix::new(oid, hex_len).unwrap(); | 49 | let prefix = git_hash::Prefix::new(oid, hex_len).unwrap(); |
| 50 | assert_eq!(prefix.as_oid().to_hex().to_string(), expected, "{}", hex_len); | 50 | assert_eq!(prefix.as_oid().to_hex().to_string(), expected, "{hex_len}"); |
| 51 | assert_eq!(prefix.hex_len(), hex_len); | 51 | assert_eq!(prefix.hex_len(), hex_len); |
| 52 | assert_eq!(prefix.cmp_oid(&oid), Ordering::Equal); | 52 | assert_eq!(prefix.cmp_oid(&oid), Ordering::Equal); |
| 53 | } | 53 | } |
| @@ -102,21 +102,16 @@ mod tests { · 101 unmodified lines | |||
| 102 | } | 102 | } |
| 103 | assert!( | 103 | assert!( |
| 104 | actual * 1000 >= (expected - 1) * 750, | 104 | actual * 1000 >= (expected - 1) * 750, |
| 105 | "value too small: {} < {}", | 105 | "value too small: {actual} < {expected}" |
| 106 | actual, | ||
| 107 | expected | ||
| 108 | ); | 106 | ); |
| 109 | assert!( | 107 | assert!( |
| 110 | actual * 1000 <= (expected + 1) * 1250, | 108 | actual * 1000 <= (expected + 1) * 1250, |
| 111 | "value too big: {} > {}", | 109 | "value too big: {actual} > {expected}" |
| 112 | actual, | ||
| 113 | expected | ||
| 114 | ); | 110 | ); |
| 115 | } | 111 | } |
| 116 | assert!( | 112 | assert!( |
| 117 | num_identities < EXPECTED_TILL_SECOND.len(), | 113 | num_identities < EXPECTED_TILL_SECOND.len(), |
| 118 | "too many untransformed values: {}", | 114 | "too many untransformed values: {num_identities}" |
| 119 | num_identities | ||
| 120 | ); | 115 | ); |
| 121 | } | 116 | } |
| 122 | 117 | ||
| @@ -33,8 +33,7 @@ fn size_in_memory() { · 32 unmodified lines | |||
| 33 | let actual = std::mem::size_of::<git_object::Object>(); | 33 | let actual = std::mem::size_of::<git_object::Object>(); |
| 34 | assert!( | 34 | assert!( |
| 35 | actual <= 264, | 35 | actual <= 264, |
| 36 | "{} <= 264: Prevent unexpected growth of what should be lightweight objects", | 36 | "{actual} <= 264: Prevent unexpected growth of what should be lightweight objects" |
| 37 | actual | ||
| 38 | ) | 37 | ) |
| 39 | } | 38 | } |
| 40 | 39 | ||
| @@ -70,7 +70,7 @@ pub(crate) mod error { · 69 unmodified lines | |||
| 70 | #[test] | 70 | #[test] |
| 71 | fn error_size() { | 71 | fn error_size() { |
| 72 | let actual = std::mem::size_of::<Error>(); | 72 | let actual = std::mem::size_of::<Error>(); |
| 73 | assert!(actual <= 88, "{} <= 88: should not grow without us noticing", actual); | 73 | assert!(actual <= 88, "{actual} <= 88: should not grow without us noticing"); |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | } | 76 | } |
| @@ -219,7 +219,7 @@ where · 142 unmodified lines | |||
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | out.unwrap_or_else(|| { | 221 | out.unwrap_or_else(|| { |
| 222 | panic!("could not find object {} in any index after looking up one of its base objects {}", id, base_id) | 222 | panic!("could not find object {id} in any index after looking up one of its base objects {base_id}" ) |
| 223 | }) | 223 | }) |
| 224 | } | 224 | } |
| 225 | }; | 225 | }; |
| @@ -119,7 +119,7 @@ where · 118 unmodified lines | |||
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | out.unwrap_or_else(|| { | 121 | out.unwrap_or_else(|| { |
| 122 | panic!("could not find object {} in any index after looking up one of its base objects {}", id, base_id) | 122 | panic!("could not find object {id} in any index after looking up one of its base objects {base_id}") |
| 123 | }) | 123 | }) |
| 124 | } | 124 | } |
| 125 | }; | 125 | }; |
| @@ -143,7 +143,7 @@ where · 142 unmodified lines | |||
| 143 | ( | 143 | ( |
| 144 | Vec::<u8>::with_capacity(4096), | 144 | Vec::<u8>::with_capacity(4096), |
| 145 | lock(&object_progress) | 145 | lock(&object_progress) |
| 146 | .add_child_with_id(format!("thread {}", thread_index), git_features::progress::UNKNOWN), | 146 | .add_child_with_id(format!("thread {thread_index}"), git_features::progress::UNKNOWN), |
| 147 | new_thread_state(), | 147 | new_thread_state(), |
| 148 | resolve.clone(), | 148 | resolve.clone(), |
| 149 | inspect_object.clone(), | 149 | inspect_object.clone(), |
| @@ -40,7 +40,7 @@ mod memory { · 39 unmodified lines | |||
| 40 | .with_scale(CustomScale), | 40 | .with_scale(CustomScale), |
| 41 | ), | 41 | ), |
| 42 | free_list: Vec::new(), | 42 | free_list: Vec::new(), |
| 43 | debug: git_features::cache::Debug::new(format!("MemoryCappedHashmap({}B)", memory_cap_in_bytes)), | 43 | debug: git_features::cache::Debug::new(format!("MemoryCappedHashmap({memory_cap_in_bytes}B)")), |
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| @@ -113,7 +113,7 @@ mod _static { · 66 unmodified lines | |||
| 113 | StaticLinkedList { | 113 | StaticLinkedList { |
| 114 | inner: Default::default(), | 114 | inner: Default::default(), |
| 115 | free_list: Vec::new(), | 115 | free_list: Vec::new(), |
| 116 | debug: git_features::cache::Debug::new(format!("StaticLinkedList<{}>", SIZE)), | 116 | debug: git_features::cache::Debug::new(format!("StaticLinkedList<{SIZE}>")), |
| 117 | } | 117 | } |
| 118 | } | 118 | } |
| 119 | } | 119 | } |
| @@ -49,7 +49,7 @@ mod memory { · 48 unmodified lines | |||
| 49 | .with_scale(CustomScale), | 49 | .with_scale(CustomScale), |
| 50 | ), | 50 | ), |
| 51 | free_list: Vec::new(), | 51 | free_list: Vec::new(), |
| 52 | debug: git_features::cache::Debug::new(format!("MemoryCappedObjectHashmap({}B)", memory_cap_in_bytes)), | 52 | debug: git_features::cache::Debug::new(format!("MemoryCappedObjectHashmap({memory_cap_in_bytes}B)")), |
| 53 | } | 53 | } |
| 54 | } | 54 | } |
| 55 | } | 55 | } |
| @@ -23,8 +23,7 @@ impl data::File { · 22 unmodified lines | |||
| 23 | let pack_len = data.len(); | 23 | let pack_len = data.len(); |
| 24 | if pack_len < N32_SIZE * 3 + hash_len { | 24 | if pack_len < N32_SIZE * 3 + hash_len { |
| 25 | return Err(data::header::decode::Error::Corrupt(format!( | 25 | return Err(data::header::decode::Error::Corrupt(format!( |
| 26 | "Pack data of size {} is too small for even an empty pack with shortest hash", | 26 | "Pack data of size {pack_len} is too small for even an empty pack with shortest hash" |
| 27 | pack_len | ||
| 28 | ))); | 27 | ))); |
| 29 | } | 28 | } |
| 30 | let (kind, num_objects) = | 29 | let (kind, num_objects) = |
| @@ -90,11 +90,11 @@ where · 89 unmodified lines | |||
| 90 | } else { | 90 | } else { |
| 91 | header_bytes.len() as u64 | 91 | header_bytes.len() as u64 |
| 92 | }; | 92 | }; |
| 93 | self.output.seek(std::io::SeekFrom::Start(0))?; | 93 | self.output.rewind()?; |
| 94 | self.output.write_all(&header_bytes[..])?; | 94 | self.output.write_all(&header_bytes[..])?; |
| 95 | self.output.flush()?; | 95 | self.output.flush()?; |
| 96 | 96 | ||
| 97 | self.output.seek(std::io::SeekFrom::Start(0))?; | 97 | self.output.rewind()?; |
| 98 | let interrupt_never = std::sync::atomic::AtomicBool::new(false); | 98 | let interrupt_never = std::sync::atomic::AtomicBool::new(false); |
| 99 | let digest = hash::bytes( | 99 | let digest = hash::bytes( |
| 100 | &mut self.output, | 100 | &mut self.output, |
| @@ -79,7 +79,7 @@ where · 78 unmodified lines | |||
| 79 | { | 79 | { |
| 80 | let mut p = progress | 80 | let mut p = progress |
| 81 | .lock() | 81 | .lock() |
| 82 | .add_child_with_id(format!("thread {}", n), git_features::progress::UNKNOWN); | 82 | .add_child_with_id(format!("thread {n}"), git_features::progress::UNKNOWN); |
| 83 | p.init(None, git_features::progress::count("objects")); | 83 | p.init(None, git_features::progress::count("objects")); |
| 84 | p | 84 | p |
| 85 | }, | 85 | }, |
| @@ -143,7 +143,7 @@ pub(crate) mod function { · 142 unmodified lines | |||
| 143 | Vec::new(), // object data buffer | 143 | Vec::new(), // object data buffer |
| 144 | progress | 144 | progress |
| 145 | .lock() | 145 | .lock() |
| 146 | .add_child_with_id(format!("thread {}", n), git_features::progress::UNKNOWN), | 146 | .add_child_with_id(format!("thread {n}"), git_features::progress::UNKNOWN), |
| 147 | ) | 147 | ) |
| 148 | } | 148 | } |
| 149 | }, | 149 | }, |
| @@ -40,7 +40,7 @@ impl index::File { · 39 unmodified lines | |||
| 40 | let footer_size = hash_len * 2; | 40 | let footer_size = hash_len * 2; |
| 41 | if idx_len < FAN_LEN * N32_SIZE + footer_size { | 41 | if idx_len < FAN_LEN * N32_SIZE + footer_size { |
| 42 | return Err(Error::Corrupt { | 42 | return Err(Error::Corrupt { |
| 43 | message: format!("Pack index of size {} is too small for even an empty index", idx_len), | 43 | message: format!("Pack index of size {idx_len} is too small for even an empty index"), |
| 44 | }); | 44 | }); |
| 45 | } | 45 | } |
| 46 | let (kind, fan, num_objects) = { | 46 | let (kind, fan, num_objects) = { |
| @@ -76,7 +76,7 @@ where · 75 unmodified lines | |||
| 76 | fn feed(&mut self, input: Self::Input) -> Result<(), Self::Error> { | 76 | fn feed(&mut self, input: Self::Input) -> Result<(), Self::Error> { |
| 77 | let chunk_stats: Vec<_> = match input { | 77 | let chunk_stats: Vec<_> = match input { |
| 78 | Err(err @ traverse::Error::PackDecode { .. }) if !self.check.fatal_decode_error() => { | 78 | Err(err @ traverse::Error::PackDecode { .. }) if !self.check.fatal_decode_error() => { |
| 79 | lock(&self.progress).info(format!("Ignoring decode error: {}", err)); | 79 | lock(&self.progress).info(format!("Ignoring decode error: {err}")); |
| 80 | return Ok(()); | 80 | return Ok(()); |
| 81 | } | 81 | } |
| 82 | res => res, | 82 | res => res, |
| @@ -150,7 +150,7 @@ impl index::File { · 149 unmodified lines | |||
| 150 | ); | 150 | ); |
| 151 | match result { | 151 | match result { |
| 152 | Err(err @ Error::PackDecode { .. }) if !check.fatal_decode_error() => { | 152 | Err(err @ Error::PackDecode { .. }) if !check.fatal_decode_error() => { |
| 153 | progress.info(format!("Ignoring decode error: {}", err)); | 153 | progress.info(format!("Ignoring decode error: {err}")); |
| 154 | Ok(()) | 154 | Ok(()) |
| 155 | } | 155 | } |
| 156 | res => res, | 156 | res => res, |
| @@ -136,7 +136,7 @@ impl index::File { · 135 unmodified lines | |||
| 136 | new_processor(), | 136 | new_processor(), |
| 137 | Vec::with_capacity(2048), // decode buffer | 137 | Vec::with_capacity(2048), // decode buffer |
| 138 | lock(&reduce_progress) | 138 | lock(&reduce_progress) |
| 139 | .add_child_with_id(format!("thread {}", index), git_features::progress::UNKNOWN), // per thread progress | 139 | .add_child_with_id(format!("thread {index}"), git_features::progress::UNKNOWN), // per thread progress |
| 140 | ) | 140 | ) |
| 141 | } | 141 | } |
| 142 | }; | 142 | }; |
| @@ -171,7 +171,7 @@ impl index::File { · 28 unmodified lines | |||
| 171 | progress.inc(); | 171 | progress.inc(); |
| 172 | let stat = match result { | 172 | let stat = match result { |
| 173 | Err(err @ Error::PackDecode { .. }) if !check.fatal_decode_error() => { | 173 | Err(err @ Error::PackDecode { .. }) if !check.fatal_decode_error() => { |
| 174 | progress.info(format!("Ignoring decode error: {}", err)); | 174 | progress.info(format!("Ignoring decode error: {err}")); |
| 175 | continue; | 175 | continue; |
| 176 | } | 176 | } |
| 177 | res => res, | 177 | res => res, |
| @@ -170,8 +170,7 @@ impl crate::index::File { · 169 unmodified lines | |||
| 170 | } | 170 | } |
| 171 | if num_objects != anticipated_num_objects { | 171 | if num_objects != anticipated_num_objects { |
| 172 | objects_progress.info(format!( | 172 | objects_progress.info(format!( |
| 173 | "{} objects were resolved into {} objects during thin-pack resolution", | 173 | "{anticipated_num_objects} objects were resolved into {num_objects} objects during thin-pack resolution" |
| 174 | anticipated_num_objects, num_objects | ||
| 175 | )); | 174 | )); |
| 176 | } | 175 | } |
| 177 | let num_objects: u32 = num_objects | 176 | let num_objects: u32 = num_objects |
| @@ -127,8 +127,7 @@ fn trailing_relative_components_are_resolved() { · 126 unmodified lines | |||
| 127 | assert_eq!( | 127 | assert_eq!( |
| 128 | normalize(path, cwd).unwrap_or_else(|| panic!("{path:?}")), | 128 | normalize(path, cwd).unwrap_or_else(|| panic!("{path:?}")), |
| 129 | Cow::Borrowed(p(expected)), | 129 | Cow::Borrowed(p(expected)), |
| 130 | "'{}' got an unexpected result", | 130 | "'{input}' got an unexpected result" |
| 131 | input | ||
| 132 | ); | 131 | ); |
| 133 | } | 132 | } |
| 134 | } | 133 | } |
| @@ -266,11 +266,7 @@ mod parse { · 265 unmodified lines | |||
| 266 | fn empty_input() { | 266 | fn empty_input() { |
| 267 | let input = ""; | 267 | let input = ""; |
| 268 | 268 | ||
| 269 | assert!( | 269 | assert!(!check_against_baseline(input), "This pathspec is valid in git: {input}"); |
| 270 | !check_against_baseline(input), | ||
| 271 | "This pathspec is valid in git: {}", | ||
| 272 | input | ||
| 273 | ); | ||
| 274 | 270 | ||
| 275 | let output = git_pathspec::parse(input.as_bytes()); | 271 | let output = git_pathspec::parse(input.as_bytes()); |
| 276 | assert!(output.is_err()); | 272 | assert!(output.is_err()); |
| @@ -285,11 +281,7 @@ mod parse { · 8 unmodified lines | |||
| 285 | ]; | 281 | ]; |
| 286 | 282 | ||
| 287 | for input in inputs.into_iter() { | 283 | for input in inputs.into_iter() { |
| 288 | assert!( | 284 | assert!(!check_against_baseline(input), "This pathspec is valid in git: {input}"); |
| 289 | !check_against_baseline(input), | ||
| 290 | "This pathspec is valid in git: {}", | ||
| 291 | input | ||
| 292 | ); | ||
| 293 | 285 | ||
| 294 | let output = git_pathspec::parse(input.as_bytes()); | 286 | let output = git_pathspec::parse(input.as_bytes()); |
| 295 | assert!(output.is_err()); | 287 | assert!(output.is_err()); |
| @@ -307,11 +299,7 @@ mod parse { · 11 unmodified lines | |||
| 307 | ]; | 299 | ]; |
| 308 | 300 | ||
| 309 | for input in inputs.into_iter() { | 301 | for input in inputs.into_iter() { |
| 310 | assert!( | 302 | assert!(!check_against_baseline(input), "This pathspec is valid in git: {input}"); |
| 311 | !check_against_baseline(input), | ||
| 312 | "This pathspec is valid in git: {}", | ||
| 313 | input | ||
| 314 | ); | ||
| 315 | 303 | ||
| 316 | let output = git_pathspec::parse(input.as_bytes()); | 304 | let output = git_pathspec::parse(input.as_bytes()); |
| 317 | assert!(output.is_err()); | 305 | assert!(output.is_err()); |
| @@ -329,14 +317,10 @@ mod parse { · 11 unmodified lines | |||
| 329 | ]; | 317 | ]; |
| 330 | 318 | ||
| 331 | for input in inputs { | 319 | for input in inputs { |
| 332 | assert!( | 320 | assert!(!check_against_baseline(input), "This pathspec is valid in git: {input}"); |
| 333 | !check_against_baseline(input), | ||
| 334 | "This pathspec is valid in git: {}", | ||
| 335 | input | ||
| 336 | ); | ||
| 337 | 321 | ||
| 338 | let output = git_pathspec::parse(input.as_bytes()); | 322 | let output = git_pathspec::parse(input.as_bytes()); |
| 339 | assert!(output.is_err(), "This pathspec did not produce an error {}", input); | 323 | assert!(output.is_err(), "This pathspec did not produce an error {input}"); |
| 340 | assert!(matches!(output.unwrap_err(), Error::InvalidAttribute { .. })); | 324 | assert!(matches!(output.unwrap_err(), Error::InvalidAttribute { .. })); |
| 341 | } | 325 | } |
| 342 | } | 326 | } |
| @@ -355,18 +339,13 @@ mod parse { · 12 unmodified lines | |||
| 355 | ]; | 339 | ]; |
| 356 | 340 | ||
| 357 | for input in inputs { | 341 | for input in inputs { |
| 358 | assert!( | 342 | assert!(!check_against_baseline(input), "This pathspec is valid in git: {input}"); |
| 359 | !check_against_baseline(input), | ||
| 360 | "This pathspec is valid in git: {}", | ||
| 361 | input | ||
| 362 | ); | ||
| 363 | 343 | ||
| 364 | let output = git_pathspec::parse(input.as_bytes()); | 344 | let output = git_pathspec::parse(input.as_bytes()); |
| 365 | assert!(output.is_err(), "This pathspec did not produce an error {}", input); | 345 | assert!(output.is_err(), "This pathspec did not produce an error {input}"); |
| 366 | assert!( | 346 | assert!( |
| 367 | matches!(output.unwrap_err(), Error::InvalidAttributeValue { .. }), | 347 | matches!(output.unwrap_err(), Error::InvalidAttributeValue { .. }), |
| 368 | "Errors did not match for pathspec: {}", | 348 | "Errors did not match for pathspec: {input}" |
| 369 | input | ||
| 370 | ); | 349 | ); |
| 371 | } | 350 | } |
| 372 | } | 351 | } |
| @@ -380,14 +359,10 @@ mod parse { · 7 unmodified lines | |||
| 380 | ]; | 359 | ]; |
| 381 | 360 | ||
| 382 | for input in inputs { | 361 | for input in inputs { |
| 383 | assert!( | 362 | assert!(!check_against_baseline(input), "This pathspec is valid in git: {input}"); |
| 384 | !check_against_baseline(input), | ||
| 385 | "This pathspec is valid in git: {}", | ||
| 386 | input | ||
| 387 | ); | ||
| 388 | 363 | ||
| 389 | let output = git_pathspec::parse(input.as_bytes()); | 364 | let output = git_pathspec::parse(input.as_bytes()); |
| 390 | assert!(output.is_err(), "This pathspec did not produce an error {}", input); | 365 | assert!(output.is_err(), "This pathspec did not produce an error {input}"); |
| 391 | assert!(matches!(output.unwrap_err(), Error::TrailingEscapeCharacter)); | 366 | assert!(matches!(output.unwrap_err(), Error::TrailingEscapeCharacter)); |
| 392 | } | 367 | } |
| 393 | } | 368 | } |
| @@ -396,11 +371,7 @@ mod parse { · 2 unmodified lines | |||
| 396 | fn empty_attribute_specification() { | 371 | fn empty_attribute_specification() { |
| 397 | let input = ":(attr:)"; | 372 | let input = ":(attr:)"; |
| 398 | 373 | ||
| 399 | assert!( | 374 | assert!(!check_against_baseline(input), "This pathspec is valid in git: {input}"); |
| 400 | !check_against_baseline(input), | ||
| 401 | "This pathspec is valid in git: {}", | ||
| 402 | input | ||
| 403 | ); | ||
| 404 | 375 | ||
| 405 | let output = git_pathspec::parse(input.as_bytes()); | 376 | let output = git_pathspec::parse(input.as_bytes()); |
| 406 | assert!(output.is_err()); | 377 | assert!(output.is_err()); |
| @@ -411,11 +382,7 @@ mod parse { · 4 unmodified lines | |||
| 411 | fn multiple_attribute_specifications() { | 382 | fn multiple_attribute_specifications() { |
| 412 | let input = ":(attr:one,attr:two)some/path"; | 383 | let input = ":(attr:one,attr:two)some/path"; |
| 413 | 384 | ||
| 414 | assert!( | 385 | assert!(!check_against_baseline(input), "This pathspec is valid in git: {input}"); |
| 415 | !check_against_baseline(input), | ||
| 416 | "This pathspec is valid in git: {}", | ||
| 417 | input | ||
| 418 | ); | ||
| 419 | 386 | ||
| 420 | let output = git_pathspec::parse(input.as_bytes()); | 387 | let output = git_pathspec::parse(input.as_bytes()); |
| 421 | assert!(output.is_err()); | 388 | assert!(output.is_err()); |
| @@ -426,11 +393,7 @@ mod parse { · 4 unmodified lines | |||
| 426 | fn missing_parentheses() { | 393 | fn missing_parentheses() { |
| 427 | let input = ":(top"; | 394 | let input = ":(top"; |
| 428 | 395 | ||
| 429 | assert!( | 396 | assert!(!check_against_baseline(input), "This pathspec is valid in git: {input}"); |
| 430 | !check_against_baseline(input), | ||
| 431 | "This pathspec is valid in git: {}", | ||
| 432 | input | ||
| 433 | ); | ||
| 434 | 397 | ||
| 435 | let output = git_pathspec::parse(input.as_bytes()); | 398 | let output = git_pathspec::parse(input.as_bytes()); |
| 436 | assert!(output.is_err()); | 399 | assert!(output.is_err()); |
| @@ -441,11 +404,7 @@ mod parse { · 4 unmodified lines | |||
| 441 | fn glob_and_literal_keywords_present() { | 404 | fn glob_and_literal_keywords_present() { |
| 442 | let input = ":(glob,literal)some/path"; | 405 | let input = ":(glob,literal)some/path"; |
| 443 | 406 | ||
| 444 | assert!( | 407 | assert!(!check_against_baseline(input), "This pathspec is valid in git: {input}"); |
| 445 | !check_against_baseline(input), | ||
| 446 | "This pathspec is valid in git: {}", | ||
| 447 | input | ||
| 448 | ); | ||
| 449 | 408 | ||
| 450 | let output = git_pathspec::parse(input.as_bytes()); | 409 | let output = git_pathspec::parse(input.as_bytes()); |
| 451 | assert!(output.is_err()); | 410 | assert!(output.is_err()); |
| @@ -457,14 +416,13 @@ mod parse { · 5 unmodified lines | |||
| 457 | for (input, expected) in inputs.into_iter() { | 416 | for (input, expected) in inputs.into_iter() { |
| 458 | assert!( | 417 | assert!( |
| 459 | check_against_baseline(input), | 418 | check_against_baseline(input), |
| 460 | "This pathspec is invalid in git: {}", | 419 | "This pathspec is invalid in git: {input}" |
| 461 | input | ||
| 462 | ); | 420 | ); |
| 463 | 421 | ||
| 464 | let pattern: PatternForTesting = git_pathspec::parse(input.as_bytes()) | 422 | let pattern: PatternForTesting = git_pathspec::parse(input.as_bytes()) |
| 465 | .unwrap_or_else(|_| panic!("parsing should not fail with pathspec {}", input)) | 423 | .unwrap_or_else(|_| panic!("parsing should not fail with pathspec {input}")) |
| 466 | .into(); | 424 | .into(); |
| 467 | assert_eq!(pattern, expected, "while checking input: \"{}\"", input); | 425 | assert_eq!(pattern, expected, "while checking input: \"{input}\""); |
| 468 | } | 426 | } |
| 469 | } | 427 | } |
| 470 | 428 | ||
| @@ -509,7 +467,7 @@ mod parse { · 38 unmodified lines | |||
| 509 | let key: &BStr = pathspec.into(); | 467 | let key: &BStr = pathspec.into(); |
| 510 | let base = BASELINE | 468 | let base = BASELINE |
| 511 | .get(key) | 469 | .get(key) |
| 512 | .unwrap_or_else(|| panic!("missing baseline for pathspec: {:?}", pathspec)); | 470 | .unwrap_or_else(|| panic!("missing baseline for pathspec: {pathspec:?}")); |
| 513 | *base == 0 | 471 | *base == 0 |
| 514 | } | 472 | } |
| 515 | } | 473 | } |
| @@ -1,6 +1,6 @@ | |||
| 1 | mod v1 { | 1 | mod v1 { |
| 2 | fn capabilities(input: &str) -> git_transport::client::Capabilities { | 2 | fn capabilities(input: &str) -> git_transport::client::Capabilities { |
| 3 | git_transport::client::Capabilities::from_bytes(format!("\0{}", input).as_bytes()) | 3 | git_transport::client::Capabilities::from_bytes(format!("\0{input}").as_bytes()) |
| 4 | .expect("valid input capabilities") | 4 | .expect("valid input capabilities") |
| 5 | .0 | 5 | .0 |
| 6 | } | 6 | } |
| @@ -54,7 +54,7 @@ mod v2 { · 47 unmodified lines | |||
| 54 | use git_transport::client::Capabilities; | 54 | use git_transport::client::Capabilities; |
| 55 | 55 | ||
| 56 | fn capabilities(command: &str, input: &str) -> Capabilities { | 56 | fn capabilities(command: &str, input: &str) -> Capabilities { |
| 57 | Capabilities::from_lines(format!("version 2\n{}={}", command, input).into()) | 57 | Capabilities::from_lines(format!("version 2\n{command}={input}").into()) |
| 58 | .expect("valid input for V2 capabilities") | 58 | .expect("valid input for V2 capabilities") |
| 59 | } | 59 | } |
| 60 | 60 | ||
| @@ -157,7 +157,7 @@ impl Arguments { · 156 unmodified lines | |||
| 157 | } | 157 | } |
| 158 | } | 158 | } |
| 159 | fn prefixed(&mut self, prefix: &str, value: impl fmt::Display) { | 159 | fn prefixed(&mut self, prefix: &str, value: impl fmt::Display) { |
| 160 | self.args.push(format!("{}{}", prefix, value).into()); | 160 | self.args.push(format!("{prefix}{value}").into()); |
| 161 | } | 161 | } |
| 162 | /// Create a new instance to help setting up arguments to send to the server as part of a `fetch` operation | 162 | /// Create a new instance to help setting up arguments to send to the server as part of a `fetch` operation |
| 163 | /// for which `features` are the available and configured features to use. | 163 | /// for which `features` are the available and configured features to use. |
| @@ -181,7 +181,7 @@ impl Arguments { · 17 unmodified lines | |||
| 181 | let baked_features = features | 181 | let baked_features = features |
| 182 | .iter() | 182 | .iter() |
| 183 | .map(|(n, v)| match v { | 183 | .map(|(n, v)| match v { |
| 184 | Some(v) => format!("{}={}", n, v), | 184 | Some(v) => format!("{n}={v}"), |
| 185 | None => n.to_string(), | 185 | None => n.to_string(), |
| 186 | }) | 186 | }) |
| 187 | .collect::<Vec<_>>(); | 187 | .collect::<Vec<_>>(); |
| @@ -123,7 +123,7 @@ where · 122 unmodified lines | |||
| 123 | let mut round = 1; | 123 | let mut round = 1; |
| 124 | 'negotiation: loop { | 124 | 'negotiation: loop { |
| 125 | progress.step(); | 125 | progress.step(); |
| 126 | progress.set_name(format!("negotiate (round {})", round)); | 126 | progress.set_name(format!("negotiate (round {round})")); |
| 127 | round += 1; | 127 | round += 1; |
| 128 | let action = delegate.negotiate(&refs, &mut arguments, previous_response.as_ref())?; | 128 | let action = delegate.negotiate(&refs, &mut arguments, previous_response.as_ref())?; |
| 129 | let mut reader = arguments.send(&mut transport, action == Action::Cancel).await?; | 129 | let mut reader = arguments.send(&mut transport, action == Action::Cancel).await?; |
| @@ -214,7 +214,7 @@ mod v2 { · 213 unmodified lines | |||
| 214 | fetch::response::Error::UploadPack(err) => { | 214 | fetch::response::Error::UploadPack(err) => { |
| 215 | assert_eq!(err.message, "segmentation fault\n") | 215 | assert_eq!(err.message, "segmentation fault\n") |
| 216 | } | 216 | } |
| 217 | err => panic!("we expect upload pack errors, got {:#?}", err), | 217 | err => panic!("we expect upload pack errors, got {err:#?}"), |
| 218 | }, | 218 | }, |
| 219 | } | 219 | } |
| 220 | } | 220 | } |
| @@ -28,7 +28,7 @@ async fn clone() -> crate::Result { · 27 unmodified lines | |||
| 28 | "agent", | 28 | "agent", |
| 29 | ) | 29 | ) |
| 30 | .await?; | 30 | .await?; |
| 31 | assert_eq!(dlg.pack_bytes, 876, "{}: It be able to read pack bytes", fixture); | 31 | assert_eq!(dlg.pack_bytes, 876, "{fixture}: It be able to read pack bytes"); |
| 32 | } | 32 | } |
| 33 | Ok(()) | 33 | Ok(()) |
| 34 | } | 34 | } |
| @@ -140,7 +140,7 @@ async fn ls_remote_abort_in_prep_ls_refs() -> crate::Result { · 139 unmodified lines | |||
| 140 | assert_eq!(err.kind(), std::io::ErrorKind::Other); | 140 | assert_eq!(err.kind(), std::io::ErrorKind::Other); |
| 141 | assert_eq!(err.get_ref().expect("other error").to_string(), "hello world"); | 141 | assert_eq!(err.get_ref().expect("other error").to_string(), "hello world"); |
| 142 | } | 142 | } |
| 143 | err => panic!("should not have another error here, got: {}", err), | 143 | err => panic!("should not have another error here, got: {err}"), |
| 144 | } | 144 | } |
| 145 | Ok(()) | 145 | Ok(()) |
| 146 | } | 146 | } |
| @@ -156,7 +156,7 @@ pub mod create_or_update { · 155 unmodified lines | |||
| 156 | .and_then(|_| committer.write_to(&mut file)) | 156 | .and_then(|_| committer.write_to(&mut file)) |
| 157 | .and_then(|_| { | 157 | .and_then(|_| { |
| 158 | if !message.is_empty() { | 158 | if !message.is_empty() { |
| 159 | writeln!(file, "\t{}", message) | 159 | writeln!(file, "\t{message}") |
| 160 | } else { | 160 | } else { |
| 161 | writeln!(file) | 161 | writeln!(file) |
| 162 | } | 162 | } |
| @@ -183,7 +183,7 @@ impl<'s, 'p> Transaction<'s, 'p> { · 182 unmodified lines | |||
| 183 | let mut lock = lock.take().map(Ok).unwrap_or_else(obtain_lock)?; | 183 | let mut lock = lock.take().map(Ok).unwrap_or_else(obtain_lock)?; |
| 184 | 184 | ||
| 185 | lock.with_mut(|file| match new { | 185 | lock.with_mut(|file| match new { |
| 186 | Target::Peeled(oid) => write!(file, "{}", oid), | 186 | Target::Peeled(oid) => write!(file, "{oid}"), |
| 187 | Target::Symbolic(name) => write!(file, "ref: {}", name.0), | 187 | Target::Symbolic(name) => write!(file, "ref: {}", name.0), |
| 188 | })?; | 188 | })?; |
| 189 | Some(lock.close()?) | 189 | Some(lock.close()?) |
| @@ -81,7 +81,7 @@ impl packed::Transaction { · 80 unmodified lines | |||
| 81 | Some(kind) if kind == git_object::Kind::Tag => { | 81 | Some(kind) if kind == git_object::Kind::Tag => { |
| 82 | next_id = git_object::TagRefIter::from_bytes(&buf).target_id().map_err(|_| { | 82 | next_id = git_object::TagRefIter::from_bytes(&buf).target_id().map_err(|_| { |
| 83 | prepare::Error::Resolve( | 83 | prepare::Error::Resolve( |
| 84 | format!("Couldn't get target object id from tag {}", next_id).into(), | 84 | format!("Couldn't get target object id from tag {next_id}").into(), |
| 85 | ) | 85 | ) |
| 86 | })?; | 86 | })?; |
| 87 | } | 87 | } |
| @@ -90,7 +90,7 @@ impl packed::Transaction { · 2 unmodified lines | |||
| 90 | } | 90 | } |
| 91 | None => { | 91 | None => { |
| 92 | return Err(prepare::Error::Resolve( | 92 | return Err(prepare::Error::Resolve( |
| 93 | format!("Couldn't find object with id {}", next_id).into(), | 93 | format!("Couldn't find object with id {next_id}").into(), |
| 94 | )) | 94 | )) |
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| @@ -194,7 +194,7 @@ fn write_packed_ref(mut out: impl std::io::Write, pref: packed::Reference<'_>) - · 97 unmodified lines | |||
| 194 | out.write_all(pref.name.as_bstr())?; | 194 | out.write_all(pref.name.as_bstr())?; |
| 195 | out.write_all(b"\n")?; | 195 | out.write_all(b"\n")?; |
| 196 | if let Some(object) = pref.object { | 196 | if let Some(object) = pref.object { |
| 197 | writeln!(out, "^{}", object)?; | 197 | writeln!(out, "^{object}")?; |
| 198 | } | 198 | } |
| 199 | Ok(()) | 199 | Ok(()) |
| 200 | } | 200 | } |
| @@ -206,11 +206,11 @@ fn write_edit(mut out: impl std::io::Write, edit: &Edit, lines_written: &mut i32 · 5 unmodified lines | |||
| 206 | new: Target::Peeled(target_oid), | 206 | new: Target::Peeled(target_oid), |
| 207 | .. | 207 | .. |
| 208 | } => { | 208 | } => { |
| 209 | write!(out, "{} ", target_oid)?; | 209 | write!(out, "{target_oid} ")?; |
| 210 | out.write_all(edit.inner.name.as_bstr())?; | 210 | out.write_all(edit.inner.name.as_bstr())?; |
| 211 | out.write_all(b"\n")?; | 211 | out.write_all(b"\n")?; |
| 212 | if let Some(object) = edit.peeled { | 212 | if let Some(object) = edit.peeled { |
| 213 | writeln!(out, "^{}", object)?; | 213 | writeln!(out, "^{object}")?; |
| 214 | } | 214 | } |
| 215 | *lines_written += 1; | 215 | *lines_written += 1; |
| 216 | } | 216 | } |
| @@ -34,7 +34,7 @@ where · 33 unmodified lines | |||
| 34 | self.assure_one_name_has_one_edit().map_err(|name| { | 34 | self.assure_one_name_has_one_edit().map_err(|name| { |
| 35 | std::io::Error::new( | 35 | std::io::Error::new( |
| 36 | std::io::ErrorKind::AlreadyExists, | 36 | std::io::ErrorKind::AlreadyExists, |
| 37 | format!("A reference named '{}' has multiple edits", name), | 37 | format!("A reference named '{name}' has multiple edits"), |
| 38 | ) | 38 | ) |
| 39 | }) | 39 | }) |
| 40 | } | 40 | } |
| @@ -121,10 +121,7 @@ where · 80 unmodified lines | |||
| 121 | if round == 5 { | 121 | if round == 5 { |
| 122 | break Err(std::io::Error::new( | 122 | break Err(std::io::Error::new( |
| 123 | std::io::ErrorKind::WouldBlock, | 123 | std::io::ErrorKind::WouldBlock, |
| 124 | format!( | 124 | format!("Could not follow all splits after {round} rounds, assuming reference cycle"), |
| 125 | "Could not follow all splits after {} rounds, assuming reference cycle", | ||
| 126 | round | ||
| 127 | ), | ||
| 128 | )); | 125 | )); |
| 129 | } | 126 | } |
| 130 | round += 1; | 127 | round += 1; |
| @@ -109,7 +109,7 @@ mod loose { · 108 unmodified lines | |||
| 109 | Err(git_ref::file::find::existing::Error::NotFound { name }) => { | 109 | Err(git_ref::file::find::existing::Error::NotFound { name }) => { |
| 110 | assert_eq!(name, Path::new(*partial_name)); | 110 | assert_eq!(name, Path::new(*partial_name)); |
| 111 | } | 111 | } |
| 112 | Err(err) => panic!("Unexpected err: {:?}", err), | 112 | Err(err) => panic!("Unexpected err: {err:?}"), |
| 113 | }, | 113 | }, |
| 114 | } | 114 | } |
| 115 | } | 115 | } |
| @@ -302,7 +302,7 @@ fn loose_iter_with_broken_refs() -> crate::Result { · 301 unmodified lines | |||
| 302 | "tags/t1" | 302 | "tags/t1" |
| 303 | ] | 303 | ] |
| 304 | .into_iter() | 304 | .into_iter() |
| 305 | .map(|p| format!("refs/{}", p)) | 305 | .map(|p| format!("refs/{p}")) |
| 306 | .collect::<Vec<_>>(), | 306 | .collect::<Vec<_>>(), |
| 307 | "all paths are as expected" | 307 | "all paths are as expected" |
| 308 | ); | 308 | ); |
| @@ -30,10 +30,7 @@ fn conflicting_creation_without_packed_refs() -> crate::Result { · 29 unmodified lines | |||
| 30 | match res { | 30 | match res { |
| 31 | Ok(_) if case_sensitive => {} | 31 | Ok(_) if case_sensitive => {} |
| 32 | Ok(_) if !case_sensitive => panic!("should fail as 'a' and 'A' clash"), | 32 | Ok(_) if !case_sensitive => panic!("should fail as 'a' and 'A' clash"), |
| 33 | Err(err) if case_sensitive => panic!( | 33 | Err(err) if case_sensitive => panic!("should work as case sensitivity allows 'a' and 'A' to coexist: {err:?}"), |
| 34 | "should work as case sensitivity allows 'a' and 'A' to coexist: {:?}", | ||
| 35 | err | ||
| 36 | ), | ||
| 37 | Err(err) if !case_sensitive => { | 34 | Err(err) if !case_sensitive => { |
| 38 | assert_eq!(err.to_string(), "A lock could not be obtained for reference \"refs/A\"") | 35 | assert_eq!(err.to_string(), "A lock could not be obtained for reference \"refs/A\"") |
| 39 | } | 36 | } |
| @@ -113,10 +113,10 @@ pub mod baseline { · 112 unmodified lines | |||
| 113 | Err(e) if e.to_string() == err => { | 113 | Err(e) if e.to_string() == err => { |
| 114 | saw_err = true; | 114 | saw_err = true; |
| 115 | } | 115 | } |
| 116 | Err(err) => panic!("Unexpected parse error: {:?}", err), | 116 | Err(err) => panic!("Unexpected parse error: {err:?}"), |
| 117 | } | 117 | } |
| 118 | } | 118 | } |
| 119 | assert!(saw_err, "Failed to see error when parsing specs: {:?}", err) | 119 | assert!(saw_err, "Failed to see error when parsing specs: {err:?}") |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | /// Here we checked by hand which refs are actually written with a particular refspec | 122 | /// Here we checked by hand which refs are actually written with a particular refspec |
| @@ -143,7 +143,7 @@ pub mod baseline { · 20 unmodified lines | |||
| 143 | let key: Vec<_> = specs.into_iter().map(BString::from).collect(); | 143 | let key: Vec<_> = specs.into_iter().map(BString::from).collect(); |
| 144 | let expected = BASELINE | 144 | let expected = BASELINE |
| 145 | .get(&key) | 145 | .get(&key) |
| 146 | .unwrap_or_else(|| panic!("BUG: Need {:?} added to the baseline", key)) | 146 | .unwrap_or_else(|| panic!("BUG: Need {key:?} added to the baseline")) |
| 147 | .as_ref(); | 147 | .as_ref(); |
| 148 | 148 | ||
| 149 | let actual = match_group.match_remotes(input()).validated(); | 149 | let actual = match_group.match_remotes(input()).validated(); |
| @@ -175,22 +175,15 @@ pub mod baseline { · 25 unmodified lines | |||
| 175 | assert_eq!( | 175 | assert_eq!( |
| 176 | actual.len(), | 176 | actual.len(), |
| 177 | expected.len(), | 177 | expected.len(), |
| 178 | "got a different amount of mappings: {:?} != {:?}", | 178 | "got a different amount of mappings: {actual:?} != {expected:?}" |
| 179 | actual, | ||
| 180 | expected | ||
| 181 | ); | 179 | ); |
| 182 | 180 | ||
| 183 | for (idx, (actual, expected)) in actual.iter().zip(expected).enumerate() { | 181 | for (idx, (actual, expected)) in actual.iter().zip(expected).enumerate() { |
| 184 | assert_eq!( | 182 | assert_eq!(source_to_bstring(actual.lhs), expected.remote, "{idx}: remote mismatch"); |
| 185 | source_to_bstring(actual.lhs), | ||
| 186 | expected.remote, | ||
| 187 | "{}: remote mismatch", | ||
| 188 | idx | ||
| 189 | ); | ||
| 190 | if let Some(expected) = expected.local.as_ref() { | 183 | if let Some(expected) = expected.local.as_ref() { |
| 191 | match actual.rhs.as_ref() { | 184 | match actual.rhs.as_ref() { |
| 192 | None => panic!("{}: Expected local ref to be {}, got none", idx, expected), | 185 | None => panic!("{idx}: Expected local ref to be {expected}, got none"), |
| 193 | Some(actual) => assert_eq!(actual.as_ref(), expected, "{}: mismatched local ref", idx), | 186 | Some(actual) => assert_eq!(actual.as_ref(), expected, "{idx}: mismatched local ref"), |
| 194 | } | 187 | } |
| 195 | } | 188 | } |
| 196 | } | 189 | } |
| @@ -12,6 +12,7 @@ use crate::{ · 11 unmodified lines | |||
| 12 | Repository, | 12 | Repository, |
| 13 | }; | 13 | }; |
| 14 | 14 | ||
| 15 | #[allow(clippy::result_large_err)] | ||
| 15 | pub fn write_remote_to_local_config_file( | 16 | pub fn write_remote_to_local_config_file( |
| 16 | remote: &mut crate::Remote<'_>, | 17 | remote: &mut crate::Remote<'_>, |
| 17 | remote_name: BString, | 18 | remote_name: BString, |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use std::convert::TryInto; | 2 | use std::convert::TryInto; |
| 2 | 3 | ||
| 3 | use crate::bstr::BString; | 4 | use crate::bstr::BString; |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use std::{borrow::Cow, path::PathBuf, time::Duration}; | 2 | use std::{borrow::Cow, path::PathBuf, time::Duration}; |
| 2 | 3 | ||
| 3 | use git_lock::acquire::Fail; | 4 | use git_lock::acquire::Fail; |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use super::{util, Error}; | 2 | use super::{util, Error}; |
| 2 | use crate::config::tree::{Core, Extensions}; | 3 | use crate::config::tree::{Core, Extensions}; |
| 3 | 4 | ||
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use std::borrow::Cow; | 2 | use std::borrow::Cow; |
| 2 | 3 | ||
| 3 | use git_sec::Permission; | 4 | use git_sec::Permission; |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use super::Error; | 2 | use super::Error; |
| 2 | use crate::{ | 3 | use crate::{ |
| 3 | config, | 4 | config, |
| @@ -102,7 +103,7 @@ pub(crate) fn disambiguate_hint( · 98 unmodified lines | |||
| 102 | lenient_config: bool, | 103 | lenient_config: bool, |
| 103 | ) -> Result<Option<ObjectKindHint>, config::key::GenericErrorWithValue> { | 104 | ) -> Result<Option<ObjectKindHint>, config::key::GenericErrorWithValue> { |
| 104 | match config.string_by_key("core.disambiguate") { | 105 | match config.string_by_key("core.disambiguate") { |
| 105 | None => return Ok(None), | 106 | None => Ok(None), |
| 106 | Some(value) => Core::DISAMBIGUATE | 107 | Some(value) => Core::DISAMBIGUATE |
| 107 | .try_into_object_kind_hint(value) | 108 | .try_into_object_kind_hint(value) |
| 108 | .with_leniency(lenient_config), | 109 | .with_leniency(lenient_config), |
| @@ -124,7 +124,7 @@ pub mod protocol { · 123 unmodified lines | |||
| 124 | /// The error returned when obtaining the permission for a particular scheme. | 124 | /// The error returned when obtaining the permission for a particular scheme. |
| 125 | #[derive(Debug, thiserror::Error)] | 125 | #[derive(Debug, thiserror::Error)] |
| 126 | #[allow(missing_docs)] | 126 | #[allow(missing_docs)] |
| 127 | #[error("The value {value:?} must be allow|deny|user in configuration key protocol{0}.allow", scheme.as_ref().map(|s| format!(".{}", s)).unwrap_or_default())] | 127 | #[error("The value {value:?} must be allow|deny|user in configuration key protocol{0}.allow", scheme.as_ref().map(|s| format!(".{s}")).unwrap_or_default())] |
| 128 | pub struct Error { | 128 | pub struct Error { |
| 129 | pub scheme: Option<String>, | 129 | pub scheme: Option<String>, |
| 130 | pub value: BString, | 130 | pub value: BString, |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use std::borrow::Cow; | 2 | use std::borrow::Cow; |
| 2 | 3 | ||
| 3 | use git_features::threading::OwnShared; | 4 | use git_features::threading::OwnShared; |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use std::{ | 2 | use std::{ |
| 2 | borrow::Cow, | 3 | borrow::Cow, |
| 3 | error::Error, | 4 | error::Error, |
| @@ -452,6 +453,7 @@ mod remote_name { · 448 unmodified lines | |||
| 452 | } | 453 | } |
| 453 | 454 | ||
| 454 | /// Try to validate `name` as symbolic remote name and return it. | 455 | /// Try to validate `name` as symbolic remote name and return it. |
| 456 | #[allow(clippy::result_large_err)] | ||
| 455 | pub fn try_into_symbolic_name( | 457 | pub fn try_into_symbolic_name( |
| 456 | &'static self, | 458 | &'static self, |
| 457 | name: Cow<'_, BStr>, | 459 | name: Cow<'_, BStr>, |
| @@ -115,7 +115,7 @@ mod disambiguate { · 114 unmodified lines | |||
| 115 | 115 | ||
| 116 | impl Disambiguate { | 116 | impl Disambiguate { |
| 117 | /// Convert a disambiguation marker into the respective enum. | 117 | /// Convert a disambiguation marker into the respective enum. |
| 118 | pub fn try_into_object_kind_hint<'a>( | 118 | pub fn try_into_object_kind_hint( |
| 119 | &'static self, | 119 | &'static self, |
| 120 | value: Cow<'_, BStr>, | 120 | value: Cow<'_, BStr>, |
| 121 | ) -> Result<Option<ObjectKindHint>, config::key::GenericErrorWithValue> { | 121 | ) -> Result<Option<ObjectKindHint>, config::key::GenericErrorWithValue> { |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use std::path::Path; | 2 | use std::path::Path; |
| 2 | 3 | ||
| 3 | pub use git_discover::*; | 4 | pub use git_discover::*; |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use std::{borrow::Cow, convert::TryInto, path::Path}; | 2 | use std::{borrow::Cow, convert::TryInto, path::Path}; |
| 2 | 3 | ||
| 3 | use git_ref::{ | 4 | use git_ref::{ |
| @@ -140,16 +140,19 @@ pub mod progress { · 139 unmodified lines | |||
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | /// See [ThreadSafeRepository::discover()], but returns a [`Repository`] instead. | 142 | /// See [ThreadSafeRepository::discover()], but returns a [`Repository`] instead. |
| 143 | #[allow(clippy::result_large_err)] | ||
| 143 | pub fn discover(directory: impl AsRef<std::path::Path>) -> Result<Repository, discover::Error> { | 144 | pub fn discover(directory: impl AsRef<std::path::Path>) -> Result<Repository, discover::Error> { |
| 144 | ThreadSafeRepository::discover(directory).map(Into::into) | 145 | ThreadSafeRepository::discover(directory).map(Into::into) |
| 145 | } | 146 | } |
| 146 | 147 | ||
| 147 | /// See [ThreadSafeRepository::init()], but returns a [`Repository`] instead. | 148 | /// See [ThreadSafeRepository::init()], but returns a [`Repository`] instead. |
| 149 | #[allow(clippy::result_large_err)] | ||
| 148 | pub fn init(directory: impl AsRef<std::path::Path>) -> Result<Repository, init::Error> { | 150 | pub fn init(directory: impl AsRef<std::path::Path>) -> Result<Repository, init::Error> { |
| 149 | ThreadSafeRepository::init(directory, create::Kind::WithWorktree, create::Options::default()).map(Into::into) | 151 | ThreadSafeRepository::init(directory, create::Kind::WithWorktree, create::Options::default()).map(Into::into) |
| 150 | } | 152 | } |
| 151 | 153 | ||
| 152 | /// See [ThreadSafeRepository::init()], but returns a [`Repository`] instead. | 154 | /// See [ThreadSafeRepository::init()], but returns a [`Repository`] instead. |
| 155 | #[allow(clippy::result_large_err)] | ||
| 153 | pub fn init_bare(directory: impl AsRef<std::path::Path>) -> Result<Repository, init::Error> { | 156 | pub fn init_bare(directory: impl AsRef<std::path::Path>) -> Result<Repository, init::Error> { |
| 154 | ThreadSafeRepository::init(directory, create::Kind::Bare, create::Options::default()).map(Into::into) | 157 | ThreadSafeRepository::init(directory, create::Kind::Bare, create::Options::default()).map(Into::into) |
| 155 | } | 158 | } |
| @@ -203,11 +206,13 @@ fn open_opts_with_git_binary_config() -> open::Options { · 47 unmodified lines | |||
| 203 | } | 206 | } |
| 204 | 207 | ||
| 205 | /// See [ThreadSafeRepository::open()], but returns a [`Repository`] instead. | 208 | /// See [ThreadSafeRepository::open()], but returns a [`Repository`] instead. |
| 209 | #[allow(clippy::result_large_err)] | ||
| 206 | pub fn open(directory: impl Into<std::path::PathBuf>) -> Result<Repository, open::Error> { | 210 | pub fn open(directory: impl Into<std::path::PathBuf>) -> Result<Repository, open::Error> { |
| 207 | ThreadSafeRepository::open(directory).map(Into::into) | 211 | ThreadSafeRepository::open(directory).map(Into::into) |
| 208 | } | 212 | } |
| 209 | 213 | ||
| 210 | /// See [ThreadSafeRepository::open_opts()], but returns a [`Repository`] instead. | 214 | /// See [ThreadSafeRepository::open_opts()], but returns a [`Repository`] instead. |
| 215 | #[allow(clippy::result_large_err)] | ||
| 211 | pub fn open_opts(directory: impl Into<std::path::PathBuf>, options: open::Options) -> Result<Repository, open::Error> { | 216 | pub fn open_opts(directory: impl Into<std::path::PathBuf>, options: open::Options) -> Result<Repository, open::Error> { |
| 212 | ThreadSafeRepository::open_opts(directory, options).map(Into::into) | 217 | ThreadSafeRepository::open_opts(directory, options).map(Into::into) |
| 213 | } | 218 | } |
| @@ -61,9 +61,7 @@ mod tests { · 60 unmodified lines | |||
| 61 | let limit = 160; | 61 | let limit = 160; |
| 62 | assert!( | 62 | assert!( |
| 63 | actual <= limit, | 63 | actual <= limit, |
| 64 | "{} <= {}: size shouldn't change without us knowing (on windows, it's bigger)", | 64 | "{actual} <= {limit}: size shouldn't change without us knowing (on windows, it's bigger)" |
| 65 | actual, | ||
| 66 | limit | ||
| 67 | ); | 65 | ); |
| 68 | } | 66 | } |
| 69 | } | 67 | } |
| @@ -140,6 +140,7 @@ impl Options { · 139 unmodified lines | |||
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | /// Open a repository at `path` with the options set so far. | 142 | /// Open a repository at `path` with the options set so far. |
| 143 | #[allow(clippy::result_large_err)] | ||
| 143 | pub fn open(self, path: impl Into<PathBuf>) -> Result<ThreadSafeRepository, Error> { | 144 | pub fn open(self, path: impl Into<PathBuf>) -> Result<ThreadSafeRepository, Error> { |
| 144 | ThreadSafeRepository::open_opts(path, self) | 145 | ThreadSafeRepository::open_opts(path, self) |
| 145 | } | 146 | } |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use std::{borrow::Cow, path::PathBuf}; | 2 | use std::{borrow::Cow, path::PathBuf}; |
| 2 | 3 | ||
| 3 | use git_features::threading::OwnShared; | 4 | use git_features::threading::OwnShared; |
| @@ -27,6 +27,7 @@ pub mod set_target_id { · 26 unmodified lines | |||
| 27 | /// Furthermore, refrain from using this method for more than a one-off change as it creates a transaction for each invocation. | 27 | /// Furthermore, refrain from using this method for more than a one-off change as it creates a transaction for each invocation. |
| 28 | /// If multiple reference should be changed, use [Repository::edit_references()][crate::Repository::edit_references()] | 28 | /// If multiple reference should be changed, use [Repository::edit_references()][crate::Repository::edit_references()] |
| 29 | /// or the lower level reference database instead. | 29 | /// or the lower level reference database instead. |
| 30 | #[allow(clippy::result_large_err)] | ||
| 30 | pub fn set_target_id( | 31 | pub fn set_target_id( |
| 31 | &mut self, | 32 | &mut self, |
| 32 | id: impl Into<git_hash::ObjectId>, | 33 | id: impl Into<git_hash::ObjectId>, |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use git_protocol::transport::client::Transport; | 2 | use git_protocol::transport::client::Transport; |
| 2 | 3 | ||
| 3 | use crate::{remote::Connection, Progress, Remote}; | 4 | use crate::{remote::Connection, Progress, Remote}; |
| @@ -32,7 +32,7 @@ pub enum RefLogMessage { · 31 unmodified lines | |||
| 32 | impl RefLogMessage { | 32 | impl RefLogMessage { |
| 33 | pub(crate) fn compose(&self, context: &str) -> BString { | 33 | pub(crate) fn compose(&self, context: &str) -> BString { |
| 34 | match self { | 34 | match self { |
| 35 | RefLogMessage::Prefixed { action } => format!("{}: {}", action, context).into(), | 35 | RefLogMessage::Prefixed { action } => format!("{action}: {context}").into(), |
| 36 | RefLogMessage::Override { message } => message.to_owned(), | 36 | RefLogMessage::Override { message } => message.to_owned(), |
| 37 | } | 37 | } |
| 38 | } | 38 | } |
| @@ -98,7 +98,7 @@ where · 97 unmodified lines | |||
| 98 | 98 | ||
| 99 | let reader = 'negotiation: loop { | 99 | let reader = 'negotiation: loop { |
| 100 | progress.step(); | 100 | progress.step(); |
| 101 | progress.set_name(format!("negotiate (round {})", round)); | 101 | progress.set_name(format!("negotiate (round {round})")); |
| 102 | 102 | ||
| 103 | let is_done = match negotiate::one_round( | 103 | let is_done = match negotiate::one_round( |
| 104 | negotiate::Algorithm::Naive, | 104 | negotiate::Algorithm::Naive, |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use std::{collections::BTreeMap, convert::TryInto, path::PathBuf}; | 2 | use std::{collections::BTreeMap, convert::TryInto, path::PathBuf}; |
| 2 | 3 | ||
| 3 | use git_odb::{Find, FindExt}; | 4 | use git_odb::{Find, FindExt}; |
| @@ -160,9 +160,8 @@ mod update { · 159 unmodified lines | |||
| 160 | Change::Update { log, new, .. } => { | 160 | Change::Update { log, new, .. } => { |
| 161 | assert_eq!( | 161 | assert_eq!( |
| 162 | log.message, | 162 | log.message, |
| 163 | format!("action: {}", reflog_message), | 163 | format!("action: {reflog_message}"), |
| 164 | "{}: reflog messages are specific and we emulate git word for word", | 164 | "{spec}: reflog messages are specific and we emulate git word for word" |
| 165 | spec | ||
| 166 | ); | 165 | ); |
| 167 | let remote_ref = repo | 166 | let remote_ref = repo |
| 168 | .find_reference(specs[0].to_ref().source().expect("always present")) | 167 | .find_reference(specs[0].to_ref().source().expect("always present")) |
| @@ -195,7 +194,7 @@ mod update { · 26 unmodified lines | |||
| 195 | ("wt-c-locked", "wt-c-locked"), | 194 | ("wt-c-locked", "wt-c-locked"), |
| 196 | ("wt-deleted", "wt-deleted"), | 195 | ("wt-deleted", "wt-deleted"), |
| 197 | ] { | 196 | ] { |
| 198 | let spec = format!("refs/heads/main:refs/heads/{}", branch); | 197 | let spec = format!("refs/heads/main:refs/heads/{branch}"); |
| 199 | let (mappings, specs) = mapping_from_spec(&spec, &repo); | 198 | let (mappings, specs) = mapping_from_spec(&spec, &repo); |
| 200 | let out = fetch::refs::update( | 199 | let out = fetch::refs::update( |
| 201 | &repo, | 200 | &repo, |
| @@ -216,7 +215,7 @@ mod update { · 14 unmodified lines | |||
| 216 | }, | 215 | }, |
| 217 | edit_index: None, | 216 | edit_index: None, |
| 218 | }], | 217 | }], |
| 219 | "{}: checked-out checks are done before checking if a change would actually be required (here it isn't)", spec | 218 | "{spec}: checked-out checks are done before checking if a change would actually be required (here it isn't)" |
| 220 | ); | 219 | ); |
| 221 | assert_eq!(out.edits.len(), 0); | 220 | assert_eq!(out.edits.len(), 0); |
| 222 | } | 221 | } |
| @@ -81,7 +81,7 @@ impl std::fmt::Display for Mode { · 80 unmodified lines | |||
| 81 | Mode::Forced => "forced-update", | 81 | Mode::Forced => "forced-update", |
| 82 | Mode::New => "new", | 82 | Mode::New => "new", |
| 83 | Mode::ImplicitTagNotSentByRemote => "unrelated tag on remote", | 83 | Mode::ImplicitTagNotSentByRemote => "unrelated tag on remote", |
| 84 | Mode::RejectedSourceObjectNotFound { id } => return write!(f, "rejected ({} not found)", id), | 84 | Mode::RejectedSourceObjectNotFound { id } => return write!(f, "rejected ({id} not found)"), |
| 85 | Mode::RejectedTagUpdate => "rejected (would overwrite existing tag)", | 85 | Mode::RejectedTagUpdate => "rejected (would overwrite existing tag)", |
| 86 | Mode::RejectedNonFastForward => "rejected (non-fast-forward)", | 86 | Mode::RejectedNonFastForward => "rejected (non-fast-forward)", |
| 87 | Mode::RejectedSymbolic => "rejected (refusing to write symbolic refs)", | 87 | Mode::RejectedSymbolic => "rejected (refusing to write symbolic refs)", |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use std::any::Any; | 2 | use std::any::Any; |
| 2 | 3 | ||
| 3 | use crate::bstr::BStr; | 4 | use crate::bstr::BStr; |
| @@ -170,7 +171,7 @@ impl crate::Repository { · 166 unmodified lines | |||
| 170 | .with_leniency(lenient) | 171 | .with_leniency(lenient) |
| 171 | }, | 172 | }, |
| 172 | ) | 173 | ) |
| 173 | .map_err(|err| config::transport::http::Error::InvalidFollowRedirects(err))? | 174 | .map_err(config::transport::http::Error::InvalidFollowRedirects)? |
| 174 | }; | 175 | }; |
| 175 | 176 | ||
| 176 | opts.low_speed_time_seconds = config | 177 | opts.low_speed_time_seconds = config |
| @@ -178,14 +179,14 @@ impl crate::Repository { · 1 unmodified line | |||
| 178 | .map(|value| config::tree::Http::LOW_SPEED_TIME.try_into_u64(value)) | 179 | .map(|value| config::tree::Http::LOW_SPEED_TIME.try_into_u64(value)) |
| 179 | .transpose() | 180 | .transpose() |
| 180 | .with_leniency(lenient) | 181 | .with_leniency(lenient) |
| 181 | .map_err(|err| config::transport::http::Error::from(err))? | 182 | .map_err(config::transport::http::Error::from)? |
| 182 | .unwrap_or_default(); | 183 | .unwrap_or_default(); |
| 183 | opts.low_speed_limit_bytes_per_second = config | 184 | opts.low_speed_limit_bytes_per_second = config |
| 184 | .integer_filter_by_key("http.lowSpeedLimit", &mut trusted_only) | 185 | .integer_filter_by_key("http.lowSpeedLimit", &mut trusted_only) |
| 185 | .map(|value| config::tree::Http::LOW_SPEED_LIMIT.try_into_u32(value)) | 186 | .map(|value| config::tree::Http::LOW_SPEED_LIMIT.try_into_u32(value)) |
| 186 | .transpose() | 187 | .transpose() |
| 187 | .with_leniency(lenient) | 188 | .with_leniency(lenient) |
| 188 | .map_err(|err| config::transport::http::Error::from(err))? | 189 | .map_err(config::transport::http::Error::from)? |
| 189 | .unwrap_or_default(); | 190 | .unwrap_or_default(); |
| 190 | opts.proxy = proxy( | 191 | opts.proxy = proxy( |
| 191 | remote_name | 192 | remote_name |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use std::convert::TryInto; | 2 | use std::convert::TryInto; |
| 2 | 3 | ||
| 3 | use git_hash::ObjectId; | 4 | use git_hash::ObjectId; |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use std::convert::TryInto; | 2 | use std::convert::TryInto; |
| 2 | 3 | ||
| 3 | use crate::{bstr::BStr, config, remote, remote::find, Remote}; | 4 | use crate::{bstr::BStr, config, remote, remote::find, Remote}; |
| @@ -33,6 +33,7 @@ impl crate::Repository { · 32 unmodified lines | |||
| 33 | /// | 33 | /// |
| 34 | /// Note that it might be the one that is currently open if this repository doesn't point to a linked worktree. | 34 | /// Note that it might be the one that is currently open if this repository doesn't point to a linked worktree. |
| 35 | /// Also note that the main repo might be bare. | 35 | /// Also note that the main repo might be bare. |
| 36 | #[allow(clippy::result_large_err)] | ||
| 36 | pub fn main_repo(&self) -> Result<crate::Repository, crate::open::Error> { | 37 | pub fn main_repo(&self) -> Result<crate::Repository, crate::open::Error> { |
| 37 | crate::ThreadSafeRepository::open_opts(self.common_dir(), self.options.clone()).map(Into::into) | 38 | crate::ThreadSafeRepository::open_opts(self.common_dir(), self.options.clone()).map(Into::into) |
| 38 | } | 39 | } |
| @@ -35,11 +35,11 @@ pub enum CandidateInfo { · 34 unmodified lines | |||
| 35 | impl std::fmt::Display for CandidateInfo { | 35 | impl std::fmt::Display for CandidateInfo { |
| 36 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 36 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 37 | match self { | 37 | match self { |
| 38 | CandidateInfo::FindError { source } => write!(f, "lookup error: {}", source), | 38 | CandidateInfo::FindError { source } => write!(f, "lookup error: {source}"), |
| 39 | CandidateInfo::Tag { name } => write!(f, "tag {:?}", name), | 39 | CandidateInfo::Tag { name } => write!(f, "tag {name:?}"), |
| 40 | CandidateInfo::Object { kind } => std::fmt::Display::fmt(kind, f), | 40 | CandidateInfo::Object { kind } => std::fmt::Display::fmt(kind, f), |
| 41 | CandidateInfo::Commit { date, title } => { | 41 | CandidateInfo::Commit { date, title } => { |
| 42 | write!(f, "commit {} {:?}", date.format(git_date::time::format::SHORT), title) | 42 | write!(f, "commit {} {title:?}", date.format(git_date::time::format::SHORT)) |
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use std::path::{Path, PathBuf}; | 2 | use std::path::{Path, PathBuf}; |
| 2 | 3 | ||
| 3 | use crate::{ | 4 | use crate::{ |
| @@ -1,3 +1,4 @@ | |||
| 1 | #![allow(clippy::result_large_err)] | ||
| 1 | use git_repository::{open, Repository, ThreadSafeRepository}; | 2 | use git_repository::{open, Repository, ThreadSafeRepository}; |
| 2 | use git_testtools::tempfile; | 3 | use git_testtools::tempfile; |
| 3 | 4 | ||
| @@ -88,7 +88,7 @@ impl<'a> Display for Format<'a> { · 87 unmodified lines | |||
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | if let Some(suffix) = &self.dirty_suffix { | 90 | if let Some(suffix) = &self.dirty_suffix { |
| 91 | write!(f, "-{}", suffix)?; | 91 | write!(f, "-{suffix}")?; |
| 92 | } | 92 | } |
| 93 | Ok(()) | 93 | Ok(()) |
| 94 | } | 94 | } |
| @@ -66,11 +66,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { · 65 unmodified lines | |||
| 66 | ); | 66 | ); |
| 67 | } | 67 | } |
| 68 | if let Err(err) = tmp.close() { | 68 | if let Err(err) = tmp.close() { |
| 69 | eprintln!("Error when removing tempdir: {}", err); | 69 | eprintln!("Error when removing tempdir: {err}"); |
| 70 | } | 70 | } |
| 71 | eprintln!( | 71 | eprintln!( |
| 72 | "OK: survived {}s without deadlock with {} tempfiles created, lock obtained {} times, cleanup handler ran {} times", | 72 | "OK: survived {secs_to_run}s without deadlock with {} tempfiles created, lock obtained {} times, cleanup handler ran {} times", |
| 73 | secs_to_run, | ||
| 74 | tempfiles_created.load(Ordering::SeqCst), | 73 | tempfiles_created.load(Ordering::SeqCst), |
| 75 | tempfiles_registry_locked.load(Ordering::SeqCst), | 74 | tempfiles_registry_locked.load(Ordering::SeqCst), |
| 76 | signal_raised.load(Ordering::SeqCst) | 75 | signal_raised.load(Ordering::SeqCst) |
| @@ -88,7 +87,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { · 11 unmodified lines | |||
| 88 | 87 | ||
| 89 | fn tempfile_for_thread_or_panic(tid: i32, tmp: &Path, count: &AtomicUsize) -> Handle<Writable> { | 88 | fn tempfile_for_thread_or_panic(tid: i32, tmp: &Path, count: &AtomicUsize) -> Handle<Writable> { |
| 90 | let res = git_tempfile::writable_at( | 89 | let res = git_tempfile::writable_at( |
| 91 | tmp.join(format!("thread-{}", tid)), | 90 | tmp.join(format!("thread-{tid}")), |
| 92 | ContainingDirectory::Exists, | 91 | ContainingDirectory::Exists, |
| 93 | AutoRemove::Tempfile, | 92 | AutoRemove::Tempfile, |
| 94 | ) | 93 | ) |
| @@ -63,8 +63,7 @@ mod error { · 62 unmodified lines | |||
| 63 | retries, | 63 | retries, |
| 64 | } => write!( | 64 | } => write!( |
| 65 | f, | 65 | f, |
| 66 | "Permanently failing to create directory {:?} ({:?} of {:?})", | 66 | "Permanently failing to create directory {dir:?} ({retries_left:?} of {retries:?})", |
| 67 | dir, retries_left, retries | ||
| 68 | ), | 67 | ), |
| 69 | } | 68 | } |
| 70 | } | 69 | } |
| @@ -20,10 +20,7 @@ impl<'a> Iter<'a> { · 19 unmodified lines | |||
| 20 | if !target.starts_with(boundary) { | 20 | if !target.starts_with(boundary) { |
| 21 | return Err(std::io::Error::new( | 21 | return Err(std::io::Error::new( |
| 22 | std::io::ErrorKind::InvalidInput, | 22 | std::io::ErrorKind::InvalidInput, |
| 23 | format!( | 23 | format!("Removal target {target:?} must be contained in boundary {boundary:?}"), |
| 24 | "Removal target {:?} must be contained in boundary {:?}", | ||
| 25 | target, boundary | ||
| 26 | ), | ||
| 27 | )); | 24 | )); |
| 28 | } | 25 | } |
| 29 | let cursor = if target == boundary { | 26 | let cursor = if target == boundary { |
| @@ -54,7 +54,7 @@ impl Handler { · 53 unmodified lines | |||
| 54 | }; | 54 | }; |
| 55 | match Self::parse_status_inner(data) { | 55 | match Self::parse_status_inner(data) { |
| 56 | Ok(status) if !(200..=valid_end).contains(&status) => { | 56 | Ok(status) if !(200..=valid_end).contains(&status) => { |
| 57 | Some((status, format!("Received HTTP status {}", status).into())) | 57 | Some((status, format!("Received HTTP status {status}").into())) |
| 58 | } | 58 | } |
| 59 | Ok(_) => None, | 59 | Ok(_) => None, |
| 60 | Err(err) => Some((500, err)), | 60 | Err(err) => Some((500, err)), |
| @@ -252,8 +252,7 @@ impl<H: Http> Transport<H> { · 251 unmodified lines | |||
| 252 | }) { | 252 | }) { |
| 253 | return Err(client::Error::Http(Error::Detail { | 253 | return Err(client::Error::Http(Error::Detail { |
| 254 | description: format!( | 254 | description: format!( |
| 255 | "Didn't find '{}' header to indicate 'smart' protocol, and 'dumb' protocol is not supported.", | 255 | "Didn't find '{wanted_content_type}' header to indicate 'smart' protocol, and 'dumb' protocol is not supported." |
| 256 | wanted_content_type | ||
| 257 | ), | 256 | ), |
| 258 | })); | 257 | })); |
| 259 | } | 258 | } |
| @@ -271,7 +270,7 @@ impl<H: Http> Transport<H> { · 11 unmodified lines | |||
| 271 | } | 270 | } |
| 272 | headers.push(Cow::Owned(format!( | 271 | headers.push(Cow::Owned(format!( |
| 273 | "Authorization: Basic {}", | 272 | "Authorization: Basic {}", |
| 274 | base64::engine::general_purpose::STANDARD.encode(format!("{}:{}", username, password)) | 273 | base64::engine::general_purpose::STANDARD.encode(format!("{username}:{password}")) |
| 275 | ))) | 274 | ))) |
| 276 | } | 275 | } |
| 277 | Ok(()) | 276 | Ok(()) |
| @@ -377,13 +376,13 @@ impl<H: Http> client::Transport for Transport<H> { · 99 unmodified lines | |||
| 377 | &extra_parameters | 376 | &extra_parameters |
| 378 | .iter() | 377 | .iter() |
| 379 | .map(|(key, value)| match value { | 378 | .map(|(key, value)| match value { |
| 380 | Some(value) => format!("{}={}", key, value), | 379 | Some(value) => format!("{key}={value}"), |
| 381 | None => key.to_string(), | 380 | None => key.to_string(), |
| 382 | }) | 381 | }) |
| 383 | .collect::<Vec<_>>() | 382 | .collect::<Vec<_>>() |
| 384 | .join(":"), | 383 | .join(":"), |
| 385 | ); | 384 | ); |
| 386 | dynamic_headers.push(format!("Git-Protocol: {}", parameters).into()); | 385 | dynamic_headers.push(format!("Git-Protocol: {parameters}").into()); |
| 387 | } | 386 | } |
| 388 | self.add_basic_auth_if_present(&mut dynamic_headers)?; | 387 | self.add_basic_auth_if_present(&mut dynamic_headers)?; |
| 389 | let GetResponse { headers, body } = | 388 | let GetResponse { headers, body } = |
| @@ -40,7 +40,7 @@ impl ProgramKind { · 39 unmodified lines | |||
| 40 | .env("GIT_PROTOCOL", format!("version={}", desired_version as usize)) | 40 | .env("GIT_PROTOCOL", format!("version={}", desired_version as usize)) |
| 41 | } | 41 | } |
| 42 | if let Some(port) = url.port { | 42 | if let Some(port) = url.port { |
| 43 | prepare = prepare.arg(format!("-p{}", port)); | 43 | prepare = prepare.arg(format!("-p{port}")); |
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| 46 | ProgramKind::Plink | ProgramKind::Putty | ProgramKind::TortoisePlink => { | 46 | ProgramKind::Plink | ProgramKind::Putty | ProgramKind::TortoisePlink => { |
| @@ -83,10 +83,10 @@ impl<T: Transport> TransportV2Ext for T { · 82 unmodified lines | |||
| 83 | arguments: Option<impl Iterator<Item = BString>>, | 83 | arguments: Option<impl Iterator<Item = BString>>, |
| 84 | ) -> Result<Box<dyn ExtendedBufRead + Unpin + '_>, Error> { | 84 | ) -> Result<Box<dyn ExtendedBufRead + Unpin + '_>, Error> { |
| 85 | let mut writer = self.request(WriteMode::OneLfTerminatedLinePerWriteCall, MessageKind::Flush)?; | 85 | let mut writer = self.request(WriteMode::OneLfTerminatedLinePerWriteCall, MessageKind::Flush)?; |
| 86 | writer.write_all(format!("command={}", command).as_bytes())?; | 86 | writer.write_all(format!("command={command}").as_bytes())?; |
| 87 | for (name, value) in capabilities { | 87 | for (name, value) in capabilities { |
| 88 | match value { | 88 | match value { |
| 89 | Some(value) => writer.write_all(format!("{}={}", name, value.as_ref()).as_bytes()), | 89 | Some(value) => writer.write_all(format!("{name}={}", value.as_ref()).as_bytes()), |
| 90 | None => writer.write_all(name.as_bytes()), | 90 | None => writer.write_all(name.as_bytes()), |
| 91 | }?; | 91 | }?; |
| 92 | } | 92 | } |
| @@ -64,7 +64,7 @@ mod message { · 63 unmodified lines | |||
| 64 | out.extend_from_slice(host.as_bytes()); | 64 | out.extend_from_slice(host.as_bytes()); |
| 65 | if let Some(port) = port { | 65 | if let Some(port) = port { |
| 66 | out.push_byte(b':'); | 66 | out.push_byte(b':'); |
| 67 | out.push_str(&format!("{}", port)); | 67 | out.push_str(&format!("{port}")); |
| 68 | } | 68 | } |
| 69 | out.push(0); | 69 | out.push(0); |
| 70 | } | 70 | } |
| @@ -87,7 +87,7 @@ mod message { · 16 unmodified lines | |||
| 87 | } | 87 | } |
| 88 | for (key, value) in extra_parameters { | 88 | for (key, value) in extra_parameters { |
| 89 | match value { | 89 | match value { |
| 90 | Some(value) => out.push_str(format!("{}={}", key, value)), | 90 | Some(value) => out.push_str(format!("{key}={value}")), |
| 91 | None => out.push_str(key), | 91 | None => out.push_str(key), |
| 92 | } | 92 | } |
| 93 | out.push(0); | 93 | out.push(0); |
| @@ -23,18 +23,18 @@ fn assert_error_status( · 22 unmodified lines | |||
| 23 | kind: std::io::ErrorKind, | 23 | kind: std::io::ErrorKind, |
| 24 | ) -> Result<(mock::Server, http::Transport<http::Impl>), crate::Error> { | 24 | ) -> Result<(mock::Server, http::Transport<http::Impl>), crate::Error> { |
| 25 | let (server, mut client) = | 25 | let (server, mut client) = |
| 26 | mock::serve_and_connect(&format!("http-{}.response", status), "path/not-important", Protocol::V1)?; | 26 | mock::serve_and_connect(&format!("http-{status}.response"), "path/not-important", Protocol::V1)?; |
| 27 | let error = client | 27 | let error = client |
| 28 | .handshake(Service::UploadPack, &[]) | 28 | .handshake(Service::UploadPack, &[]) |
| 29 | .err() | 29 | .err() |
| 30 | .expect("non-200 status causes error"); | 30 | .expect("non-200 status causes error"); |
| 31 | let error = error | 31 | let error = error |
| 32 | .source() | 32 | .source() |
| 33 | .unwrap_or_else(|| panic!("no source() in: {:?} ", error)) | 33 | .unwrap_or_else(|| panic!("no source() in: {error:?} ")) |
| 34 | .downcast_ref::<std::io::Error>() | 34 | .downcast_ref::<std::io::Error>() |
| 35 | .expect("io error as source"); | 35 | .expect("io error as source"); |
| 36 | assert_eq!(error.kind(), kind); | 36 | assert_eq!(error.kind(), kind); |
| 37 | let expected = format!("Received HTTP status {}", status); | 37 | let expected = format!("Received HTTP status {status}"); |
| 38 | assert_eq!(error.to_string().get(..expected.len()), Some(expected).as_deref()); | 38 | assert_eq!(error.to_string().get(..expected.len()), Some(expected).as_deref()); |
| 39 | drop(server.received()); | 39 | drop(server.received()); |
| 40 | Ok((server, client)) | 40 | Ok((server, client)) |
| @@ -28,7 +28,7 @@ impl From<ForUser> for Option<BString> { · 27 unmodified lines | |||
| 28 | pub enum Error { | 28 | pub enum Error { |
| 29 | #[error("UTF8 conversion on non-unix system failed for path: {path:?}")] | 29 | #[error("UTF8 conversion on non-unix system failed for path: {path:?}")] |
| 30 | IllformedUtf8 { path: BString }, | 30 | IllformedUtf8 { path: BString }, |
| 31 | #[error("Home directory could not be obtained for {}", match user {Some(user) => format!("user '{}'", user), None => "current user".into()})] | 31 | #[error("Home directory could not be obtained for {}", match user {Some(user) => format!("user '{user}'"), None => "current user".into()})] |
| 32 | MissingHome { user: Option<BString> }, | 32 | MissingHome { user: Option<BString> }, |
| 33 | } | 33 | } |
| 34 | 34 | ||
| @@ -188,7 +188,7 @@ impl Url { · 187 unmodified lines | |||
| 188 | (Some(_user), None) => unreachable!("BUG: should not be possible to have a user but no host"), | 188 | (Some(_user), None) => unreachable!("BUG: should not be possible to have a user but no host"), |
| 189 | }; | 189 | }; |
| 190 | if let Some(port) = &self.port { | 190 | if let Some(port) = &self.port { |
| 191 | write!(&mut out, ":{}", port)?; | 191 | write!(&mut out, ":{port}")?; |
| 192 | } | 192 | } |
| 193 | if self.serialize_alternative_form && self.scheme == Scheme::Ssh { | 193 | if self.serialize_alternative_form && self.scheme == Scheme::Ssh { |
| 194 | out.write_all(b":")?; | 194 | out.write_all(b":")?; |
| @@ -21,7 +21,7 @@ fn user_home(name: &str) -> std::path::PathBuf { · 20 unmodified lines | |||
| 21 | #[cfg(not(windows))] | 21 | #[cfg(not(windows))] |
| 22 | fn user_home(name: &str) -> std::path::PathBuf { | 22 | fn user_home(name: &str) -> std::path::PathBuf { |
| 23 | #[cfg(not(windows))] | 23 | #[cfg(not(windows))] |
| 24 | format!("/home/{}", name).into() | 24 | format!("/home/{name}").into() |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | #[test] | 27 | #[test] |
| @@ -29,7 +29,7 @@ fn without_username() -> crate::Result { · 1 unmodified line | |||
| 29 | let (user, resolved_path) = expand_path::parse(b"/~/hello/git".as_bstr())?; | 29 | let (user, resolved_path) = expand_path::parse(b"/~/hello/git".as_bstr())?; |
| 30 | let resolved_path = expand_path::with(user.as_ref(), resolved_path.as_ref(), |user: &ForUser| match user { | 30 | let resolved_path = expand_path::with(user.as_ref(), resolved_path.as_ref(), |user: &ForUser| match user { |
| 31 | ForUser::Current => Some(user_home("byron")), | 31 | ForUser::Current => Some(user_home("byron")), |
| 32 | ForUser::Name(name) => Some(format!("/home/{}", name).into()), | 32 | ForUser::Name(name) => Some(format!("/home/{name}").into()), |
| 33 | })?; | 33 | })?; |
| 34 | assert_eq!(resolved_path, expected_path()); | 34 | assert_eq!(resolved_path, expected_path()); |
| 35 | Ok(()) | 35 | Ok(()) |
| @@ -231,10 +231,10 @@ impl State { · 230 unmodified lines | |||
| 231 | /// - ignores entries which aren't blobs | 231 | /// - ignores entries which aren't blobs |
| 232 | /// - ignores ignore entries which are not skip-worktree | 232 | /// - ignores ignore entries which are not skip-worktree |
| 233 | /// - within merges, picks 'our' stage both for ignore and attribute files. | 233 | /// - within merges, picks 'our' stage both for ignore and attribute files. |
| 234 | pub fn build_attribute_list<'paths>( | 234 | pub fn build_attribute_list( |
| 235 | &self, | 235 | &self, |
| 236 | index: &git_index::State, | 236 | index: &git_index::State, |
| 237 | paths: &'paths git_index::PathStorageRef, | 237 | paths: &git_index::PathStorageRef, |
| 238 | case: Case, | 238 | case: Case, |
| 239 | ) -> Vec<PathOidMapping> { | 239 | ) -> Vec<PathOidMapping> { |
| 240 | let a1_backing; | 240 | let a1_backing; |
| @@ -183,7 +183,7 @@ pub fn spawn_git_daemon(working_dir: impl AsRef<Path>) -> std::io::Result<GitDae · 182 unmodified lines | |||
| 183 | } | 183 | } |
| 184 | Ok(GitDaemon { | 184 | Ok(GitDaemon { |
| 185 | child, | 185 | child, |
| 186 | url: format!("git://{}", server_addr), | 186 | url: format!("git://{server_addr}"), |
| 187 | }) | 187 | }) |
| 188 | } | 188 | } |
| 189 | 189 | ||