diff --git a/experiments/object-access/src/main.rs b/experiments/object-access/src/main.rs index 60ea27ab2aa..8ff9eb001b6 100644 --- a/experiments/object-access/src/main.rs +++ b/experiments/object-access/src/main.rs @@ -1,8 +1,7 @@ use std::{path::Path, sync::Arc, time::Instant}; use anyhow::anyhow; -use git_repository::ThreadSafeRepository; -use git_repository::{hash::ObjectId, odb, threading::OwnShared}; +use git_repository::{hash::ObjectId, odb, threading::OwnShared, ThreadSafeRepository}; use crate::odb::Cache; diff --git a/git-attributes/src/parse/attribute.rs b/git-attributes/src/parse/attribute.rs index b35c3ea86c2..db09daf536f 100644 --- a/git-attributes/src/parse/attribute.rs +++ b/git-attributes/src/parse/attribute.rs @@ -1,6 +1,7 @@ -use bstr::{BStr, BString, ByteSlice}; use std::borrow::Cow; +use bstr::{BStr, BString, ByteSlice}; + #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] pub enum Kind { diff --git a/git-attributes/src/parse/ignore.rs b/git-attributes/src/parse/ignore.rs index 95c51497f81..8a3e92df9d1 100644 --- a/git-attributes/src/parse/ignore.rs +++ b/git-attributes/src/parse/ignore.rs @@ -1,6 +1,7 @@ -use crate::ignore; use bstr::{BString, ByteSlice}; +use crate::ignore; + pub struct Lines<'a> { lines: bstr::Lines<'a>, line_no: usize, diff --git a/git-attributes/tests/parse/attribute.rs b/git-attributes/tests/parse/attribute.rs index ae1463da537..09394c18743 100644 --- a/git-attributes/tests/parse/attribute.rs +++ b/git-attributes/tests/parse/attribute.rs @@ -1,6 +1,5 @@ use bstr::{BStr, ByteSlice}; -use git_attributes::ignore::pattern::Mode; -use git_attributes::{parse, State}; +use git_attributes::{ignore::pattern::Mode, parse, State}; use git_testtools::fixture_bytes; #[test] diff --git a/git-config/src/file/git_config.rs b/git-config/src/file/git_config.rs index fcae58b7752..66f9f3d452f 100644 --- a/git-config/src/file/git_config.rs +++ b/git-config/src/file/git_config.rs @@ -119,11 +119,12 @@ pub struct GitConfig<'event> { } pub mod from_paths { - use crate::parser; - use crate::values::path::interpolate; - use quick_error::quick_error; use std::borrow::Cow; + use quick_error::quick_error; + + use crate::{parser, values::path::interpolate}; + quick_error! { #[derive(Debug)] /// The error returned by [`GitConfig::from_paths()`][super::GitConfig::from_paths()] and [`GitConfig::from_env_paths()`][super::GitConfig::from_env_paths()]. @@ -174,9 +175,10 @@ pub mod from_paths { } pub mod from_env { + use quick_error::quick_error; + use super::from_paths; use crate::values::path::interpolate; - use quick_error::quick_error; quick_error! { #[derive(Debug)] @@ -1796,11 +1798,10 @@ a"#, mod from_paths_tests { use std::{fs, io}; - use crate::file::from_paths; use tempfile::tempdir; use super::{from_paths::Error, Cow, GitConfig}; - use crate::parser::ParserOrIoError; + use crate::{file::from_paths, parser::ParserOrIoError}; /// Escapes backslash when writing a path as string so that it is a valid windows path fn escape_backslashes(path: &std::path::Path) -> String { @@ -2261,12 +2262,11 @@ mod from_paths_tests { mod from_env_tests { use std::{env, fs}; - use crate::file::from_paths; - use crate::file::from_paths::Options; use serial_test::serial; use tempfile::tempdir; use super::{from_env, Cow, GitConfig}; + use crate::file::{from_paths, from_paths::Options}; struct Env<'a> { altered_vars: Vec<&'a str>, diff --git a/git-config/src/fs.rs b/git-config/src/fs.rs index 3e007a1ba4e..fcd0904f1a8 100644 --- a/git-config/src/fs.rs +++ b/git-config/src/fs.rs @@ -7,8 +7,7 @@ use std::{ path::{Path, PathBuf}, }; -use crate::file::from_paths; -use crate::file::{GitConfig, GitConfigError}; +use crate::file::{from_paths, GitConfig, GitConfigError}; #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] pub enum ConfigSource { diff --git a/git-config/src/values.rs b/git-config/src/values.rs index 0bf9429c698..6cb093783dc 100644 --- a/git-config/src/values.rs +++ b/git-config/src/values.rs @@ -1,8 +1,8 @@ //! Rust containers for valid `git-config` types. -use quick_error::quick_error; use std::{borrow::Cow, convert::TryFrom, fmt::Display, str::FromStr}; +use quick_error::quick_error; #[cfg(feature = "serde")] use serde::{Serialize, Serializer}; @@ -288,8 +288,7 @@ pub mod path { mod interpolate_tests { use std::borrow::Cow; - use crate::values::b; - use crate::values::{path::interpolate::Error, Path}; + use crate::values::{b, path::interpolate::Error, Path}; #[test] fn no_interpolation_for_paths_without_tilde_or_prefix() { @@ -1383,9 +1382,10 @@ mod boolean { #[cfg(test)] mod integer { + use std::convert::TryFrom; + use super::{Integer, IntegerSuffix}; use crate::values::b; - use std::convert::TryFrom; #[test] fn from_str_no_suffix() { diff --git a/git-features/src/parallel/in_parallel.rs b/git-features/src/parallel/in_parallel.rs index 33196af29b8..52ad15545f9 100644 --- a/git-features/src/parallel/in_parallel.rs +++ b/git-features/src/parallel/in_parallel.rs @@ -1,6 +1,7 @@ -use crate::parallel::{num_threads, Reduce}; use std::sync::atomic::{AtomicBool, Ordering}; +use crate::parallel::{num_threads, Reduce}; + /// Runs `left` and `right` in parallel, returning their output when both are done. pub fn join(left: impl FnOnce() -> O1 + Send, right: impl FnOnce() -> O2 + Send) -> (O1, O2) { crossbeam_utils::thread::scope(|s| { diff --git a/git-hash/src/owned/prefix.rs b/git-hash/src/owned/prefix.rs index f1568b961e6..508020f8f63 100644 --- a/git-hash/src/owned/prefix.rs +++ b/git-hash/src/owned/prefix.rs @@ -1,7 +1,9 @@ -use crate::{oid, ObjectId, Prefix}; -use quick_error::quick_error; use std::cmp::Ordering; +use quick_error::quick_error; + +use crate::{oid, ObjectId, Prefix}; + quick_error! { /// The error returned by [Prefix::try_from_id()][super::Prefix::try_from_id()]. #[derive(Debug)] diff --git a/git-hash/tests/oid/mod.rs b/git-hash/tests/oid/mod.rs index acc6bbaee85..c92cbbaf69f 100644 --- a/git-hash/tests/oid/mod.rs +++ b/git-hash/tests/oid/mod.rs @@ -1,8 +1,9 @@ mod prefix { mod cmp_oid { - use git_testtools::hex_to_id; use std::cmp::Ordering; + use git_testtools::hex_to_id; + #[test] fn it_detects_inequality() { let prefix = git_hash::Prefix::new(hex_to_id("b920bbb055e1efb9080592a409d3975738b6efb3"), 7).unwrap(); @@ -30,9 +31,10 @@ mod prefix { } } mod new { + use std::cmp::Ordering; + use git_hash::{Kind, ObjectId}; use git_testtools::hex_to_id; - use std::cmp::Ordering; #[test] fn various_valid_inputs() { diff --git a/git-mailmap/src/entry.rs b/git-mailmap/src/entry.rs index 7b2d43963f1..e157428145b 100644 --- a/git-mailmap/src/entry.rs +++ b/git-mailmap/src/entry.rs @@ -1,6 +1,7 @@ -use crate::Entry; use bstr::BStr; +use crate::Entry; + /// Acccess impl<'a> Entry<'a> { /// The name to map to. diff --git a/git-mailmap/src/parse.rs b/git-mailmap/src/parse.rs index 15209256b8a..7c0f1e4c77e 100644 --- a/git-mailmap/src/parse.rs +++ b/git-mailmap/src/parse.rs @@ -17,10 +17,11 @@ mod error { } } -use crate::Entry; use bstr::{BStr, ByteSlice}; pub use error::Error; +use crate::Entry; + /// An iterator to parse mailmap lines on-demand. pub struct Lines<'a> { lines: bstr::Lines<'a>, diff --git a/git-mailmap/src/snapshot.rs b/git-mailmap/src/snapshot.rs index 06de41e9b3f..ec63aa9f4bd 100644 --- a/git-mailmap/src/snapshot.rs +++ b/git-mailmap/src/snapshot.rs @@ -1,8 +1,9 @@ -use crate::Snapshot; +use std::{cmp::Ordering, ops::Deref}; + use bstr::{BStr, BString, ByteSlice}; use git_actor::SignatureRef; -use std::cmp::Ordering; -use std::ops::Deref; + +use crate::Snapshot; /// A resolved signature with borrowed fields for a mapped `name` and/or `email`. pub struct ResolvedSignature<'a> { @@ -311,9 +312,10 @@ fn enriched_signature( #[cfg(test)] mod encoded_string { - use crate::snapshot::{EncodedString, EncodedStringRef}; use std::cmp::Ordering; + use crate::snapshot::{EncodedString, EncodedStringRef}; + #[test] fn basic_ascii_case_folding() { assert_eq!( diff --git a/git-odb/src/cache.rs b/git-odb/src/cache.rs index a61fa6763ca..fb78a712165 100644 --- a/git-odb/src/cache.rs +++ b/git-odb/src/cache.rs @@ -1,7 +1,7 @@ -use std::rc::Rc; use std::{ cell::RefCell, ops::{Deref, DerefMut}, + rc::Rc, sync::Arc, }; diff --git a/git-odb/src/store_impls/dynamic/find.rs b/git-odb/src/store_impls/dynamic/find.rs index 51a37066bd1..22e200e297a 100644 --- a/git-odb/src/store_impls/dynamic/find.rs +++ b/git-odb/src/store_impls/dynamic/find.rs @@ -84,11 +84,13 @@ mod error { } } } -use crate::find::{PotentialPrefix, PrefixLookupResult}; -use crate::Find; pub use error::Error; -use crate::store::types::PackId; +use crate::{ + find::{PotentialPrefix, PrefixLookupResult}, + store::types::PackId, + Find, +}; impl super::Handle where diff --git a/git-odb/src/store_impls/dynamic/handle.rs b/git-odb/src/store_impls/dynamic/handle.rs index 33ae0239f3b..8fb819ffd03 100644 --- a/git-odb/src/store_impls/dynamic/handle.rs +++ b/git-odb/src/store_impls/dynamic/handle.rs @@ -1,8 +1,8 @@ -use std::convert::{TryFrom, TryInto}; -use std::rc::Rc; use std::{ cell::RefCell, + convert::{TryFrom, TryInto}, ops::Deref, + rc::Rc, sync::{atomic::Ordering, Arc}, }; diff --git a/git-odb/src/store_impls/dynamic/mod.rs b/git-odb/src/store_impls/dynamic/mod.rs index b8b11725f96..07a07cda3ce 100644 --- a/git-odb/src/store_impls/dynamic/mod.rs +++ b/git-odb/src/store_impls/dynamic/mod.rs @@ -79,11 +79,10 @@ mod access; /// pub mod structure { - use crate::store::load_index; - use crate::types::IndexAndPacks; - use crate::Store; use std::path::PathBuf; + use crate::{store::load_index, types::IndexAndPacks, Store}; + /// A record of a structural element of an object database. #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] diff --git a/git-odb/src/store_impls/loose/find.rs b/git-odb/src/store_impls/loose/find.rs index d66840d786e..49c4647b085 100644 --- a/git-odb/src/store_impls/loose/find.rs +++ b/git-odb/src/store_impls/loose/find.rs @@ -1,5 +1,4 @@ -use std::cmp::Ordering; -use std::{fs, io::Read, path::PathBuf}; +use std::{cmp::Ordering, fs, io::Read, path::PathBuf}; use git_features::zlib; diff --git a/git-odb/tests/odb/store/dynamic.rs b/git-odb/tests/odb/store/dynamic.rs index b8d405a6416..8d969e3e30b 100644 --- a/git-odb/tests/odb/store/dynamic.rs +++ b/git-odb/tests/odb/store/dynamic.rs @@ -404,10 +404,12 @@ fn assert_all_indices_loaded(handle: &git_odb::Handle, num_refreshes: usize, ope } mod disambiguate_prefix { - use crate::store::dynamic::{assert_all_indices_loaded, db_with_all_object_sources}; + use std::cmp::Ordering; + use git_odb::find::PotentialPrefix; use git_testtools::hex_to_id; - use std::cmp::Ordering; + + use crate::store::dynamic::{assert_all_indices_loaded, db_with_all_object_sources}; #[test] fn unambiguous_hex_lengths_yield_prefixes_of_exactly_the_given_length() { @@ -483,9 +485,10 @@ mod disambiguate_prefix { } mod lookup_prefix { - use crate::store::dynamic::{assert_all_indices_loaded, db_with_all_object_sources}; use git_testtools::hex_to_id; + use crate::store::dynamic::{assert_all_indices_loaded, db_with_all_object_sources}; + #[test] fn returns_none_for_prefixes_without_any_match() { let (handle, _tmp) = db_with_all_object_sources().unwrap(); diff --git a/git-odb/tests/odb/store/loose.rs b/git-odb/tests/odb/store/loose.rs index df3415a2ef2..f5409191e22 100644 --- a/git-odb/tests/odb/store/loose.rs +++ b/git-odb/tests/odb/store/loose.rs @@ -85,9 +85,10 @@ mod contains { } mod lookup_prefix { - use crate::store::loose::ldb; use git_testtools::{fixture_path, hex_to_id}; + use crate::store::loose::ldb; + #[test] fn returns_none_for_prefixes_without_any_match() { let store = ldb(); diff --git a/git-pack/src/index/access.rs b/git-pack/src/index/access.rs index c7313c73777..e6344c842ef 100644 --- a/git-pack/src/index/access.rs +++ b/git-pack/src/index/access.rs @@ -1,10 +1,8 @@ -use std::cmp::Ordering; -use std::mem::size_of; +use std::{cmp::Ordering, mem::size_of}; -use crate::index::PrefixLookupResult; use crate::{ data, - index::{self, EntryIndex, FAN_LEN}, + index::{self, EntryIndex, PrefixLookupResult, FAN_LEN}, }; const N32_SIZE: usize = size_of::(); diff --git a/git-pack/src/multi_index/access.rs b/git-pack/src/multi_index/access.rs index 5d8fb160597..dc8338943eb 100644 --- a/git-pack/src/multi_index/access.rs +++ b/git-pack/src/multi_index/access.rs @@ -1,9 +1,11 @@ -use std::cmp::Ordering; -use std::path::{Path, PathBuf}; +use std::{ + cmp::Ordering, + path::{Path, PathBuf}, +}; -use crate::index::PrefixLookupResult; use crate::{ data, + index::PrefixLookupResult, multi_index::{EntryIndex, File, PackIndex, Version}, }; diff --git a/git-pack/tests/pack/index.rs b/git-pack/tests/pack/index.rs index 62cff413626..3cfd099e1a8 100644 --- a/git-pack/tests/pack/index.rs +++ b/git-pack/tests/pack/index.rs @@ -95,11 +95,15 @@ mod version { use git_features::progress; use git_odb::pack; - use git_pack::data::{input, EntryRange}; - use git_pack::index; + use git_pack::{ + data::{input, EntryRange}, + index, + }; - use crate::pack::INDEX_V2; - use crate::{fixture_path, pack::V2_PACKS_AND_INDICES}; + use crate::{ + fixture_path, + pack::{INDEX_V2, V2_PACKS_AND_INDICES}, + }; #[test] fn write_to_stream() -> Result<(), Box> { diff --git a/git-pack/tests/pack/multi_index/access.rs b/git-pack/tests/pack/multi_index/access.rs index 518f8feff3e..19d44cb9a55 100644 --- a/git-pack/tests/pack/multi_index/access.rs +++ b/git-pack/tests/pack/multi_index/access.rs @@ -1,7 +1,9 @@ -use super::multi_index; -use git_testtools::hex_to_id; use std::path::PathBuf; +use git_testtools::hex_to_id; + +use super::multi_index; + #[test] fn lookup_with_ambiguity() { let (file, _path) = multi_index(); diff --git a/git-repository/src/head.rs b/git-repository/src/head.rs index 6ca8e7f0ceb..58138aaefba 100644 --- a/git-repository/src/head.rs +++ b/git-repository/src/head.rs @@ -120,9 +120,10 @@ pub mod peel { PeelReference(#[from] reference::peel::Error), } } - use crate::head::Kind; pub use error::Error; + use crate::head::Kind; + mod peel_to_commit { use crate::object; diff --git a/git-repository/src/id.rs b/git-repository/src/id.rs index 07449dcca2a..04ff7300599 100644 --- a/git-repository/src/id.rs +++ b/git-repository/src/id.rs @@ -1,11 +1,9 @@ //! -use std::convert::TryInto; -use std::ops::Deref; +use std::{convert::TryInto, ops::Deref}; use git_hash::{oid, ObjectId}; -use crate::object::find; -use crate::{Id, Object}; +use crate::{object::find, Id, Object}; /// An [object id][ObjectId] infused with `Easy`. impl<'repo> Id<'repo> { @@ -99,8 +97,7 @@ pub struct Ancestors<'repo> { pub mod ancestors { use git_odb::FindExt; - use crate::id::Ancestors; - use crate::{ext::ObjectIdExt, Id}; + use crate::{ext::ObjectIdExt, id::Ancestors, Id}; impl<'repo> Id<'repo> { /// Obtain a platform for traversing ancestors of this commit. diff --git a/git-repository/src/object/commit.rs b/git-repository/src/object/commit.rs index 53e8183c042..10e1b0adeab 100644 --- a/git-repository/src/object/commit.rs +++ b/git-repository/src/object/commit.rs @@ -1,5 +1,4 @@ -use crate::bstr::BStr; -use crate::{Commit, Tree}; +use crate::{bstr::BStr, Commit, Tree}; mod error { use crate::object; diff --git a/git-repository/src/object/impls.rs b/git-repository/src/object/impls.rs index 980627a3c01..c3f5a22d841 100644 --- a/git-repository/src/object/impls.rs +++ b/git-repository/src/object/impls.rs @@ -1,7 +1,6 @@ use std::convert::TryFrom; -use crate::object; -use crate::{Commit, DetachedObject, Object, Tree}; +use crate::{object, Commit, DetachedObject, Object, Tree}; impl<'repo> std::fmt::Debug for Object<'repo> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { diff --git a/git-repository/src/object/peel.rs b/git-repository/src/object/peel.rs index 430c43ecc78..b4229c9fb81 100644 --- a/git-repository/src/object/peel.rs +++ b/git-repository/src/object/peel.rs @@ -1,7 +1,9 @@ //! -use crate::object; -use crate::object::{peel, Kind}; -use crate::Object; +use crate::{ + object, + object::{peel, Kind}, + Object, +}; /// pub mod to_kind { diff --git a/git-repository/src/object/tree.rs b/git-repository/src/object/tree.rs index ee9a93e0b8f..40fb211c673 100644 --- a/git-repository/src/object/tree.rs +++ b/git-repository/src/object/tree.rs @@ -2,8 +2,7 @@ use git_hash::ObjectId; use git_object::{bstr::BStr, TreeRefIter}; use git_odb::FindExt; -use crate::object::find; -use crate::Tree; +use crate::{object::find, Tree}; impl<'repo> Tree<'repo> { /// Obtain a tree instance by handing in all components that it is made up of. diff --git a/git-repository/src/path/is.rs b/git-repository/src/path/is.rs index 466b2891511..312352e37b7 100644 --- a/git-repository/src/path/is.rs +++ b/git-repository/src/path/is.rs @@ -1,6 +1,8 @@ //! -use std::ffi::OsStr; -use std::path::{Path, PathBuf}; +use std::{ + ffi::OsStr, + path::{Path, PathBuf}, +}; /// The error returned by [`git()`]. #[derive(Debug, thiserror::Error)] diff --git a/git-repository/src/reference/log.rs b/git-repository/src/reference/log.rs index 52ff9cb5116..e8556b048e6 100644 --- a/git-repository/src/reference/log.rs +++ b/git-repository/src/reference/log.rs @@ -1,10 +1,11 @@ //! use git_object::commit::MessageRef; - -use crate::bstr::{BStr, BString, ByteVec}; use git_ref::file::ReferenceExt; -use crate::Reference; +use crate::{ + bstr::{BStr, BString, ByteVec}, + Reference, +}; impl<'repo> Reference<'repo> { /// Return a platform for obtaining iterators over reference logs. diff --git a/git-repository/src/types.rs b/git-repository/src/types.rs index 5159983615d..89c74275d17 100644 --- a/git-repository/src/types.rs +++ b/git-repository/src/types.rs @@ -1,8 +1,9 @@ use std::{cell::RefCell, path::PathBuf}; -use crate::head; use git_hash::ObjectId; +use crate::head; + /// The head reference, as created from looking at `.git/HEAD`, able to represent all of its possible states. /// /// Note that like [`Reference`], this type's data is snapshot of persisted state on disk. diff --git a/git-repository/tests/easy/id.rs b/git-repository/tests/easy/id.rs index 88f46e4c628..cfce5fa02fd 100644 --- a/git-repository/tests/easy/id.rs +++ b/git-repository/tests/easy/id.rs @@ -1,6 +1,7 @@ +use std::cmp::Ordering; + use git_repository::prelude::ObjectIdExt; use git_testtools::hex_to_id; -use std::cmp::Ordering; #[test] fn prefix() -> crate::Result { diff --git a/git-repository/tests/easy/object.rs b/git-repository/tests/easy/object.rs index b6f094d16c5..fb28a217a96 100644 --- a/git-repository/tests/easy/object.rs +++ b/git-repository/tests/easy/object.rs @@ -1,7 +1,8 @@ mod commit { + use std::cmp::Ordering; + use git_repository::{Commit, Repository}; use git_testtools::hex_to_id; - use std::cmp::Ordering; use crate::basic_repo; diff --git a/git-repository/tests/repo.rs b/git-repository/tests/repo.rs index 4dbcbb9422f..d42204658a6 100644 --- a/git-repository/tests/repo.rs +++ b/git-repository/tests/repo.rs @@ -1,5 +1,4 @@ -use git_repository::Repository; -use git_repository::ThreadSafeRepository; +use git_repository::{Repository, ThreadSafeRepository}; type Result = std::result::Result>; diff --git a/git-revision/src/describe.rs b/git-revision/src/describe.rs index c0fc0fcc0d6..c330171c5fc 100644 --- a/git-revision/src/describe.rs +++ b/git-revision/src/describe.rs @@ -1,6 +1,9 @@ +use std::{ + borrow::Cow, + fmt::{Display, Formatter}, +}; + use git_object::bstr::BStr; -use std::borrow::Cow; -use std::fmt::{Display, Formatter}; #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] pub struct Outcome<'a> { @@ -67,13 +70,16 @@ impl<'a> Display for Format<'a> { } pub(crate) mod function { - use super::Outcome; + use std::{ + borrow::Cow, + collections::{hash_map, HashMap, VecDeque}, + iter::FromIterator, + }; + use git_hash::{oid, ObjectId}; - use git_object::bstr::BStr; - use git_object::CommitRefIter; - use std::borrow::Cow; - use std::collections::{hash_map, HashMap, VecDeque}; - use std::iter::FromIterator; + use git_object::{bstr::BStr, CommitRefIter}; + + use super::Outcome; #[allow(clippy::result_unit_err)] pub fn describe<'a, Find, E>( diff --git a/git-revision/tests/describe/format.rs b/git-revision/tests/describe/format.rs index f52bb311315..772e991e826 100644 --- a/git-revision/tests/describe/format.rs +++ b/git-revision/tests/describe/format.rs @@ -1,7 +1,8 @@ +use std::borrow::Cow; + use git_object::bstr::ByteSlice; use git_revision::describe; use git_testtools::hex_to_id; -use std::borrow::Cow; #[test] fn exact_match_with_dirty_and_long() { diff --git a/git-revision/tests/describe/mod.rs b/git-revision/tests/describe/mod.rs index 13c5e8c628a..e351547720d 100644 --- a/git-revision/tests/describe/mod.rs +++ b/git-revision/tests/describe/mod.rs @@ -1,9 +1,9 @@ +use std::borrow::Cow; + use git_object::bstr::ByteSlice; -use git_repository::odb::FindExt; -use git_repository::Repository; +use git_repository::{odb::FindExt, Repository}; use git_revision::describe; use git_testtools::hex_to_id; -use std::borrow::Cow; mod format; diff --git a/git-tempfile/examples/try-deadlock-on-cleanup.rs b/git-tempfile/examples/try-deadlock-on-cleanup.rs index 4f4940e959f..c6fb6222061 100644 --- a/git-tempfile/examples/try-deadlock-on-cleanup.rs +++ b/git-tempfile/examples/try-deadlock-on-cleanup.rs @@ -1,10 +1,13 @@ -use std::path::Path; -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::sync::Arc; -use std::time::Duration; +use std::{ + path::Path, + sync::{ + atomic::{AtomicUsize, Ordering}, + Arc, + }, + time::Duration, +}; -use git_tempfile::handle::Writable; -use git_tempfile::{AutoRemove, ContainingDirectory, Handle}; +use git_tempfile::{handle::Writable, AutoRemove, ContainingDirectory, Handle}; fn main() -> Result<(), Box> { let secs_to_run: usize = std::env::args() diff --git a/git-worktree/src/index/checkout.rs b/git-worktree/src/index/checkout.rs index 81098247040..7208ec8c584 100644 --- a/git-worktree/src/index/checkout.rs +++ b/git-worktree/src/index/checkout.rs @@ -1,6 +1,7 @@ -use bstr::BString; use std::path::PathBuf; +use bstr::BString; + /// A cache for directory creation to reduce the amount of stat calls when creating /// directories safely, that is without following symlinks that might be on the way. /// @@ -35,9 +36,10 @@ pub struct PathCache { } mod cache { + use std::path::{Path, PathBuf}; + use super::PathCache; use crate::os; - use std::path::{Path, PathBuf}; impl PathCache { /// Create a new instance with `root` being the base for all future paths we handle, assuming it to be valid which includes diff --git a/git-worktree/src/index/entry.rs b/git-worktree/src/index/entry.rs index 2cdb507c914..f937b0d310b 100644 --- a/git-worktree/src/index/entry.rs +++ b/git-worktree/src/index/entry.rs @@ -1,13 +1,11 @@ -use std::path::Path; -use std::{convert::TryInto, fs::OpenOptions, io::Write, time::Duration}; +use std::{convert::TryInto, fs::OpenOptions, io::Write, path::Path, time::Duration}; use bstr::BStr; use git_hash::oid; use git_index::Entry; use io_close::Close; -use crate::index::checkout::PathCache; -use crate::{index, os}; +use crate::{index, index::checkout::PathCache, os}; #[cfg_attr(not(unix), allow(unused_variables))] pub fn checkout( diff --git a/git-worktree/src/index/mod.rs b/git-worktree/src/index/mod.rs index 2629966c121..72bf4e64db4 100644 --- a/git-worktree/src/index/mod.rs +++ b/git-worktree/src/index/mod.rs @@ -1,9 +1,8 @@ -use git_features::parallel::in_parallel; -use git_features::progress::Progress; -use git_features::{interrupt, progress}; -use git_hash::oid; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; +use git_features::{interrupt, parallel::in_parallel, progress, progress::Progress}; +use git_hash::oid; + use crate::index::checkout::PathCache; pub mod checkout; @@ -111,19 +110,27 @@ where } mod chunk { + use std::sync::atomic::{AtomicUsize, Ordering}; + use bstr::BStr; use git_features::progress::Progress; use git_hash::oid; - use std::sync::atomic::{AtomicUsize, Ordering}; - use crate::index::{checkout, checkout::PathCache, entry}; - use crate::{index, os}; + use crate::{ + index, + index::{checkout, checkout::PathCache, entry}, + os, + }; mod reduce { - use crate::index::checkout; + use std::{ + marker::PhantomData, + sync::atomic::{AtomicUsize, Ordering}, + }; + use git_features::progress::Progress; - use std::marker::PhantomData; - use std::sync::atomic::{AtomicUsize, Ordering}; + + use crate::index::checkout; pub struct Reduce<'a, 'entry, P1, P2, E> { pub files: &'a mut P1, diff --git a/git-worktree/src/os.rs b/git-worktree/src/os.rs index 620162e57e0..a297e73cd87 100644 --- a/git-worktree/src/os.rs +++ b/git-worktree/src/os.rs @@ -1,6 +1,4 @@ -use std::io; -use std::io::ErrorKind::AlreadyExists; -use std::path::Path; +use std::{io, io::ErrorKind::AlreadyExists, path::Path}; #[cfg(not(windows))] pub fn create_symlink(original: &Path, link: &Path) -> io::Result<()> { diff --git a/git-worktree/tests/worktree/index/checkout.rs b/git-worktree/tests/worktree/index/checkout.rs index 8beaa6e8fd1..4551124a883 100644 --- a/git-worktree/tests/worktree/index/checkout.rs +++ b/git-worktree/tests/worktree/index/checkout.rs @@ -1,7 +1,8 @@ mod cache { + use std::path::Path; + use git_index::entry::Mode; use git_worktree::index::checkout::PathCache; - use std::path::Path; use tempfile::{tempdir, TempDir}; #[test] @@ -100,16 +101,15 @@ mod cache { use std::os::unix::prelude::MetadataExt; use std::{ fs, - io::ErrorKind, + io::{ErrorKind, ErrorKind::AlreadyExists}, path::{Path, PathBuf}, + sync::atomic::{AtomicBool, AtomicUsize, Ordering}, }; use git_features::progress; use git_object::bstr::ByteSlice; use git_odb::FindExt; use git_worktree::{fs::Capabilities, index, index::checkout::Collision}; -use std::io::ErrorKind::AlreadyExists; -use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use tempfile::TempDir; use crate::fixture_path; diff --git a/gitoxide-core/src/index/checkout.rs b/gitoxide-core/src/index/checkout.rs index 3bbe1f269d9..bdbd2aba6bd 100644 --- a/gitoxide-core/src/index/checkout.rs +++ b/gitoxide-core/src/index/checkout.rs @@ -1,10 +1,16 @@ -use crate::index; -use crate::index::{parse_file, Options}; +use std::{ + path::{Path, PathBuf}, + sync::atomic::{AtomicBool, Ordering}, +}; + use anyhow::bail; use git::{odb::FindExt, worktree::index::checkout, Progress}; use git_repository as git; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicBool, Ordering}; + +use crate::{ + index, + index::{parse_file, Options}, +}; pub fn checkout_exclusive( index_path: impl AsRef, diff --git a/gitoxide-core/src/index/entries.rs b/gitoxide-core/src/index/entries.rs index b6133866103..8f86e50862e 100644 --- a/gitoxide-core/src/index/entries.rs +++ b/gitoxide-core/src/index/entries.rs @@ -1,7 +1,9 @@ -use crate::index::{parse_file, Options}; -use git_repository as git; use std::path::Path; +use git_repository as git; + +use crate::index::{parse_file, Options}; + pub fn entries( index_path: impl AsRef, mut out: impl std::io::Write, diff --git a/gitoxide-core/src/mailmap.rs b/gitoxide-core/src/mailmap.rs index 95c6abccbb7..43bcd650ea8 100644 --- a/gitoxide-core/src/mailmap.rs +++ b/gitoxide-core/src/mailmap.rs @@ -1,9 +1,9 @@ -use crate::OutputFormat; +use std::{collections::HashSet, io::Write, path::Path}; + use anyhow::{bail, Context}; use git_repository as git; -use std::collections::HashSet; -use std::io::Write; -use std::path::Path; + +use crate::OutputFormat; pub const PROGRESS_RANGE: std::ops::RangeInclusive = 1..=2; diff --git a/gitoxide-core/src/organize.rs b/gitoxide-core/src/organize.rs index 88588e60250..17f312212a4 100644 --- a/gitoxide-core/src/organize.rs +++ b/gitoxide-core/src/organize.rs @@ -1,5 +1,7 @@ -use std::ffi::OsStr; -use std::path::{Path, PathBuf}; +use std::{ + ffi::OsStr, + path::{Path, PathBuf}, +}; use git_config::file::GitConfig; use git_repository::{objs::bstr::ByteSlice, progress, Progress}; diff --git a/gitoxide-core/src/pack/multi_index.rs b/gitoxide-core/src/pack/multi_index.rs index ec02e0dc3e4..1bbe7fddde6 100644 --- a/gitoxide-core/src/pack/multi_index.rs +++ b/gitoxide-core/src/pack/multi_index.rs @@ -1,10 +1,11 @@ -use anyhow::bail; use std::{io::BufWriter, path::PathBuf, sync::atomic::AtomicBool}; -use crate::OutputFormat; +use anyhow::bail; use git_repository as git; use git_repository::Progress; +use crate::OutputFormat; + pub const PROGRESS_RANGE: std::ops::RangeInclusive = 1..=3; pub fn verify(multi_index_path: PathBuf, progress: impl Progress, should_interrupt: &AtomicBool) -> anyhow::Result<()> { diff --git a/gitoxide-core/src/repository/mailmap.rs b/gitoxide-core/src/repository/mailmap.rs index 71cd8b768a0..b513de5d23f 100644 --- a/gitoxide-core/src/repository/mailmap.rs +++ b/gitoxide-core/src/repository/mailmap.rs @@ -1,9 +1,10 @@ -use crate::OutputFormat; +use std::{io, path::PathBuf}; + use git_repository as git; #[cfg(feature = "serde1")] use git_repository::mailmap::Entry; -use std::io; -use std::path::PathBuf; + +use crate::OutputFormat; #[cfg(feature = "serde1")] #[cfg_attr(feature = "serde1", derive(serde::Serialize))] diff --git a/gitoxide-core/src/repository/odb.rs b/gitoxide-core/src/repository/odb.rs index 8dede354726..21b329b4284 100644 --- a/gitoxide-core/src/repository/odb.rs +++ b/gitoxide-core/src/repository/odb.rs @@ -1,13 +1,15 @@ -use crate::OutputFormat; +use std::{io, path::PathBuf}; + use anyhow::bail; use git_repository as git; -use std::io; -use std::path::PathBuf; + +use crate::OutputFormat; mod info { - use git_repository::odb::store; use std::path::PathBuf; + use git_repository::odb::store; + #[cfg_attr(feature = "serde1", derive(serde::Serialize))] pub struct Statistics { pub path: PathBuf, diff --git a/gitoxide-core/src/repository/tree.rs b/gitoxide-core/src/repository/tree.rs index 3586bc2759c..83dfcc81af0 100644 --- a/gitoxide-core/src/repository/tree.rs +++ b/gitoxide-core/src/repository/tree.rs @@ -1,23 +1,24 @@ +use std::{borrow::Cow, io, path::PathBuf}; + use anyhow::bail; -use std::borrow::Cow; -use std::io; -use std::path::PathBuf; +use git_repository as git; +use git_repository::{prelude::ObjectIdExt, Tree}; use crate::OutputFormat; -use git_repository as git; -use git_repository::prelude::ObjectIdExt; -use git_repository::Tree; mod entries { - use git_repository as git; use std::collections::VecDeque; - use crate::repository::tree::format_entry; - use git::bstr::{BStr, BString}; - use git::objs::tree::EntryRef; - use git::traverse::tree::visit::Action; + use git::{ + bstr::{BStr, BString}, + objs::tree::EntryRef, + traverse::tree::visit::Action, + }; + use git_repository as git; use git_repository::bstr::{ByteSlice, ByteVec}; + use crate::repository::tree::format_entry; + #[cfg_attr(feature = "serde1", derive(serde::Serialize))] #[derive(Default)] pub struct Statistics { diff --git a/src/plumbing/main.rs b/src/plumbing/main.rs index 56735c157e7..7ee58b17661 100644 --- a/src/plumbing/main.rs +++ b/src/plumbing/main.rs @@ -12,12 +12,10 @@ use clap::Parser; use gitoxide_core as core; use gitoxide_core::pack::verify; -use crate::plumbing::options::mailmap; -use crate::plumbing::options::pack::multi_index; #[cfg(any(feature = "gitoxide-core-async-client", feature = "gitoxide-core-blocking-client"))] use crate::plumbing::options::remote; use crate::{ - plumbing::options::{commitgraph, index, pack, repo, Args, Subcommands}, + plumbing::options::{commitgraph, index, mailmap, pack, pack::multi_index, repo, Args, Subcommands}, shared::pretty::prepare_and_run, };