diff --git a/git-discover/src/upwards/types.rs b/git-discover/src/upwards/types.rs index da36839b8ff..1a2261bd4d3 100644 --- a/git-discover/src/upwards/types.rs +++ b/git-discover/src/upwards/types.rs @@ -1,5 +1,4 @@ -use std::ffi::OsStr; -use std::{env, path::PathBuf}; +use std::{env, ffi::OsStr, path::PathBuf}; /// The error returned by [git_discover::upwards()][crate::upwards()]. #[derive(Debug, thiserror::Error)] diff --git a/git-features/src/progress.rs b/git-features/src/progress.rs index 2be6b495ae3..e6fc657d6d4 100644 --- a/git-features/src/progress.rs +++ b/git-features/src/progress.rs @@ -3,8 +3,7 @@ use std::io; pub use prodash::{ messages::MessageLevel, - progress::Id, - progress::{Discard, DoOrDiscard, Either, Step, StepShared, ThroughputOnDrop, UNKNOWN}, + progress::{Discard, DoOrDiscard, Either, Id, Step, StepShared, ThroughputOnDrop, UNKNOWN}, unit, Progress, Unit, }; diff --git a/git-index/src/access/mod.rs b/git-index/src/access/mod.rs index 6c547cab2f3..d9c8538688f 100644 --- a/git-index/src/access/mod.rs +++ b/git-index/src/access/mod.rs @@ -1,6 +1,7 @@ -use bstr::{BStr, ByteSlice, ByteVec}; use std::cmp::Ordering; +use bstr::{BStr, ByteSlice, ByteVec}; + use crate::{entry, extension, Entry, PathStorage, State, Version}; // TODO: integrate this somehow, somewhere, depending on later usage. diff --git a/git-index/src/entry/mod.rs b/git-index/src/entry/mod.rs index 41af79f7697..165df801e6d 100644 --- a/git-index/src/entry/mod.rs +++ b/git-index/src/entry/mod.rs @@ -64,14 +64,11 @@ mod access { } mod _impls { - use std::cmp::Ordering; - use std::ops::Add; - use std::time::SystemTime; + use std::{cmp::Ordering, ops::Add, time::SystemTime}; use bstr::BStr; - use crate::entry::Time; - use crate::{Entry, State}; + use crate::{entry::Time, Entry, State}; impl From for Time { fn from(s: SystemTime) -> Self { diff --git a/git-index/src/file/mod.rs b/git-index/src/file/mod.rs index e7025593f36..6fa3f2ff507 100644 --- a/git-index/src/file/mod.rs +++ b/git-index/src/file/mod.rs @@ -19,9 +19,10 @@ mod impls { } mod impl_ { - use crate::{File, State}; use std::fmt::Formatter; + use crate::{File, State}; + impl std::fmt::Debug for File { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.debug_struct("File") @@ -66,9 +67,10 @@ mod access { } mod mutation { - use crate::File; use std::path::PathBuf; + use crate::File; + /// Mutating access impl File { /// Set the path at which we think we are located to the given `path`. diff --git a/git-index/src/lib.rs b/git-index/src/lib.rs index 78ebd6d18b2..d0bcad182f9 100644 --- a/git-index/src/lib.rs +++ b/git-index/src/lib.rs @@ -9,7 +9,6 @@ use std::{ops::Range, path::PathBuf}; use filetime::FileTime; - pub use git_hash as hash; /// @@ -110,9 +109,10 @@ pub struct State { } mod impls { - use crate::State; use std::fmt::{Debug, Formatter}; + use crate::State; + impl Debug for State { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { for entry in &self.entries { diff --git a/git-index/tests/index/entry.rs b/git-index/tests/index/entry.rs index cbb86f9cea4..6570c14ba51 100644 --- a/git-index/tests/index/entry.rs +++ b/git-index/tests/index/entry.rs @@ -1,7 +1,8 @@ mod time { - use git_index::entry; use std::time::SystemTime; + use git_index::entry; + #[test] fn conversion_roundtrip() { for sample in [entry::Time::default(), entry::Time { secs: 42, nsecs: 150 }] { diff --git a/git-index/tests/index/file/read.rs b/git-index/tests/index/file/read.rs index efb5f3989b0..f8c33ae924c 100644 --- a/git-index/tests/index/file/read.rs +++ b/git-index/tests/index/file/read.rs @@ -1,13 +1,12 @@ use std::path::{Path, PathBuf}; -use crate::hex_to_id; use bstr::ByteSlice; use git_index::{ entry::{self, Flags, Mode}, Version, }; -use crate::loose_file_path; +use crate::{hex_to_id, loose_file_path}; fn verify(index: git_index::File) -> git_index::File { index.verify_integrity().unwrap(); diff --git a/git-index/tests/index/mod.rs b/git-index/tests/index/mod.rs index 4931c99f0ce..ecb77ba19af 100644 --- a/git-index/tests/index/mod.rs +++ b/git-index/tests/index/mod.rs @@ -1,6 +1,7 @@ -use git_hash::ObjectId; use std::path::{Path, PathBuf}; +use git_hash::ObjectId; + mod access; mod entry; mod file; diff --git a/git-odb/src/store_impls/dynamic/verify.rs b/git-odb/src/store_impls/dynamic/verify.rs index 619d57fa241..f3107c9f486 100644 --- a/git-odb/src/store_impls/dynamic/verify.rs +++ b/git-odb/src/store_impls/dynamic/verify.rs @@ -14,8 +14,7 @@ use crate::{ /// pub mod integrity { - use std::marker::PhantomData; - use std::path::PathBuf; + use std::{marker::PhantomData, path::PathBuf}; use crate::pack; diff --git a/git-odb/tests/odb/store/dynamic.rs b/git-odb/tests/odb/store/dynamic.rs index 3471df42384..c7989562c61 100644 --- a/git-odb/tests/odb/store/dynamic.rs +++ b/git-odb/tests/odb/store/dynamic.rs @@ -4,8 +4,7 @@ use git_hash::ObjectId; use git_odb::{store, store::iter::Ordering, Find, FindExt, Header, Write}; use git_testtools::fixture_path; -use crate::hex_to_id; -use crate::odb::db; +use crate::{hex_to_id, odb::db}; fn all_orderings() -> [Ordering; 2] { [ diff --git a/git-odb/tests/odb/store/loose.rs b/git-odb/tests/odb/store/loose.rs index 1f088b27ced..e86273ed45a 100644 --- a/git-odb/tests/odb/store/loose.rs +++ b/git-odb/tests/odb/store/loose.rs @@ -90,8 +90,7 @@ mod lookup_prefix { use git_testtools::fixture_path; use maplit::hashset; - use crate::odb::hex_to_id; - use crate::store::loose::ldb; + use crate::{odb::hex_to_id, store::loose::ldb}; #[test] fn returns_none_for_prefixes_without_any_match() { @@ -330,8 +329,7 @@ cjHJZXWmV4CcRfmLsXzU8s2cR9A0DBvOxhPD1TlKC2JhBFXigjuL9U4Rbq9tdegB } mod header { - use crate::odb::hex_to_id; - use crate::odb::store::loose::ldb; + use crate::odb::{hex_to_id, store::loose::ldb}; #[test] fn existing() -> crate::Result { diff --git a/git-pack/src/bundle/write/mod.rs b/git-pack/src/bundle/write/mod.rs index 1e07f62fdb0..195566bdf4a 100644 --- a/git-pack/src/bundle/write/mod.rs +++ b/git-pack/src/bundle/write/mod.rs @@ -1,7 +1,7 @@ -use std::marker::PhantomData; use std::{ io, io::Write, + marker::PhantomData, path::{Path, PathBuf}, sync::{atomic::AtomicBool, Arc}, }; diff --git a/git-pack/src/index/traverse/types.rs b/git-pack/src/index/traverse/types.rs index ef3aab25647..7b1f2ddf24d 100644 --- a/git-pack/src/index/traverse/types.rs +++ b/git-pack/src/index/traverse/types.rs @@ -1,5 +1,4 @@ -use std::collections::BTreeMap; -use std::marker::PhantomData; +use std::{collections::BTreeMap, marker::PhantomData}; /// Statistics regarding object encountered during execution of the [`traverse()`][crate::index::File::traverse()] method. #[derive(Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Clone)] diff --git a/git-pack/src/index/traverse/with_lookup.rs b/git-pack/src/index/traverse/with_lookup.rs index 9f762a76296..df3606f9c8d 100644 --- a/git-pack/src/index/traverse/with_lookup.rs +++ b/git-pack/src/index/traverse/with_lookup.rs @@ -3,13 +3,14 @@ use std::sync::atomic::{AtomicBool, Ordering}; use git_features::{ parallel::{self, in_parallel_if}, progress::{self, unit, Progress}, + threading::{lock, Mutable, OwnShared}, }; use super::{Error, Reducer}; -use crate::{data, index, index::util}; - -use crate::index::traverse::Outcome; -use git_features::threading::{lock, Mutable, OwnShared}; +use crate::{ + data, index, + index::{traverse::Outcome, util}, +}; /// Traversal options for [`index::File::traverse_with_lookup()`] pub struct Options { diff --git a/git-pack/src/index/verify.rs b/git-pack/src/index/verify.rs index 31079be7c65..69084875de8 100644 --- a/git-pack/src/index/verify.rs +++ b/git-pack/src/index/verify.rs @@ -7,9 +7,10 @@ use crate::index; /// pub mod integrity { - use git_object::bstr::BString; use std::marker::PhantomData; + use git_object::bstr::BString; + /// Returned by [`index::File::verify_integrity()`][crate::index::File::verify_integrity()]. #[derive(thiserror::Error, Debug)] #[allow(missing_docs)] diff --git a/git-pack/tests/pack/data/file.rs b/git-pack/tests/pack/data/file.rs index c0568f335da..337bf9075ad 100644 --- a/git-pack/tests/pack/data/file.rs +++ b/git-pack/tests/pack/data/file.rs @@ -9,10 +9,12 @@ fn pack_at(at: &str) -> pack::data::File { mod method { use std::sync::atomic::AtomicBool; - use crate::hex_to_id; use git_features::progress; - use crate::pack::{data::file::pack_at, SMALL_PACK}; + use crate::{ + hex_to_id, + pack::{data::file::pack_at, SMALL_PACK}, + }; #[test] fn checksum() { diff --git a/git-pack/tests/pack/multi_index/access.rs b/git-pack/tests/pack/multi_index/access.rs index 9ff74daa2ee..7b5dac7f5bd 100644 --- a/git-pack/tests/pack/multi_index/access.rs +++ b/git-pack/tests/pack/multi_index/access.rs @@ -1,8 +1,7 @@ use std::path::PathBuf; -use crate::hex_to_id; - use super::multi_index; +use crate::hex_to_id; #[test] fn lookup_with_ambiguity() { diff --git a/git-pack/tests/pack/multi_index/write.rs b/git-pack/tests/pack/multi_index/write.rs index d9e8c55e40a..cf728c98042 100644 --- a/git-pack/tests/pack/multi_index/write.rs +++ b/git-pack/tests/pack/multi_index/write.rs @@ -1,9 +1,10 @@ use std::{path::PathBuf, sync::atomic::AtomicBool}; -use crate::hex_to_id; use git_features::progress; use git_testtools::fixture_path_standalone; +use crate::hex_to_id; + #[test] fn from_paths() -> crate::Result { let dir = tempfile::TempDir::new()?; diff --git a/git-ref/tests/file/reference.rs b/git-ref/tests/file/reference.rs index ddf4635448c..7e099435004 100644 --- a/git-ref/tests/file/reference.rs +++ b/git-ref/tests/file/reference.rs @@ -47,11 +47,10 @@ mod reflog { } mod peel { - use crate::util::hex_to_id; use git_odb::pack::Find; use git_ref::{file::ReferenceExt, peel, Reference}; - use crate::{file, file::store_with_packed_refs}; + use crate::{file, file::store_with_packed_refs, util::hex_to_id}; #[test] fn one_level() -> crate::Result { @@ -180,10 +179,11 @@ mod parse { mktest!(ref_tag, b"reff: hello", "\"reff: hello\" could not be parsed"); } mod valid { - use crate::util::hex_to_id; use git_object::bstr::ByteSlice; use git_ref::file::loose::Reference; + use crate::util::hex_to_id; + macro_rules! mktest { ($name:ident, $input:literal, $kind:path, $id:expr, $ref:expr) => { #[test] diff --git a/git-ref/tests/file/store/find.rs b/git-ref/tests/file/store/find.rs index 1e05292be8d..7ed36c15790 100644 --- a/git-ref/tests/file/store/find.rs +++ b/git-ref/tests/file/store/find.rs @@ -3,8 +3,7 @@ mod existing { use git_ref::{PartialName, PartialNameRef}; - use crate::file::store_at; - use crate::util::hex_to_id; + use crate::{file::store_at, util::hex_to_id}; #[test] fn with_packed_refs() -> crate::Result { diff --git a/git-ref/tests/file/store/iter.rs b/git-ref/tests/file/store/iter.rs index 836ec736226..17da7574d7e 100644 --- a/git-ref/tests/file/store/iter.rs +++ b/git-ref/tests/file/store/iter.rs @@ -2,8 +2,10 @@ use std::convert::TryInto; use git_object::bstr::ByteSlice; -use crate::file::{store, store_at, store_with_packed_refs}; -use crate::util::hex_to_id; +use crate::{ + file::{store, store_at, store_with_packed_refs}, + util::hex_to_id, +}; mod with_namespace { use git_object::bstr::{BString, ByteSlice}; diff --git a/git-ref/tests/file/transaction/prepare_and_commit/delete.rs b/git-ref/tests/file/transaction/prepare_and_commit/delete.rs index 7162edc996a..725408e74da 100644 --- a/git-ref/tests/file/transaction/prepare_and_commit/delete.rs +++ b/git-ref/tests/file/transaction/prepare_and_commit/delete.rs @@ -1,6 +1,5 @@ use std::convert::TryInto; -use crate::util::hex_to_id; use git_lock::acquire::Fail; use git_ref::{ file::ReferenceExt, @@ -8,9 +7,12 @@ use git_ref::{ Reference, Target, }; -use crate::file::{ - store_writable, - transaction::prepare_and_commit::{committer, empty_store}, +use crate::{ + file::{ + store_writable, + transaction::prepare_and_commit::{committer, empty_store}, + }, + util::hex_to_id, }; #[test] diff --git a/git-ref/tests/file/worktree.rs b/git-ref/tests/file/worktree.rs index 1cac900d017..660a6590463 100644 --- a/git-ref/tests/file/worktree.rs +++ b/git-ref/tests/file/worktree.rs @@ -193,7 +193,6 @@ mod read_only { mod writable { use std::convert::TryInto; - use crate::util::hex_to_id; use git_lock::acquire::Fail; use git_ref::{ file::{transaction::PackedRefs, Store}, @@ -201,9 +200,12 @@ mod writable { FullName, FullNameRef, Target, }; - use crate::file::{ - transaction::prepare_and_commit::committer, - worktree::{main_store, worktree_store, Mode}, + use crate::{ + file::{ + transaction::prepare_and_commit::committer, + worktree::{main_store, worktree_store, Mode}, + }, + util::hex_to_id, }; fn change_with_id(id: git_hash::ObjectId) -> Change { diff --git a/git-ref/tests/transaction/mod.rs b/git-ref/tests/transaction/mod.rs index 2d62e43cb44..bf8f28f5176 100644 --- a/git-ref/tests/transaction/mod.rs +++ b/git-ref/tests/transaction/mod.rs @@ -98,13 +98,12 @@ mod refedit_ext { mod splitting { use std::{cell::Cell, convert::TryInto}; - use crate::util::hex_to_id; use git_ref::{ transaction::{Change, LogChange, PreviousValue, RefEdit, RefEditsExt, RefLog}, FullNameRef, PartialNameRef, Target, }; - use crate::transaction::refedit_ext::MockStore; + use crate::{transaction::refedit_ext::MockStore, util::hex_to_id}; fn find<'a>(edits: &'a [RefEdit], name: &str) -> &'a RefEdit { let name: &FullNameRef = name.try_into().unwrap(); diff --git a/git-repository/src/config/cache/access.rs b/git-repository/src/config/cache/access.rs index 0b67947b63d..20f1f29cd9f 100644 --- a/git-repository/src/config/cache/access.rs +++ b/git-repository/src/config/cache/access.rs @@ -2,12 +2,15 @@ use std::{borrow::Cow, path::PathBuf, time::Duration}; use git_lock::acquire::Fail; -use crate::config::cache::util::ApplyLeniency; -use crate::config::tree::{Checkout, Core, Key}; use crate::{ bstr::BStr, config, - config::{cache::util::ApplyLeniencyDefault, checkout_options, Cache}, + config::{ + cache::util::{ApplyLeniency, ApplyLeniencyDefault}, + checkout_options, + tree::{Checkout, Core, Key}, + Cache, + }, remote, repository::identity, }; diff --git a/git-repository/src/config/cache/init.rs b/git-repository/src/config/cache/init.rs index df8dd72e489..18b7c4abd53 100644 --- a/git-repository/src/config/cache/init.rs +++ b/git-repository/src/config/cache/init.rs @@ -3,11 +3,14 @@ use std::borrow::Cow; use git_sec::Permission; use super::{interpolate_context, util, Error, StageOne}; -use crate::config::tree::{gitoxide, Core, Http}; use crate::{ bstr::BString, config, - config::{cache::util::ApplyLeniency, Cache}, + config::{ + cache::util::ApplyLeniency, + tree::{gitoxide, Core, Http}, + Cache, + }, repository, }; diff --git a/git-repository/src/config/cache/util.rs b/git-repository/src/config/cache/util.rs index c0122c9d5a2..91ff46cb731 100644 --- a/git-repository/src/config/cache/util.rs +++ b/git-repository/src/config/cache/util.rs @@ -1,7 +1,9 @@ use super::Error; -use crate::config; -use crate::config::tree::{gitoxide, Core}; -use crate::revision::spec::parse::ObjectKindHint; +use crate::{ + config, + config::tree::{gitoxide, Core}, + revision::spec::parse::ObjectKindHint, +}; pub(crate) fn interpolate_context<'a>( git_install_dir: Option<&'a std::path::Path>, diff --git a/git-repository/src/config/snapshot/credential_helpers.rs b/git-repository/src/config/snapshot/credential_helpers.rs index 19303cfac90..d91443bba92 100644 --- a/git-repository/src/config/snapshot/credential_helpers.rs +++ b/git-repository/src/config/snapshot/credential_helpers.rs @@ -2,10 +2,12 @@ use std::{borrow::Cow, convert::TryFrom}; pub use error::Error; -use crate::config::tree::{credential, Core, Credential, Key}; use crate::{ bstr::{ByteSlice, ByteVec}, - config::Snapshot, + config::{ + tree::{credential, Core, Credential, Key}, + Snapshot, + }, }; mod error { diff --git a/git-repository/src/config/tree/keys.rs b/git-repository/src/config/tree/keys.rs index d458e1997c5..c6465425b2f 100644 --- a/git-repository/src/config/tree/keys.rs +++ b/git-repository/src/config/tree/keys.rs @@ -1,9 +1,14 @@ -use crate::bstr::BStr; -use crate::config; -use crate::config::tree::{Key, Link, Note, Section, SubSectionRequirement}; -use std::borrow::Cow; -use std::error::Error; -use std::fmt::{Debug, Formatter}; +use std::{ + borrow::Cow, + error::Error, + fmt::{Debug, Formatter}, +}; + +use crate::{ + bstr::BStr, + config, + config::tree::{Key, Link, Note, Section, SubSectionRequirement}, +}; /// Implements a value without any constraints, i.e. a any value. pub struct Any { @@ -180,11 +185,13 @@ pub type PushRefSpec = Any; pub type FetchRefSpec = Any; mod duration { - use crate::config; - use crate::config::tree::keys::DurationInMilliseconds; - use crate::config::tree::Section; use std::time::Duration; + use crate::{ + config, + config::tree::{keys::DurationInMilliseconds, Section}, + }; + impl DurationInMilliseconds { /// Create a new instance. pub const fn new_duration(name: &'static str, section: &'static dyn Section) -> Self { @@ -206,12 +213,15 @@ mod duration { } mod lock_timeout { - use crate::config; - use crate::config::tree::keys::LockTimeout; - use crate::config::tree::Section; - use git_lock::acquire::Fail; use std::time::Duration; + use git_lock::acquire::Fail; + + use crate::{ + config, + config::tree::{keys::LockTimeout, Section}, + }; + impl LockTimeout { /// Create a new instance. pub const fn new_lock_timeout(name: &'static str, section: &'static dyn Section) -> Self { @@ -236,8 +246,10 @@ mod lock_timeout { } mod refspecs { - use crate::config::tree::keys::{validate, FetchRefSpec, PushRefSpec}; - use crate::config::tree::Section; + use crate::config::tree::{ + keys::{validate, FetchRefSpec, PushRefSpec}, + Section, + }; impl PushRefSpec { /// Create a new instance. @@ -255,12 +267,17 @@ mod refspecs { } mod url { - use crate::bstr::BStr; - use crate::config; - use crate::config::tree::keys::{validate, Url}; - use crate::config::tree::Section; use std::borrow::Cow; + use crate::{ + bstr::BStr, + config, + config::tree::{ + keys::{validate, Url}, + Section, + }, + }; + impl Url { /// Create a new instance. pub const fn new_url(name: &'static str, section: &'static dyn Section) -> Self { @@ -304,8 +321,7 @@ impl Path { } mod workers { - use crate::config::tree::keys::UnsignedInteger; - use crate::config::tree::Section; + use crate::config::tree::{keys::UnsignedInteger, Section}; impl UnsignedInteger { /// Create a new instance. @@ -358,11 +374,16 @@ mod workers { } mod time { - use crate::bstr::{BStr, ByteSlice}; - use crate::config::tree::keys::{validate, Time}; - use crate::config::tree::Section; use std::borrow::Cow; + use crate::{ + bstr::{BStr, ByteSlice}, + config::tree::{ + keys::{validate, Time}, + Section, + }, + }; + impl Time { /// Create a new instance. pub const fn new_time(name: &'static str, section: &'static dyn Section) -> Self { @@ -389,9 +410,13 @@ mod time { } mod boolean { - use crate::config; - use crate::config::tree::keys::{validate, Boolean}; - use crate::config::tree::Section; + use crate::{ + config, + config::tree::{ + keys::{validate, Boolean}, + Section, + }, + }; impl Boolean { /// Create a new instance. @@ -412,12 +437,14 @@ mod boolean { } mod remote_name { - use crate::bstr::{BStr, BString}; - use crate::config; - use crate::config::tree::keys::RemoteName; - use crate::config::tree::Section; use std::borrow::Cow; + use crate::{ + bstr::{BStr, BString}, + config, + config::tree::{keys::RemoteName, Section}, + }; + impl RemoteName { /// Create a new instance. pub const fn new_remote_name(name: &'static str, section: &'static dyn Section) -> Self { @@ -443,11 +470,13 @@ pub trait Validate { /// various implementations of the `Validate` trait. pub mod validate { - use crate::bstr::{BStr, ByteSlice}; - use crate::config::tree::keys::Validate; - use crate::remote; - use std::borrow::Cow; - use std::error::Error; + use std::{borrow::Cow, error::Error}; + + use crate::{ + bstr::{BStr, ByteSlice}, + config::tree::keys::Validate, + remote, + }; /// Everything is valid. #[derive(Default)] diff --git a/git-repository/src/config/tree/sections/author.rs b/git-repository/src/config/tree/sections/author.rs index 8e2a8bcf956..4101e3817f6 100644 --- a/git-repository/src/config/tree/sections/author.rs +++ b/git-repository/src/config/tree/sections/author.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{gitoxide, keys, Author, Key, Section}; +use crate::{ + config, + config::tree::{gitoxide, keys, Author, Key, Section}, +}; impl Author { /// The `author.name` key. diff --git a/git-repository/src/config/tree/sections/branch.rs b/git-repository/src/config/tree/sections/branch.rs index 6abedf8b4b4..9cd2dfa7d91 100644 --- a/git-repository/src/config/tree/sections/branch.rs +++ b/git-repository/src/config/tree/sections/branch.rs @@ -1,5 +1,4 @@ -use crate::config::tree::traits::SubSectionRequirement; -use crate::config::tree::{keys, Branch, Key, Section}; +use crate::config::tree::{keys, traits::SubSectionRequirement, Branch, Key, Section}; const NAME_PARAMETER: Option = Some(SubSectionRequirement::Parameter("name")); @@ -30,11 +29,12 @@ impl Section for Branch { pub type Merge = keys::Any; mod merge { - use crate::bstr::BStr; - use crate::config::tree::branch::Merge; - use git_ref::FullNameRef; use std::borrow::Cow; + use git_ref::FullNameRef; + + use crate::{bstr::BStr, config::tree::branch::Merge}; + impl Merge { /// Return the validated full ref name from `value` if it is valid. pub fn try_into_fullrefname( @@ -50,9 +50,10 @@ mod merge { /// pub mod validate { - use crate::bstr::BStr; - use crate::config::tree::branch::Merge; - use crate::config::tree::keys; + use crate::{ + bstr::BStr, + config::tree::{branch::Merge, keys}, + }; pub struct FullNameRef; impl keys::Validate for FullNameRef { diff --git a/git-repository/src/config/tree/sections/checkout.rs b/git-repository/src/config/tree/sections/checkout.rs index 1a12c83235b..f8c49bb543f 100644 --- a/git-repository/src/config/tree/sections/checkout.rs +++ b/git-repository/src/config/tree/sections/checkout.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{keys, Checkout, Key, Section}; +use crate::{ + config, + config::tree::{keys, Checkout, Key, Section}, +}; impl Checkout { /// The `checkout.workers` key. @@ -41,8 +43,7 @@ mod workers { /// pub mod validate { - use crate::bstr::BStr; - use crate::config::tree::keys; + use crate::{bstr::BStr, config::tree::keys}; pub struct Workers; impl keys::Validate for Workers { diff --git a/git-repository/src/config/tree/sections/clone.rs b/git-repository/src/config/tree/sections/clone.rs index abf7291e0d6..616185a0b71 100644 --- a/git-repository/src/config/tree/sections/clone.rs +++ b/git-repository/src/config/tree/sections/clone.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{keys, Clone, Key, Section}; +use crate::{ + config, + config::tree::{keys, Clone, Key, Section}, +}; impl Clone { /// The `clone.defaultRemoteName` key. diff --git a/git-repository/src/config/tree/sections/committer.rs b/git-repository/src/config/tree/sections/committer.rs index ca1fb70d204..acc25c930dd 100644 --- a/git-repository/src/config/tree/sections/committer.rs +++ b/git-repository/src/config/tree/sections/committer.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{gitoxide, keys, Committer, Key, Section}; +use crate::{ + config, + config::tree::{gitoxide, keys, Committer, Key, Section}, +}; impl Committer { /// The `committer.name` key. diff --git a/git-repository/src/config/tree/sections/core.rs b/git-repository/src/config/tree/sections/core.rs index 4797f785502..95ba0ae3f70 100644 --- a/git-repository/src/config/tree/sections/core.rs +++ b/git-repository/src/config/tree/sections/core.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{keys, Core, Key, Section}; +use crate::{ + config, + config::tree::{keys, Core, Key, Section}, +}; impl Core { /// The `core.abbrev` key. @@ -107,12 +109,10 @@ pub type LogAllRefUpdates = keys::Any; pub type Disambiguate = keys::Any; mod disambiguate { - use crate::bstr::BStr; - use crate::config; - use crate::config::tree::core::Disambiguate; - use crate::revision::spec::parse::ObjectKindHint; use std::borrow::Cow; + use crate::{bstr::BStr, config, config::tree::core::Disambiguate, revision::spec::parse::ObjectKindHint}; + impl Disambiguate { /// Convert a disambiguation marker into the respective enum. pub fn try_into_object_kind_hint<'a>( @@ -134,11 +134,10 @@ mod disambiguate { } mod log_all_ref_updates { - use crate::bstr::BStr; - use crate::config; - use crate::config::tree::core::LogAllRefUpdates; use std::borrow::Cow; + use crate::{bstr::BStr, config, config::tree::core::LogAllRefUpdates}; + impl LogAllRefUpdates { /// Returns the mode for ref-updates as parsed from `value`. If `value` is not a boolean, `string_on_failure` will be called /// to obtain the key `core.logAllRefUpdates` as string instead. For correctness, this two step process is necessary as @@ -165,11 +164,10 @@ mod log_all_ref_updates { } mod check_stat { - use crate::bstr::BStr; - use crate::config; - use crate::config::tree::core::CheckStat; use std::borrow::Cow; + use crate::{bstr::BStr, config, config::tree::core::CheckStat}; + impl CheckStat { /// Returns true if the full set of stat entries should be checked, and it's just as lenient as git. pub fn try_into_checkstat( @@ -188,12 +186,16 @@ mod check_stat { } mod abbrev { - use crate::bstr::{BStr, ByteSlice}; - use crate::config; - use crate::config::tree::core::Abbrev; - use config::abbrev::Error; use std::borrow::Cow; + use config::abbrev::Error; + + use crate::{ + bstr::{BStr, ByteSlice}, + config, + config::tree::core::Abbrev, + }; + impl Abbrev { /// Convert the given `hex_len_str` into the amount of characters that a short hash should have. /// If `None` is returned, the correct value can be determined based on the amount of objects in the repo. @@ -240,8 +242,7 @@ mod abbrev { } mod validate { - use crate::bstr::BStr; - use crate::config::tree::keys; + use crate::{bstr::BStr, config::tree::keys}; pub struct LockTimeout; impl keys::Validate for LockTimeout { diff --git a/git-repository/src/config/tree/sections/credential.rs b/git-repository/src/config/tree/sections/credential.rs index 15dbe048bb9..d370db0c5ce 100644 --- a/git-repository/src/config/tree/sections/credential.rs +++ b/git-repository/src/config/tree/sections/credential.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{keys, Credential, Key, Section}; +use crate::{ + config, + config::tree::{keys, Credential, Key, Section}, +}; impl Credential { /// The `credential.helper` key. diff --git a/git-repository/src/config/tree/sections/diff.rs b/git-repository/src/config/tree/sections/diff.rs index 490d5af48a5..6aee697e333 100644 --- a/git-repository/src/config/tree/sections/diff.rs +++ b/git-repository/src/config/tree/sections/diff.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{keys, Diff, Key, Section}; +use crate::{ + config, + config::tree::{keys, Diff, Key, Section}, +}; impl Diff { /// The `diff.algorithm` key. @@ -21,12 +23,14 @@ impl Section for Diff { pub type Algorithm = keys::Any; mod algorithm { - use crate::bstr::BStr; - use crate::config; - use crate::config::diff::algorithm::Error; - use crate::config::tree::sections::diff::Algorithm; use std::borrow::Cow; + use crate::{ + bstr::BStr, + config, + config::{diff::algorithm::Error, tree::sections::diff::Algorithm}, + }; + impl Algorithm { /// Derive the diff algorithm identified by `name`, case-insensitively. pub fn try_into_algorithm(&self, name: Cow<'_, BStr>) -> Result { @@ -51,8 +55,10 @@ mod algorithm { } mod validate { - use crate::bstr::BStr; - use crate::config::tree::{keys, Diff}; + use crate::{ + bstr::BStr, + config::tree::{keys, Diff}, + }; pub struct Algorithm; impl keys::Validate for Algorithm { diff --git a/git-repository/src/config/tree/sections/extensions.rs b/git-repository/src/config/tree/sections/extensions.rs index 17572df5635..ad49aea029b 100644 --- a/git-repository/src/config/tree/sections/extensions.rs +++ b/git-repository/src/config/tree/sections/extensions.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{keys, Extensions, Key, Section}; +use crate::{ + config, + config::tree::{keys, Extensions, Key, Section}, +}; impl Extensions { /// The `extensions.worktreeConfig` key. @@ -15,11 +17,10 @@ impl Extensions { pub type ObjectFormat = keys::Any; mod object_format { - use crate::bstr::BStr; - use crate::config; - use crate::config::tree::sections::extensions::ObjectFormat; use std::borrow::Cow; + use crate::{bstr::BStr, config, config::tree::sections::extensions::ObjectFormat}; + impl ObjectFormat { pub fn try_into_object_format( &'static self, @@ -45,8 +46,7 @@ impl Section for Extensions { } mod validate { - use crate::bstr::BStr; - use crate::config::tree::keys; + use crate::{bstr::BStr, config::tree::keys}; pub struct ObjectFormat; diff --git a/git-repository/src/config/tree/sections/gitoxide.rs b/git-repository/src/config/tree/sections/gitoxide.rs index eaa6b1fdda7..8c3defd0b68 100644 --- a/git-repository/src/config/tree/sections/gitoxide.rs +++ b/git-repository/src/config/tree/sections/gitoxide.rs @@ -51,8 +51,10 @@ impl Section for Gitoxide { } mod subsections { - use crate::config::tree::{http, keys, Gitoxide, Key, Section}; - use crate::config::Tree; + use crate::config::{ + tree::{http, keys, Gitoxide, Key, Section}, + Tree, + }; /// The `Http` sub-section. #[derive(Copy, Clone, Default)] @@ -341,10 +343,10 @@ mod subsections { } pub mod validate { - use crate::bstr::BStr; - use crate::config::tree::keys::Validate; use std::error::Error; + use crate::{bstr::BStr, config::tree::keys::Validate}; + pub struct ProtocolFromUser; impl Validate for ProtocolFromUser { fn validate(&self, value: &BStr) -> Result<(), Box> { @@ -356,5 +358,6 @@ pub mod validate { } } -use crate::config; pub use subsections::{Allow, Author, Commit, Committer, Http, Https, Objects, Ssh, User}; + +use crate::config; diff --git a/git-repository/src/config/tree/sections/http.rs b/git-repository/src/config/tree/sections/http.rs index 63f23365d6f..fcaadd2c7ad 100644 --- a/git-repository/src/config/tree/sections/http.rs +++ b/git-repository/src/config/tree/sections/http.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{keys, Http, Key, Section}; +use crate::{ + config, + config::tree::{keys, Http, Key, Section}, +}; impl Http { /// The `http.sslVersion` key. @@ -87,8 +89,10 @@ pub type ProxyAuthMethod = keys::Any; pub type Version = keys::Any; mod key_impls { - use crate::config::tree::http::{ProxyAuthMethod, SslVersion}; - use crate::config::tree::{keys, Section}; + use crate::config::tree::{ + http::{ProxyAuthMethod, SslVersion}, + keys, Section, + }; impl SslVersion { pub const fn new_ssl_version(name: &'static str, section: &'static dyn Section) -> Self { @@ -237,10 +241,13 @@ mod key_impls { } pub mod validate { - use crate::bstr::{BStr, ByteSlice}; - use crate::config::tree::keys::Validate; use std::error::Error; + use crate::{ + bstr::{BStr, ByteSlice}, + config::tree::keys::Validate, + }; + pub struct SslVersion; impl Validate for SslVersion { fn validate(&self, _value: &BStr) -> Result<(), Box> { diff --git a/git-repository/src/config/tree/sections/init.rs b/git-repository/src/config/tree/sections/init.rs index def7d6a4c66..de42d3b6257 100644 --- a/git-repository/src/config/tree/sections/init.rs +++ b/git-repository/src/config/tree/sections/init.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{keys, Init, Key, Section}; +use crate::{ + config, + config::tree::{keys, Init, Key, Section}, +}; impl Init { /// The `init.defaultBranch` key. diff --git a/git-repository/src/config/tree/sections/pack.rs b/git-repository/src/config/tree/sections/pack.rs index 58d9a5f8310..c70daa72ff4 100644 --- a/git-repository/src/config/tree/sections/pack.rs +++ b/git-repository/src/config/tree/sections/pack.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{keys, Key, Pack, Section}; +use crate::{ + config, + config::tree::{keys, Key, Pack, Section}, +}; impl Pack { /// The `pack.threads` key. @@ -16,8 +18,7 @@ impl Pack { pub type IndexVersion = keys::Any; mod index_version { - use crate::config; - use crate::config::tree::sections::pack::IndexVersion; + use crate::{config, config::tree::sections::pack::IndexVersion}; impl IndexVersion { /// Try to interpret an integer value as index version. @@ -46,8 +47,7 @@ impl Section for Pack { } mod validate { - use crate::bstr::BStr; - use crate::config::tree::keys; + use crate::{bstr::BStr, config::tree::keys}; pub struct IndexVersion; impl keys::Validate for IndexVersion { diff --git a/git-repository/src/config/tree/sections/protocol.rs b/git-repository/src/config/tree/sections/protocol.rs index bfdb35af26d..58e907b0f8a 100644 --- a/git-repository/src/config/tree/sections/protocol.rs +++ b/git-repository/src/config/tree/sections/protocol.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{keys, Key, Protocol, Section}; +use crate::{ + config, + config::tree::{keys, Key, Protocol, Section}, +}; impl Protocol { /// The `protocol.allow` key. @@ -14,12 +16,10 @@ pub type Allow = keys::Any; #[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))] mod allow { - use crate::bstr::BStr; - use crate::config; - use crate::config::tree::protocol::Allow; - use crate::remote::url::scheme_permission; use std::borrow::Cow; + use crate::{bstr::BStr, config, config::tree::protocol::Allow, remote::url::scheme_permission}; + impl Allow { /// Convert `value` into its respective `Allow` variant, possibly informing about the `scheme` we are looking at in the error. pub fn try_into_allow( @@ -72,8 +72,7 @@ impl Section for Protocol { } mod validate { - use crate::bstr::BStr; - use crate::config::tree::keys; + use crate::{bstr::BStr, config::tree::keys}; pub struct Allow; impl keys::Validate for Allow { diff --git a/git-repository/src/config/tree/sections/remote.rs b/git-repository/src/config/tree/sections/remote.rs index 62535552abb..dfcbee5e0f4 100644 --- a/git-repository/src/config/tree/sections/remote.rs +++ b/git-repository/src/config/tree/sections/remote.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{http, keys, Key, Remote, Section, SubSectionRequirement}; +use crate::{ + config, + config::tree::{http, keys, Key, Remote, Section, SubSectionRequirement}, +}; const NAME_PARAMETER: Option = Some(SubSectionRequirement::Parameter("name")); @@ -54,11 +56,10 @@ impl Section for Remote { pub type TagOpt = keys::Any; mod tag_opts { - use crate::bstr::BStr; - use crate::config::tree::remote::TagOpt; - use crate::{config, remote}; use std::borrow::Cow; + use crate::{bstr::BStr, config, config::tree::remote::TagOpt, remote}; + impl TagOpt { /// Try to interpret `value` as tag option. /// @@ -81,10 +82,9 @@ mod tag_opts { } pub mod validate { - use crate::bstr::BStr; - use crate::config::tree::keys::Validate; - use std::borrow::Cow; - use std::error::Error; + use std::{borrow::Cow, error::Error}; + + use crate::{bstr::BStr, config::tree::keys::Validate}; pub struct TagOpt; impl Validate for TagOpt { diff --git a/git-repository/src/config/tree/sections/safe.rs b/git-repository/src/config/tree/sections/safe.rs index 0e5e99c545d..1ed3d790ad7 100644 --- a/git-repository/src/config/tree/sections/safe.rs +++ b/git-repository/src/config/tree/sections/safe.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{keys, Key, Safe, Section}; +use crate::{ + config, + config::tree::{keys, Key, Safe, Section}, +}; impl Safe { /// The `safe.directory` key diff --git a/git-repository/src/config/tree/sections/ssh.rs b/git-repository/src/config/tree/sections/ssh.rs index 8e4c07d6885..ecb0fdae80a 100644 --- a/git-repository/src/config/tree/sections/ssh.rs +++ b/git-repository/src/config/tree/sections/ssh.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{keys, Key, Section, Ssh}; +use crate::{ + config, + config::tree::{keys, Key, Section, Ssh}, +}; impl Ssh { /// The `ssh.variant` key @@ -13,11 +15,10 @@ pub type Variant = keys::Any; #[cfg(feature = "blocking-network-client")] mod variant { - use crate::bstr::BStr; - use crate::config; - use crate::config::tree::ssh::Variant; use std::borrow::Cow; + use crate::{bstr::BStr, config, config::tree::ssh::Variant}; + impl Variant { pub fn try_into_variant( &'static self, @@ -49,8 +50,7 @@ impl Section for Ssh { } mod validate { - use crate::bstr::BStr; - use crate::config::tree::keys; + use crate::{bstr::BStr, config::tree::keys}; pub struct Variant; impl keys::Validate for Variant { diff --git a/git-repository/src/config/tree/sections/url.rs b/git-repository/src/config/tree/sections/url.rs index 53c58d71045..6a9c0bfdbdb 100644 --- a/git-repository/src/config/tree/sections/url.rs +++ b/git-repository/src/config/tree/sections/url.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{keys, Key, Section, SubSectionRequirement, Url}; +use crate::{ + config, + config::tree::{keys, Key, Section, SubSectionRequirement, Url}, +}; const BASE_PARAMETER: Option = Some(SubSectionRequirement::Parameter("base")); diff --git a/git-repository/src/config/tree/sections/user.rs b/git-repository/src/config/tree/sections/user.rs index 2110873051f..d1f4f71026f 100644 --- a/git-repository/src/config/tree/sections/user.rs +++ b/git-repository/src/config/tree/sections/user.rs @@ -1,5 +1,7 @@ -use crate::config; -use crate::config::tree::{gitoxide, keys, Key, Section, User}; +use crate::{ + config, + config::tree::{gitoxide, keys, Key, Section, User}, +}; impl User { /// The `user.name` key diff --git a/git-repository/src/config/tree/traits.rs b/git-repository/src/config/tree/traits.rs index 9c5dddd3b16..a594a3fa69f 100644 --- a/git-repository/src/config/tree/traits.rs +++ b/git-repository/src/config/tree/traits.rs @@ -1,6 +1,7 @@ -use crate::bstr::{BStr, BString, ByteVec}; use std::borrow::Cow; +use crate::bstr::{BStr, BString, ByteVec}; + /// Provide information about a configuration section. pub trait Section { /// The section name, like `remote` in `remote.origin.url`. diff --git a/git-repository/src/init.rs b/git-repository/src/init.rs index 3565568fca1..8d92d8a1136 100644 --- a/git-repository/src/init.rs +++ b/git-repository/src/init.rs @@ -6,8 +6,7 @@ use git_ref::{ FullName, Target, }; -use crate::config::tree::Init; -use crate::{bstr::BString, ThreadSafeRepository}; +use crate::{bstr::BString, config::tree::Init, ThreadSafeRepository}; /// The name of the branch to use if non is configured via git configuration. /// diff --git a/git-repository/src/open/repository.rs b/git-repository/src/open/repository.rs index 00b3b82baef..3acbeaea341 100644 --- a/git-repository/src/open/repository.rs +++ b/git-repository/src/open/repository.rs @@ -3,10 +3,12 @@ use std::{borrow::Cow, path::PathBuf}; use git_features::threading::OwnShared; use super::{Error, Options}; -use crate::config::tree::{gitoxide, Core, Key, Safe}; use crate::{ config, - config::cache::{interpolate_context, util::ApplyLeniency}, + config::{ + cache::{interpolate_context, util::ApplyLeniency}, + tree::{gitoxide, Core, Key, Safe}, + }, permission, Permissions, ThreadSafeRepository, }; diff --git a/git-repository/src/reference/remote.rs b/git-repository/src/reference/remote.rs index 3793f670693..7cc1d14d35d 100644 --- a/git-repository/src/reference/remote.rs +++ b/git-repository/src/reference/remote.rs @@ -1,5 +1,4 @@ -use crate::config::tree::Branch; -use crate::{config, remote, Reference}; +use crate::{config, config::tree::Branch, remote, Reference}; /// Remotes impl<'repo> Reference<'repo> { diff --git a/git-repository/src/remote/connection/fetch/config.rs b/git-repository/src/remote/connection/fetch/config.rs index 0190ecf6710..f30cb5651cb 100644 --- a/git-repository/src/remote/connection/fetch/config.rs +++ b/git-repository/src/remote/connection/fetch/config.rs @@ -1,8 +1,8 @@ -use crate::config::cache::util::ApplyLeniency; -use crate::config::tree::Pack; - use super::Error; -use crate::Repository; +use crate::{ + config::{cache::util::ApplyLeniency, tree::Pack}, + Repository, +}; pub fn index_threads(repo: &Repository) -> Result, Error> { Ok(repo diff --git a/git-repository/src/remote/connection/fetch/update_refs/tests.rs b/git-repository/src/remote/connection/fetch/update_refs/tests.rs index 3bd9a9f4f28..e581b92b7da 100644 --- a/git-repository/src/remote/connection/fetch/update_refs/tests.rs +++ b/git-repository/src/remote/connection/fetch/update_refs/tests.rs @@ -10,9 +10,9 @@ fn hex_to_id(hex: &str) -> git_hash::ObjectId { mod update { use std::convert::TryInto; - use super::hex_to_id; use git_testtools::Result; + use super::hex_to_id; use crate as git; fn base_repo_path() -> String { @@ -43,12 +43,11 @@ mod update { } use git_ref::{transaction::Change, TargetRef}; - use crate::remote::fetch::refs::tests::restricted; use crate::{ bstr::BString, remote::{ fetch, - fetch::{Mapping, RefLogMessage, Source, SpecIndex}, + fetch::{refs::tests::restricted, Mapping, RefLogMessage, Source, SpecIndex}, }, }; diff --git a/git-repository/src/remote/url/scheme_permission.rs b/git-repository/src/remote/url/scheme_permission.rs index 771e1a74e0f..17e3e2ec8d7 100644 --- a/git-repository/src/remote/url/scheme_permission.rs +++ b/git-repository/src/remote/url/scheme_permission.rs @@ -1,8 +1,10 @@ use std::{borrow::Cow, collections::BTreeMap, convert::TryFrom}; -use crate::bstr::{BStr, BString, ByteSlice}; -use crate::config; -use crate::config::tree::{gitoxide, Key, Protocol}; +use crate::{ + bstr::{BStr, BString, ByteSlice}, + config, + config::tree::{gitoxide, Key, Protocol}, +}; /// All allowed values of the `protocol.allow` key. #[derive(Debug, Clone, Copy, Eq, PartialEq)] diff --git a/git-repository/src/repository/config/mod.rs b/git-repository/src/repository/config/mod.rs index 23929fdd013..265da7085e3 100644 --- a/git-repository/src/repository/config/mod.rs +++ b/git-repository/src/repository/config/mod.rs @@ -32,8 +32,10 @@ impl crate::Repository { pub fn ssh_connect_options( &self, ) -> Result { - use crate::config::cache::util::ApplyLeniency; - use crate::config::tree::{gitoxide, Core, Ssh}; + use crate::config::{ + cache::util::ApplyLeniency, + tree::{gitoxide, Core, Ssh}, + }; let config = &self.config.resolved; let mut trusted = self.filter_config_section(); diff --git a/git-repository/src/repository/config/transport.rs b/git-repository/src/repository/config/transport.rs index 61046e8a29f..c86d43ef21b 100644 --- a/git-repository/src/repository/config/transport.rs +++ b/git-repository/src/repository/config/transport.rs @@ -52,12 +52,15 @@ impl crate::Repository { http::options::{ProxyAuthMethod, SslVersion, SslVersionRangeInclusive}, }; - use crate::config; - use crate::config::cache::util::ApplyLeniency; - use crate::config::tree::gitoxide; #[cfg(debug_assertions)] use crate::config::tree::Key; - use crate::config::tree::Remote; + use crate::{ + config, + config::{ + cache::util::ApplyLeniency, + tree::{gitoxide, Remote}, + }, + }; fn try_cow_to_string( v: Cow<'_, BStr>, lenient: bool, diff --git a/git-repository/src/repository/identity.rs b/git-repository/src/repository/identity.rs index 244963d1ad1..34f3f445c6d 100644 --- a/git-repository/src/repository/identity.rs +++ b/git-repository/src/repository/identity.rs @@ -1,8 +1,10 @@ use std::time::SystemTime; -use crate::bstr::BString; -use crate::config; -use crate::config::tree::{gitoxide, keys, Author, Committer, Key, User}; +use crate::{ + bstr::BString, + config, + config::tree::{gitoxide, keys, Author, Committer, Key, User}, +}; /// Identity handling. /// diff --git a/git-repository/tests/clone/mod.rs b/git-repository/tests/clone/mod.rs index e23361b3abf..7da392b1fe5 100644 --- a/git-repository/tests/clone/mod.rs +++ b/git-repository/tests/clone/mod.rs @@ -1,7 +1,6 @@ use git_repository as git; -use crate::remote; -use crate::util::restricted; +use crate::{remote, util::restricted}; #[cfg(feature = "blocking-network-client")] mod blocking_io { @@ -10,8 +9,7 @@ mod blocking_io { use git_repository as git; use git_repository::remote::fetch::SpecIndex; - use crate::remote; - use crate::util::restricted; + use crate::{remote, util::restricted}; #[test] fn fetch_only_with_configuration() -> crate::Result { diff --git a/git-repository/tests/config/tree.rs b/git-repository/tests/config/tree.rs index e5757e293ba..48400a3342f 100644 --- a/git-repository/tests/config/tree.rs +++ b/git-repository/tests/config/tree.rs @@ -1,16 +1,19 @@ -use git_object::bstr::BStr; use std::borrow::Cow; +use git_object::bstr::BStr; + fn bcow(input: &str) -> Cow<'_, BStr> { Cow::Borrowed(input.into()) } mod keys { - use crate::config::tree::bcow; + use std::borrow::Cow; + use git_object::bstr::ByteSlice; use git_repository as git; use git_repository::config::tree::{Key, Section}; - use std::borrow::Cow; + + use crate::config::tree::bcow; #[test] fn string() -> crate::Result { @@ -69,9 +72,10 @@ mod keys { } mod branch { - use crate::config::tree::bcow; use git_repository::config::tree::{branch, Branch, Key}; + use crate::config::tree::bcow; + #[test] fn merge() { assert!(branch::Merge::try_into_fullrefname(bcow("refs/heads/main")).is_ok()); @@ -90,9 +94,10 @@ mod ssh { #[test] #[cfg(feature = "blocking-network-client")] fn variant() -> crate::Result { - use crate::config::tree::bcow; use git_protocol::transport::client::ssh::ProgramKind; use git_repository::config::tree::Ssh; + + use crate::config::tree::bcow; for (actual, expected) in [ ("auto", None), ("ssh", Some(ProgramKind::Ssh)), @@ -114,10 +119,11 @@ mod ssh { } mod diff { - use crate::config::tree::bcow; use git_diff::blob::Algorithm; use git_repository::config::tree::{Diff, Key}; + use crate::config::tree::bcow; + #[test] fn algorithm() -> crate::Result { for (actual, expected) in [ @@ -147,12 +153,16 @@ mod diff { } mod core { - use crate::config::tree::bcow; - use git_lock::acquire::Fail; - use git_repository::config::tree::{Core, Key}; - use git_repository::revision::spec::parse::ObjectKindHint; use std::time::Duration; + use git_lock::acquire::Fail; + use git_repository::{ + config::tree::{Core, Key}, + revision::spec::parse::ObjectKindHint, + }; + + use crate::config::tree::bcow; + fn signed(value: i64) -> Result { Ok(value) } @@ -305,9 +315,10 @@ mod core { } mod extensions { - use crate::config::tree::bcow; use git_repository::config::tree::{Extensions, Key}; + use crate::config::tree::bcow; + #[test] fn object_format() -> crate::Result { assert_eq!( @@ -382,9 +393,12 @@ mod pack { #[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))] mod protocol { + use git_repository::{ + config::tree::{protocol, Key, Protocol}, + remote::url::scheme_permission::Allow, + }; + use crate::config::tree::bcow; - use git_repository::config::tree::{protocol, Key, Protocol}; - use git_repository::remote::url::scheme_permission::Allow; #[test] fn allow() -> crate::Result { @@ -494,10 +508,12 @@ mod gitoxide { feature = "blocking-http-transport-curl" ))] mod http { - use crate::config::tree::bcow; + use std::borrow::Cow; + use git_object::bstr::ByteSlice; use git_repository::config::tree::{Http, Key}; - use std::borrow::Cow; + + use crate::config::tree::bcow; #[test] fn follow_redirects() -> crate::Result { @@ -637,9 +653,12 @@ mod http { } mod remote { + use git_repository::{ + config::tree::{Key, Remote}, + remote, + }; + use crate::config::tree::bcow; - use git_repository::config::tree::{Key, Remote}; - use git_repository::remote; #[test] fn tag_opt() -> crate::Result { diff --git a/git-repository/tests/id/mod.rs b/git-repository/tests/id/mod.rs index 6fb74daef47..cc070450271 100644 --- a/git-repository/tests/id/mod.rs +++ b/git-repository/tests/id/mod.rs @@ -1,9 +1,11 @@ -use git_object::bstr::BString; use std::cmp::Ordering; +use git_object::bstr::BString; use git_repository as git; -use git_repository::config::tree::{Core, Key}; -use git_repository::prelude::ObjectIdExt; +use git_repository::{ + config::tree::{Core, Key}, + prelude::ObjectIdExt, +}; /// Convert a hexadecimal hash into its corresponding `ObjectId` or _panic_. fn hex_to_id(hex: &str) -> git_hash::ObjectId { diff --git a/git-repository/tests/remote/fetch.rs b/git-repository/tests/remote/fetch.rs index cc8dfcf597d..6f185c20bd8 100644 --- a/git-repository/tests/remote/fetch.rs +++ b/git-repository/tests/remote/fetch.rs @@ -2,13 +2,15 @@ mod blocking_and_async_io { use std::sync::atomic::AtomicBool; - use crate::util::hex_to_id; use git_features::progress; use git_protocol::maybe_async; use git_repository as git; use git_repository::remote::{fetch, Direction::Fetch}; - use crate::remote::{into_daemon_remote_if_async, spawn_git_daemon_if_async}; + use crate::{ + remote::{into_daemon_remote_if_async, spawn_git_daemon_if_async}, + util::hex_to_id, + }; pub(crate) fn base_repo_path() -> String { git::path::realpath( diff --git a/git-repository/tests/repository/object.rs b/git-repository/tests/repository/object.rs index 0debe4d89f5..a627d7377bb 100644 --- a/git-repository/tests/repository/object.rs +++ b/git-repository/tests/repository/object.rs @@ -20,9 +20,7 @@ mod write_object { mod write_blob { use std::io::{Seek, SeekFrom}; - use crate::util::hex_to_id; - - use crate::repository::object::empty_bare_repo; + use crate::{repository::object::empty_bare_repo, util::hex_to_id}; #[test] fn from_slice() -> crate::Result { @@ -184,11 +182,10 @@ mod commit_as { } mod commit { - use crate::util::hex_to_id; use git_repository as git; use git_testtools::tempfile; - use crate::{freeze_time, restricted_and_git}; + use crate::{freeze_time, restricted_and_git, util::hex_to_id}; #[test] fn parent_in_initial_commit_causes_failure() -> crate::Result { diff --git a/git-repository/tests/repository/reference.rs b/git-repository/tests/repository/reference.rs index 60f165e7526..6841f9b73cd 100644 --- a/git-repository/tests/repository/reference.rs +++ b/git-repository/tests/repository/reference.rs @@ -82,9 +82,10 @@ mod set_namespace { } mod iter_references { - use crate::util::hex_to_id; use git_repository as git; + use crate::util::hex_to_id; + fn repo() -> crate::Result { crate::repo("make_references_repo.sh").map(|r| r.to_thread_local()) } @@ -187,10 +188,11 @@ mod iter_references { mod head { - use crate::util::hex_to_id; use git_ref::transaction::PreviousValue; use git_repository as git; + use crate::util::hex_to_id; + #[test] fn symbolic() -> crate::Result { let repo = crate::basic_repo()?; diff --git a/git-repository/tests/revision/spec/from_bytes/ambiguous.rs b/git-repository/tests/revision/spec/from_bytes/ambiguous.rs index 4a518c5e0f3..0a34de57201 100644 --- a/git-repository/tests/revision/spec/from_bytes/ambiguous.rs +++ b/git-repository/tests/revision/spec/from_bytes/ambiguous.rs @@ -1,4 +1,3 @@ -use crate::util::hex_to_id; use git_repository::{ prelude::{ObjectIdExt, RevSpecExt}, revision::{ @@ -8,9 +7,12 @@ use git_repository::{ }; use super::repo; -use crate::revision::spec::from_bytes::{ - parse_spec, parse_spec_better_than_baseline, parse_spec_no_baseline, parse_spec_no_baseline_opts, parse_spec_opts, - rev_parse, +use crate::{ + revision::spec::from_bytes::{ + parse_spec, parse_spec_better_than_baseline, parse_spec_no_baseline, parse_spec_no_baseline_opts, + parse_spec_opts, rev_parse, + }, + util::hex_to_id, }; #[test] diff --git a/git-repository/tests/revision/spec/from_bytes/mod.rs b/git-repository/tests/revision/spec/from_bytes/mod.rs index 3adeca0bc0f..34b7553ff20 100644 --- a/git-repository/tests/revision/spec/from_bytes/mod.rs +++ b/git-repository/tests/revision/spec/from_bytes/mod.rs @@ -1,7 +1,8 @@ -use crate::util::hex_to_id; use git_repository::{prelude::ObjectIdExt, revision::Spec}; pub use util::*; +use crate::util::hex_to_id; + mod ambiguous; mod regex; mod util; @@ -32,10 +33,12 @@ mod sibling_branch { } mod index { - use crate::util::hex_to_id; use git_repository::{prelude::ObjectIdExt, revision::Spec}; - use crate::revision::spec::from_bytes::{parse_spec, repo}; + use crate::{ + revision::spec::from_bytes::{parse_spec, repo}, + util::hex_to_id, + }; #[test] fn at_stage() { diff --git a/git-repository/tests/revision/spec/from_bytes/peel.rs b/git-repository/tests/revision/spec/from_bytes/peel.rs index 97927287ec4..1dccbae4d88 100644 --- a/git-repository/tests/revision/spec/from_bytes/peel.rs +++ b/git-repository/tests/revision/spec/from_bytes/peel.rs @@ -1,7 +1,9 @@ -use crate::util::hex_to_id; use git_repository::{prelude::ObjectIdExt, revision::Spec}; -use crate::revision::spec::from_bytes::{parse_spec, repo}; +use crate::{ + revision::spec::from_bytes::{parse_spec, repo}, + util::hex_to_id, +}; #[test] fn peel_to_object() { diff --git a/git-repository/tests/revision/spec/from_bytes/reflog.rs b/git-repository/tests/revision/spec/from_bytes/reflog.rs index 1f5b9233044..0125191bd8d 100644 --- a/git-repository/tests/revision/spec/from_bytes/reflog.rs +++ b/git-repository/tests/revision/spec/from_bytes/reflog.rs @@ -1,10 +1,12 @@ -use crate::util::hex_to_id; use git_repository::{ prelude::ObjectIdExt, revision::{spec::parse::Error, Spec}, }; -use crate::revision::spec::from_bytes::{parse_spec, parse_spec_no_baseline, repo}; +use crate::{ + revision::spec::from_bytes::{parse_spec, parse_spec_no_baseline, repo}, + util::hex_to_id, +}; #[test] fn nth_prior_checkout() { diff --git a/git-repository/tests/revision/spec/from_bytes/regex.rs b/git-repository/tests/revision/spec/from_bytes/regex.rs index dbd64279f67..43b8bc9e2c1 100644 --- a/git-repository/tests/revision/spec/from_bytes/regex.rs +++ b/git-repository/tests/revision/spec/from_bytes/regex.rs @@ -1,7 +1,9 @@ -use crate::util::hex_to_id; use git_repository::prelude::ObjectIdExt; -use crate::revision::spec::from_bytes::{parse_spec_no_baseline, repo}; +use crate::{ + revision::spec::from_bytes::{parse_spec_no_baseline, repo}, + util::hex_to_id, +}; mod with_known_revision { use git_repository::revision::Spec; diff --git a/git-repository/tests/revision/spec/from_bytes/traverse.rs b/git-repository/tests/revision/spec/from_bytes/traverse.rs index 38fd4f5e987..13f45a82735 100644 --- a/git-repository/tests/revision/spec/from_bytes/traverse.rs +++ b/git-repository/tests/revision/spec/from_bytes/traverse.rs @@ -1,7 +1,9 @@ -use crate::util::hex_to_id; use git_repository::{prelude::ObjectIdExt, revision::Spec}; -use crate::revision::spec::from_bytes::{parse_spec, parse_spec_no_baseline, repo}; +use crate::{ + revision::spec::from_bytes::{parse_spec, parse_spec_no_baseline, repo}, + util::hex_to_id, +}; #[test] fn complex() -> crate::Result { diff --git a/git-revision/tests/describe/format.rs b/git-revision/tests/describe/format.rs index 6b5bac15570..32a797696a7 100644 --- a/git-revision/tests/describe/format.rs +++ b/git-revision/tests/describe/format.rs @@ -1,9 +1,10 @@ use std::borrow::Cow; -use crate::hex_to_id; use git_object::bstr::ByteSlice; use git_revision::describe; +use crate::hex_to_id; + #[test] fn exact_match_with_dirty_and_long() { let mut format = describe::Outcome { diff --git a/git-revision/tests/describe/mod.rs b/git-revision/tests/describe/mod.rs index f161f0f4c4c..394b8a8ca77 100644 --- a/git-revision/tests/describe/mod.rs +++ b/git-revision/tests/describe/mod.rs @@ -1,6 +1,5 @@ use std::borrow::Cow; -use crate::hex_to_id; use git_object::bstr::ByteSlice; use git_repository::{ odb::{Find, FindExt}, @@ -8,6 +7,8 @@ use git_repository::{ }; use git_revision::describe; +use crate::hex_to_id; + mod format; #[test] diff --git a/git-transport/src/client/blocking_io/file.rs b/git-transport/src/client/blocking_io/file.rs index 8f866de8f92..1a20cd6fade 100644 --- a/git-transport/src/client/blocking_io/file.rs +++ b/git-transport/src/client/blocking_io/file.rs @@ -1,9 +1,8 @@ -use std::ffi::OsStr; use std::{ any::Any, borrow::Cow, error::Error, - ffi::OsString, + ffi::{OsStr, OsString}, io::Write, process::{self, Stdio}, }; diff --git a/git-transport/src/client/blocking_io/http/mod.rs b/git-transport/src/client/blocking_io/http/mod.rs index a097ee9defa..1c42dd3f66c 100644 --- a/git-transport/src/client/blocking_io/http/mod.rs +++ b/git-transport/src/client/blocking_io/http/mod.rs @@ -1,4 +1,3 @@ -use base64::Engine; use std::{ any::Any, borrow::Cow, @@ -7,6 +6,7 @@ use std::{ sync::{Arc, Mutex}, }; +use base64::Engine; use bstr::BStr; use git_packetline::PacketLineRef; pub use traits::{Error, GetResponse, Http, PostBodyDataKind, PostResponse}; diff --git a/git-transport/src/client/blocking_io/ssh/program_kind.rs b/git-transport/src/client/blocking_io/ssh/program_kind.rs index 2ac613a7bb0..a46b2f6ab9b 100644 --- a/git-transport/src/client/blocking_io/ssh/program_kind.rs +++ b/git-transport/src/client/blocking_io/ssh/program_kind.rs @@ -1,5 +1,4 @@ -use std::ffi::OsStr; -use std::io::ErrorKind; +use std::{ffi::OsStr, io::ErrorKind}; use bstr::{BString, ByteSlice, ByteVec}; diff --git a/git-transport/src/client/blocking_io/ssh/tests.rs b/git-transport/src/client/blocking_io/ssh/tests.rs index dd8f64f4616..971d9599229 100644 --- a/git-transport/src/client/blocking_io/ssh/tests.rs +++ b/git-transport/src/client/blocking_io/ssh/tests.rs @@ -214,9 +214,10 @@ mod program_kind { } mod line_to_err { - use crate::client::ssh::ProgramKind; use std::io::ErrorKind; + use crate::client::ssh::ProgramKind; + #[test] fn all() { for (kind, line, expected) in [ diff --git a/git-transport/src/client/non_io_types.rs b/git-transport/src/client/non_io_types.rs index da0e75b6ec1..c60f733e584 100644 --- a/git-transport/src/client/non_io_types.rs +++ b/git-transport/src/client/non_io_types.rs @@ -92,9 +92,10 @@ pub(crate) mod connect { } mod error { - use bstr::BString; use std::ffi::OsString; + use bstr::BString; + use crate::client::capabilities; #[cfg(feature = "http-client")] use crate::client::http; diff --git a/git-worktree/tests/worktree/fs/cache/ignore_and_attributes.rs b/git-worktree/tests/worktree/fs/cache/ignore_and_attributes.rs index a53e6ebc88b..b38a5a6a0fe 100644 --- a/git-worktree/tests/worktree/fs/cache/ignore_and_attributes.rs +++ b/git-worktree/tests/worktree/fs/cache/ignore_and_attributes.rs @@ -1,6 +1,5 @@ use std::path::Path; -use crate::hex_to_id; use bstr::{BStr, ByteSlice}; use git_glob::pattern::Case; use git_index::entry::Mode; @@ -8,6 +7,8 @@ use git_odb::{pack::bundle::write::Options, FindExt}; use git_worktree::fs; use tempfile::{tempdir, TempDir}; +use crate::hex_to_id; + struct IgnoreExpectations<'a> { lines: bstr::Lines<'a>, } diff --git a/git-worktree/tests/worktree/mod.rs b/git-worktree/tests/worktree/mod.rs index a471cb9388b..bc68cc4be7b 100644 --- a/git-worktree/tests/worktree/mod.rs +++ b/git-worktree/tests/worktree/mod.rs @@ -1,8 +1,9 @@ mod fs; mod index; -use git_hash::ObjectId; use std::path::{Path, PathBuf}; + +use git_hash::ObjectId; pub type Result = std::result::Result>; pub fn hex_to_id(hex: &str) -> ObjectId { diff --git a/src/plumbing/options/free.rs b/src/plumbing/options/free.rs index 26c77ae9959..2be0878fb3c 100644 --- a/src/plumbing/options/free.rs +++ b/src/plumbing/options/free.rs @@ -308,9 +308,10 @@ pub mod pack { pub mod index { use std::path::PathBuf; - use super::AsIterationMode; use gitoxide_core as core; + use super::AsIterationMode; + #[derive(Debug, clap::Subcommand)] pub enum Subcommands { /// create a pack index from a pack data file. @@ -346,10 +347,12 @@ pub mod pack { } mod clap_util { - use clap::builder::{NonEmptyStringValueParser, PossibleValue, TypedValueParser}; - use clap::{Arg, Command, Error}; - use std::ffi::OsStr; - use std::str::FromStr; + use std::{ffi::OsStr, str::FromStr}; + + use clap::{ + builder::{NonEmptyStringValueParser, PossibleValue, TypedValueParser}, + Arg, Command, Error, + }; #[derive(Clone)] pub struct AsObjectExpansion; diff --git a/src/plumbing/options/mod.rs b/src/plumbing/options/mod.rs index a4cdff33944..7bd70f9dbfd 100644 --- a/src/plumbing/options/mod.rs +++ b/src/plumbing/options/mod.rs @@ -355,9 +355,10 @@ pub mod revision { pub mod exclude { use std::ffi::OsString; - use super::AsPathSpec; use git_repository as git; + use super::AsPathSpec; + #[derive(Debug, clap::Subcommand)] pub enum Subcommands { /// Check if path-specs are excluded and print the result similar to `git check-ignore`. @@ -405,11 +406,14 @@ pub mod index { pub mod free; mod clap_util { - use clap::builder::{OsStringValueParser, TypedValueParser}; - use clap::{Arg, Command, Error}; - use git_repository as git; use std::ffi::OsStr; + use clap::{ + builder::{OsStringValueParser, TypedValueParser}, + Arg, Command, Error, + }; + use git_repository as git; + #[derive(Clone)] pub struct AsPathSpec; diff --git a/src/plumbing/progress.rs b/src/plumbing/progress.rs index 74932a0d184..df71aff3df0 100644 --- a/src/plumbing/progress.rs +++ b/src/plumbing/progress.rs @@ -1,5 +1,7 @@ -use std::borrow::Cow; -use std::fmt::{Display, Formatter}; +use std::{ + borrow::Cow, + fmt::{Display, Formatter}, +}; use crosstermion::crossterm::style::Stylize; use git_repository as git; diff --git a/src/shared.rs b/src/shared.rs index c8c4bd44129..f1d9a24a420 100644 --- a/src/shared.rs +++ b/src/shared.rs @@ -237,14 +237,12 @@ pub fn from_env() -> T { } mod clap { - use clap::builder::PossibleValue; - use clap::error::ErrorKind; - use clap::{builder, Arg, Command, Error}; + use std::{ffi::OsStr, str::FromStr}; + + use clap::{builder, builder::PossibleValue, error::ErrorKind, Arg, Command, Error}; use git_repository as git; use git_repository::bstr::BString; use gitoxide_core as core; - use std::ffi::OsStr; - use std::str::FromStr; #[derive(Clone)] pub struct AsBString;