diff --git a/gitoxide-core/src/repository/attributes/query.rs b/gitoxide-core/src/repository/attributes/query.rs index f1a719e9173..83e8bf67f07 100644 --- a/gitoxide-core/src/repository/attributes/query.rs +++ b/gitoxide-core/src/repository/attributes/query.rs @@ -1,6 +1,7 @@ -use crate::OutputFormat; use gix::repository::IndexPersistedOrInMemory; +use crate::OutputFormat; + pub struct Options { pub format: OutputFormat, pub statistics: bool, @@ -10,12 +11,13 @@ pub(crate) mod function { use std::{io, path::Path}; use anyhow::{anyhow, bail}; - use gix::bstr::BStr; - use gix::prelude::FindExt; + use gix::{bstr::BStr, prelude::FindExt}; - use crate::repository::PathsOrPatterns; use crate::{ - repository::attributes::query::{attributes_cache, Options}, + repository::{ + attributes::query::{attributes_cache, Options}, + PathsOrPatterns, + }, OutputFormat, }; diff --git a/gitoxide-core/src/repository/attributes/validate_baseline.rs b/gitoxide-core/src/repository/attributes/validate_baseline.rs index 50ec100b47d..a4645620344 100644 --- a/gitoxide-core/src/repository/attributes/validate_baseline.rs +++ b/gitoxide-core/src/repository/attributes/validate_baseline.rs @@ -18,8 +18,7 @@ pub(crate) mod function { }; use anyhow::{anyhow, bail}; - use gix::bstr::BString; - use gix::{attrs::Assignment, odb::FindExt, Progress}; + use gix::{attrs::Assignment, bstr::BString, odb::FindExt, Progress}; use crate::{ repository::attributes::{query::attributes_cache, validate_baseline::Options}, diff --git a/gitoxide-core/src/repository/commit.rs b/gitoxide-core/src/repository/commit.rs index febd67a70e0..17ce99e5f3c 100644 --- a/gitoxide-core/src/repository/commit.rs +++ b/gitoxide-core/src/repository/commit.rs @@ -1,6 +1,6 @@ +use std::{io::Write, process::Stdio}; + use anyhow::{anyhow, bail, Context, Result}; -use std::io::Write; -use std::process::Stdio; /// Note that this is a quick implementation of commit signature verification that ignores a lot of what /// git does and can do, while focussing on the gist of it. diff --git a/gitoxide-core/src/repository/exclude.rs b/gitoxide-core/src/repository/exclude.rs index a7f538e188e..d42e9fcade4 100644 --- a/gitoxide-core/src/repository/exclude.rs +++ b/gitoxide-core/src/repository/exclude.rs @@ -1,11 +1,9 @@ use std::io; use anyhow::{anyhow, bail}; -use gix::bstr::BStr; -use gix::prelude::FindExt; +use gix::{bstr::BStr, prelude::FindExt}; -use crate::repository::PathsOrPatterns; -use crate::OutputFormat; +use crate::{repository::PathsOrPatterns, OutputFormat}; pub mod query { use std::ffi::OsString; diff --git a/gitoxide-core/src/repository/fetch.rs b/gitoxide-core/src/repository/fetch.rs index 311273d2b2b..35240a3b498 100644 --- a/gitoxide-core/src/repository/fetch.rs +++ b/gitoxide-core/src/repository/fetch.rs @@ -18,8 +18,11 @@ pub const PROGRESS_RANGE: std::ops::RangeInclusive = 1..=3; pub(crate) mod function { use anyhow::bail; - use gix::remote::fetch::refs::update::TypeChange; - use gix::{prelude::ObjectIdExt, refspec::match_group::validate::Fix, remote::fetch::Status}; + use gix::{ + prelude::ObjectIdExt, + refspec::match_group::validate::Fix, + remote::fetch::{refs::update::TypeChange, Status}, + }; use layout::{ backends::svg::SVGWriter, core::{base::Orientation, geometry::Point, style::StyleAttr}, diff --git a/gitoxide-core/src/repository/index/entries.rs b/gitoxide-core/src/repository/index/entries.rs index 4b9da6dc647..02c3503529f 100644 --- a/gitoxide-core/src/repository/index/entries.rs +++ b/gitoxide-core/src/repository/index/entries.rs @@ -17,19 +17,23 @@ pub enum Attributes { } pub(crate) mod function { - use gix::bstr::{BStr, BString}; - use std::collections::BTreeSet; use std::{ borrow::Cow, + collections::BTreeSet, io::{BufWriter, Write}, }; - use crate::OutputFormat; - use gix::odb::FindExt; - use gix::repository::IndexPersistedOrInMemory; - use gix::Repository; + use gix::{ + bstr::{BStr, BString}, + odb::FindExt, + repository::IndexPersistedOrInMemory, + Repository, + }; - use crate::repository::index::entries::{Attributes, Options}; + use crate::{ + repository::index::entries::{Attributes, Options}, + OutputFormat, + }; pub fn entries( repo: gix::Repository, diff --git a/gitoxide-core/src/repository/mod.rs b/gitoxide-core/src/repository/mod.rs index e5e63bcb42e..6e25218df75 100644 --- a/gitoxide-core/src/repository/mod.rs +++ b/gitoxide-core/src/repository/mod.rs @@ -1,7 +1,7 @@ -use gix::bstr::BString; use std::path::PathBuf; use anyhow::{Context as AnyhowContext, Result}; +use gix::bstr::BString; pub fn init(directory: Option) -> Result { gix::create::into( diff --git a/gix-actor/src/identity.rs b/gix-actor/src/identity.rs index 382c0615ae6..9507afdc297 100644 --- a/gix-actor/src/identity.rs +++ b/gix-actor/src/identity.rs @@ -1,6 +1,5 @@ use bstr::ByteSlice; -use winnow::error::StrContext; -use winnow::prelude::*; +use winnow::{error::StrContext, prelude::*}; use crate::{signature::decode, Identity, IdentityRef}; diff --git a/gix-actor/src/signature/decode.rs b/gix-actor/src/signature/decode.rs index 87673b451e9..e8d14d3cd70 100644 --- a/gix-actor/src/signature/decode.rs +++ b/gix-actor/src/signature/decode.rs @@ -3,9 +3,7 @@ pub(crate) mod function { use btoi::btoi; use gix_date::{time::Sign, OffsetInSeconds, SecondsSinceUnixEpoch, Time}; use winnow::{ - combinator::alt, - combinator::separated_pair, - combinator::terminated, + combinator::{alt, separated_pair, terminated}, error::{AddContext, ParserError, StrContext}, prelude::*, stream::AsChar, diff --git a/gix-actor/src/signature/mod.rs b/gix-actor/src/signature/mod.rs index c70a4f3cdcd..cb91bd8eb9f 100644 --- a/gix-actor/src/signature/mod.rs +++ b/gix-actor/src/signature/mod.rs @@ -1,7 +1,6 @@ mod _ref { use bstr::ByteSlice; - use winnow::error::StrContext; - use winnow::prelude::*; + use winnow::{error::StrContext, prelude::*}; use crate::{signature::decode, IdentityRef, Signature, SignatureRef}; diff --git a/gix-config/src/parse/nom/mod.rs b/gix-config/src/parse/nom/mod.rs index 9d0723061b8..1ae2f8593d1 100644 --- a/gix-config/src/parse/nom/mod.rs +++ b/gix-config/src/parse/nom/mod.rs @@ -2,12 +2,7 @@ use std::borrow::Cow; use bstr::{BStr, ByteSlice}; use winnow::{ - combinator::alt, - combinator::delimited, - combinator::fold_repeat, - combinator::opt, - combinator::preceded, - combinator::repeat, + combinator::{alt, delimited, fold_repeat, opt, preceded, repeat}, error::{ErrorKind, InputError as NomError, ParserError as _}, prelude::*, stream::{Offset as _, Stream as _}, diff --git a/gix-config/src/parse/nom/tests.rs b/gix-config/src/parse/nom/tests.rs index 401b3f94e91..65f6e4b8fdf 100644 --- a/gix-config/src/parse/nom/tests.rs +++ b/gix-config/src/parse/nom/tests.rs @@ -1,9 +1,10 @@ use super::*; mod section_headers { + use winnow::prelude::*; + use super::section_header; use crate::parse::tests::util::{fully_consumed, section_header as parsed_section_header}; - use winnow::prelude::*; #[test] fn no_subsection() { @@ -116,6 +117,7 @@ mod section_headers { mod sub_section { use std::borrow::Cow; + use winnow::prelude::*; use super::sub_section; @@ -859,9 +861,10 @@ mod key_value_pair { } mod comment { + use winnow::prelude::*; + use super::comment; use crate::parse::tests::util::{comment as parsed_comment, fully_consumed}; - use winnow::prelude::*; #[test] fn semicolon() { diff --git a/gix-object/src/commit/decode.rs b/gix-object/src/commit/decode.rs index 1d361b255c1..0b8243ef34b 100644 --- a/gix-object/src/commit/decode.rs +++ b/gix-object/src/commit/decode.rs @@ -2,11 +2,7 @@ use std::borrow::Cow; use smallvec::SmallVec; use winnow::{ - combinator::alt, - combinator::preceded, - combinator::repeat, - combinator::terminated, - combinator::{eof, opt, rest}, + combinator::{alt, eof, opt, preceded, repeat, rest, terminated}, error::{AddContext, ParserError, StrContext}, prelude::*, token::take_till1, diff --git a/gix-object/src/commit/message/body.rs b/gix-object/src/commit/message/body.rs index 779d4ac0bd0..6301bf30ee7 100644 --- a/gix-object/src/commit/message/body.rs +++ b/gix-object/src/commit/message/body.rs @@ -1,10 +1,7 @@ use std::ops::Deref; use winnow::{ - combinator::eof, - combinator::rest, - combinator::separated_pair, - combinator::terminated, + combinator::{eof, rest, separated_pair, terminated}, error::{ErrorKind, ParserError}, prelude::*, token::take_until1, diff --git a/gix-object/src/commit/message/decode.rs b/gix-object/src/commit/message/decode.rs index 8a63bdc782e..8038009b430 100644 --- a/gix-object/src/commit/message/decode.rs +++ b/gix-object/src/commit/message/decode.rs @@ -1,6 +1,9 @@ use winnow::{ - combinator::alt, combinator::eof, combinator::preceded, combinator::rest, combinator::terminated, - error::ParserError, prelude::*, stream::Offset, stream::Stream, token::take_till1, + combinator::{alt, eof, preceded, rest, terminated}, + error::ParserError, + prelude::*, + stream::{Offset, Stream}, + token::take_till1, }; use crate::bstr::{BStr, ByteSlice}; diff --git a/gix-object/src/commit/mod.rs b/gix-object/src/commit/mod.rs index f1748b558a4..b3de9b0a4b9 100644 --- a/gix-object/src/commit/mod.rs +++ b/gix-object/src/commit/mod.rs @@ -1,6 +1,7 @@ -use bstr::{BStr, BString, ByteSlice}; use std::ops::Range; +use bstr::{BStr, BString, ByteSlice}; + use crate::{Commit, CommitRef, TagRef}; mod decode; diff --git a/gix-object/src/commit/ref_iter.rs b/gix-object/src/commit/ref_iter.rs index e411bc7fd51..4401384ca88 100644 --- a/gix-object/src/commit/ref_iter.rs +++ b/gix-object/src/commit/ref_iter.rs @@ -1,19 +1,21 @@ -use std::borrow::Cow; -use std::ops::Range; +use std::{borrow::Cow, ops::Range}; use bstr::BStr; use gix_hash::{oid, ObjectId}; use winnow::{ - combinator::alt, - combinator::terminated, - combinator::{eof, opt}, + combinator::{alt, eof, opt, terminated}, error::StrContext, prelude::*, token::take_till1, }; -use crate::commit::SignedData; -use crate::{bstr::ByteSlice, commit::decode, parse, parse::NL, CommitRefIter}; +use crate::{ + bstr::ByteSlice, + commit::{decode, SignedData}, + parse, + parse::NL, + CommitRefIter, +}; #[derive(Copy, Clone)] pub(crate) enum SignatureKind { diff --git a/gix-object/src/parse.rs b/gix-object/src/parse.rs index 4b60429a645..0013d9b72a3 100644 --- a/gix-object/src/parse.rs +++ b/gix-object/src/parse.rs @@ -1,7 +1,6 @@ use bstr::{BStr, BString, ByteVec}; use winnow::{ - combinator::repeat, - combinator::{preceded, terminated}, + combinator::{preceded, repeat, terminated}, error::{AddContext, ParserError, StrContext}, prelude::*, token::{take_till1, take_until0, take_while}, diff --git a/gix-object/src/tag/decode.rs b/gix-object/src/tag/decode.rs index 804c70285af..73a9286380d 100644 --- a/gix-object/src/tag/decode.rs +++ b/gix-object/src/tag/decode.rs @@ -1,9 +1,5 @@ use winnow::{ - combinator::alt, - combinator::delimited, - combinator::rest, - combinator::{eof, opt}, - combinator::{preceded, terminated}, + combinator::{alt, delimited, eof, opt, preceded, rest, terminated}, error::{AddContext, ParserError, StrContext}, prelude::*, stream::AsChar, diff --git a/gix-object/src/tag/ref_iter.rs b/gix-object/src/tag/ref_iter.rs index fcb3e4bc3da..b3956ff8378 100644 --- a/gix-object/src/tag/ref_iter.rs +++ b/gix-object/src/tag/ref_iter.rs @@ -1,10 +1,8 @@ use bstr::BStr; use gix_hash::{oid, ObjectId}; use winnow::{ - combinator::terminated, - combinator::{eof, opt}, - error::ParserError, - error::StrContext, + combinator::{eof, opt, terminated}, + error::{ParserError, StrContext}, prelude::*, stream::AsChar, token::take_while, diff --git a/gix-object/src/tree/ref_iter.rs b/gix-object/src/tree/ref_iter.rs index 14453c4bd86..be1244910ef 100644 --- a/gix-object/src/tree/ref_iter.rs +++ b/gix-object/src/tree/ref_iter.rs @@ -1,6 +1,6 @@ -use bstr::BStr; use std::convert::TryFrom; +use bstr::BStr; use winnow::error::ParserError; use crate::{tree, tree::EntryRef, TreeRef, TreeRefIter}; @@ -117,9 +117,7 @@ mod decode { use bstr::ByteSlice; use winnow::{ - combinator::eof, - combinator::repeat, - combinator::terminated, + combinator::{eof, repeat, terminated}, error::ParserError, prelude::*, stream::AsChar, diff --git a/gix-pathspec/src/defaults.rs b/gix-pathspec/src/defaults.rs index 81f26b9f9bf..2ed7a09182a 100644 --- a/gix-pathspec/src/defaults.rs +++ b/gix-pathspec/src/defaults.rs @@ -1,7 +1,7 @@ -use crate::Defaults; -use crate::{MagicSignature, SearchMode}; use std::ffi::OsString; +use crate::{Defaults, MagicSignature, SearchMode}; + /// pub mod from_environment { /// The error returned by [Defaults::from_environment()](super::Defaults::from_environment()). diff --git a/gix-pathspec/src/lib.rs b/gix-pathspec/src/lib.rs index d97e8765020..550f142e2eb 100644 --- a/gix-pathspec/src/lib.rs +++ b/gix-pathspec/src/lib.rs @@ -3,10 +3,10 @@ #![deny(missing_docs, rust_2018_idioms)] #![forbid(unsafe_code)] -use bitflags::bitflags; -use bstr::BString; use std::path::PathBuf; +use bitflags::bitflags; +use bstr::BString; /// `gix-glob` types are available through [`attributes::glob`]. pub use gix_attributes as attributes; diff --git a/gix-pathspec/src/pattern.rs b/gix-pathspec/src/pattern.rs index 43eb91209bf..5aed06d1ab1 100644 --- a/gix-pathspec/src/pattern.rs +++ b/gix-pathspec/src/pattern.rs @@ -1,7 +1,9 @@ -use crate::{normalize, MagicSignature, Pattern, SearchMode}; -use bstr::{BStr, BString, ByteSlice, ByteVec}; use std::path::{Component, Path, PathBuf}; +use bstr::{BStr, BString, ByteSlice, ByteVec}; + +use crate::{normalize, MagicSignature, Pattern, SearchMode}; + /// Access impl Pattern { /// Returns `true` if this seems to be a pathspec that indicates that 'there is no pathspec'. diff --git a/gix-pathspec/src/search/init.rs b/gix-pathspec/src/search/init.rs index 210db7b0904..02d7ce9e172 100644 --- a/gix-pathspec/src/search/init.rs +++ b/gix-pathspec/src/search/init.rs @@ -1,7 +1,7 @@ -use crate::search::Spec; -use crate::{MagicSignature, Pattern, Search}; use std::path::Path; +use crate::{search::Spec, MagicSignature, Pattern, Search}; + /// Create a new specification to support matches from `pathspec`, [normalizing](Pattern::normalize()) it with `prefix` and `root`. fn mapping_from_pattern( mut pathspec: Pattern, diff --git a/gix-pathspec/src/search/matching.rs b/gix-pathspec/src/search/matching.rs index fd4d9a9e4a2..85c3a73f1b5 100644 --- a/gix-pathspec/src/search/matching.rs +++ b/gix-pathspec/src/search/matching.rs @@ -1,8 +1,11 @@ -use crate::search::{Match, Spec}; -use crate::{MagicSignature, Pattern, Search, SearchMode}; use bstr::{BStr, BString, ByteSlice}; use gix_glob::pattern::Case; +use crate::{ + search::{Match, Spec}, + MagicSignature, Pattern, Search, SearchMode, +}; + impl Search { /// Return the first [`Match`] of `relative_path`, or `None`. /// `is_dir` is true if `relative_path` is a directory. diff --git a/gix-pathspec/src/search/mod.rs b/gix-pathspec/src/search/mod.rs index 3f7405df7ff..ff76df0144e 100644 --- a/gix-pathspec/src/search/mod.rs +++ b/gix-pathspec/src/search/mod.rs @@ -1,6 +1,7 @@ -use crate::{Pattern, Search}; use bstr::{BStr, ByteSlice}; +use crate::{Pattern, Search}; + /// Describes a matching pattern within a search for ignored paths. #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] pub struct Match<'a> { diff --git a/gix-pathspec/tests/defaults.rs b/gix-pathspec/tests/defaults.rs index 9e80e60059c..ed3dc7a0377 100644 --- a/gix-pathspec/tests/defaults.rs +++ b/gix-pathspec/tests/defaults.rs @@ -1,5 +1,4 @@ -use gix_pathspec::Defaults; -use gix_pathspec::{MagicSignature, SearchMode}; +use gix_pathspec::{Defaults, MagicSignature, SearchMode}; use serial_test::serial; #[test] diff --git a/gix-pathspec/tests/search/mod.rs b/gix-pathspec/tests/search/mod.rs index 2929e86cb9c..55cd8a114f4 100644 --- a/gix-pathspec/tests/search/mod.rs +++ b/gix-pathspec/tests/search/mod.rs @@ -142,9 +142,10 @@ fn pathspecs(input: &[&str]) -> Vec { } mod baseline { - use bstr::{BString, ByteSlice}; use std::path::{Path, PathBuf}; + use bstr::{BString, ByteSlice}; + pub fn run( name: &str, items_are_dirs: bool, diff --git a/gix-ref/src/store/file/log/line.rs b/gix-ref/src/store/file/log/line.rs index 434e89c43b1..6e121efd162 100644 --- a/gix-ref/src/store/file/log/line.rs +++ b/gix-ref/src/store/file/log/line.rs @@ -75,13 +75,7 @@ impl<'a> From> for Line { pub mod decode { use gix_object::bstr::{BStr, ByteSlice}; use winnow::{ - combinator::alt, - combinator::eof, - combinator::fail, - combinator::opt, - combinator::preceded, - combinator::rest, - combinator::terminated, + combinator::{alt, eof, fail, opt, preceded, rest, terminated}, error::{AddContext, ParserError, StrContext}, prelude::*, token::take_while, @@ -190,8 +184,7 @@ pub mod decode { mod invalid { use gix_testtools::to_bstr_err; - use winnow::error::TreeError; - use winnow::prelude::*; + use winnow::{error::TreeError, prelude::*}; use super::one; diff --git a/gix-ref/src/store/file/loose/reference/decode.rs b/gix-ref/src/store/file/loose/reference/decode.rs index d2e71851d7c..7ba89837383 100644 --- a/gix-ref/src/store/file/loose/reference/decode.rs +++ b/gix-ref/src/store/file/loose/reference/decode.rs @@ -2,7 +2,11 @@ use std::convert::{TryFrom, TryInto}; use gix_hash::ObjectId; use gix_object::bstr::BString; -use winnow::{combinator::opt, combinator::terminated, prelude::*, token::take_while}; +use winnow::{ + combinator::{opt, terminated}, + prelude::*, + token::take_while, +}; use crate::{ parse::{hex_hash, newline}, diff --git a/gix-ref/src/store/packed/buffer.rs b/gix-ref/src/store/packed/buffer.rs index 7135ab0f346..c20a965a13b 100644 --- a/gix-ref/src/store/packed/buffer.rs +++ b/gix-ref/src/store/packed/buffer.rs @@ -20,8 +20,7 @@ pub mod open { use std::path::PathBuf; use memmap2::Mmap; - use winnow::prelude::*; - use winnow::stream::Offset; + use winnow::{prelude::*, stream::Offset}; use crate::store_impl::packed; diff --git a/gix-ref/src/store/packed/decode.rs b/gix-ref/src/store/packed/decode.rs index da246fdc817..b4f8e8562e6 100644 --- a/gix-ref/src/store/packed/decode.rs +++ b/gix-ref/src/store/packed/decode.rs @@ -2,8 +2,7 @@ use std::convert::TryInto; use gix_object::bstr::{BStr, ByteSlice}; use winnow::{ - combinator::opt, - combinator::{delimited, preceded, terminated}, + combinator::{delimited, opt, preceded, terminated}, error::{FromExternalError, ParserError}, prelude::*, token::take_while, diff --git a/gix-ref/src/store/packed/decode/tests.rs b/gix-ref/src/store/packed/decode/tests.rs index 92a1d0434d3..e864ee99917 100644 --- a/gix-ref/src/store/packed/decode/tests.rs +++ b/gix-ref/src/store/packed/decode/tests.rs @@ -1,8 +1,7 @@ type Result = std::result::Result<(), Box>; mod reference { - use winnow::error::TreeError; - use winnow::prelude::*; + use winnow::{error::TreeError, prelude::*}; use super::Result; use crate::{ diff --git a/gix-ref/src/store/packed/iter.rs b/gix-ref/src/store/packed/iter.rs index 85934042f25..665ed410d16 100644 --- a/gix-ref/src/store/packed/iter.rs +++ b/gix-ref/src/store/packed/iter.rs @@ -1,8 +1,9 @@ use gix_object::bstr::{BString, ByteSlice}; -use winnow::combinator::preceded; -use winnow::combinator::rest; -use winnow::prelude::*; -use winnow::stream::Stream as _; +use winnow::{ + combinator::{preceded, rest}, + prelude::*, + stream::Stream as _, +}; use crate::store_impl::{packed, packed::decode}; diff --git a/gix-ref/tests/file/store/find.rs b/gix-ref/tests/file/store/find.rs index 17f47a0bd57..b718ca4d0c5 100644 --- a/gix-ref/tests/file/store/find.rs +++ b/gix-ref/tests/file/store/find.rs @@ -90,8 +90,7 @@ mod existing { } mod loose { - use crate::file::store; - use crate::util::hex_to_id; + use crate::{file::store, util::hex_to_id}; mod existing { use std::path::Path; diff --git a/gix-submodule/src/access.rs b/gix-submodule/src/access.rs index ce0a1325a33..4e688aabfb2 100644 --- a/gix-submodule/src/access.rs +++ b/gix-submodule/src/access.rs @@ -1,9 +1,12 @@ -use crate::config::{Branch, FetchRecurse, Ignore, Update}; -use crate::{config, File, IsActivePlatform}; +use std::{borrow::Cow, collections::HashSet, path::Path}; + use bstr::BStr; -use std::borrow::Cow; -use std::collections::HashSet; -use std::path::Path; + +use crate::{ + config, + config::{Branch, FetchRecurse, Ignore, Update}, + File, IsActivePlatform, +}; /// High-Level Access /// diff --git a/gix-submodule/src/is_active_platform.rs b/gix-submodule/src/is_active_platform.rs index d195fa8c92f..8e75fdea1e7 100644 --- a/gix-submodule/src/is_active_platform.rs +++ b/gix-submodule/src/is_active_platform.rs @@ -1,6 +1,7 @@ -use crate::IsActivePlatform; use bstr::BStr; +use crate::IsActivePlatform; + /// The error returned by [File::names_and_active_state](crate::File::names_and_active_state()). #[derive(Debug, thiserror::Error)] #[allow(missing_docs)] diff --git a/gix-submodule/src/lib.rs b/gix-submodule/src/lib.rs index e55431e2a14..c2721fcdbc1 100644 --- a/gix-submodule/src/lib.rs +++ b/gix-submodule/src/lib.rs @@ -2,9 +2,9 @@ #![deny(rust_2018_idioms, missing_docs)] #![forbid(unsafe_code)] +use std::{borrow::Cow, collections::BTreeMap}; + use bstr::BStr; -use std::borrow::Cow; -use std::collections::BTreeMap; /// All relevant information about a git module, typically from `.gitmodules` files. /// @@ -86,9 +86,10 @@ impl File { /// mod init { - use crate::File; use std::path::PathBuf; + use crate::File; + impl std::fmt::Debug for File { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("File") diff --git a/gix-submodule/tests/file/baseline.rs b/gix-submodule/tests/file/baseline.rs index 83b26fabdd4..ad9934205c4 100644 --- a/gix-submodule/tests/file/baseline.rs +++ b/gix-submodule/tests/file/baseline.rs @@ -1,7 +1,7 @@ +use std::{ffi::OsStr, path::PathBuf}; + use bstr::ByteSlice; use gix_features::fs::walkdir::Parallelism; -use std::ffi::OsStr; -use std::path::PathBuf; #[test] fn common_values_and_names_by_path() -> crate::Result { diff --git a/gix-submodule/tests/file/mod.rs b/gix-submodule/tests/file/mod.rs index 2f465cc1e16..94c2728ca5a 100644 --- a/gix-submodule/tests/file/mod.rs +++ b/gix-submodule/tests/file/mod.rs @@ -3,9 +3,10 @@ fn submodule(bytes: &str) -> gix_submodule::File { } mod is_active_platform { - use bstr::{BStr, ByteSlice}; use std::str::FromStr; + use bstr::{BStr, ByteSlice}; + fn multi_modules() -> crate::Result { let modules = gix_testtools::scripted_fixture_read_only("basic.sh")? .join("multiple") @@ -115,9 +116,10 @@ mod is_active_platform { } mod path { - use crate::file::submodule; use gix_submodule::config::path::Error; + use crate::file::submodule; + fn submodule_path(value: &str) -> Error { let module = submodule(&format!("[submodule.a]\npath = {value}")); module.path("a".into()).unwrap_err() @@ -156,9 +158,10 @@ mod path { } mod url { - use crate::file::submodule; use gix_submodule::config::url::Error; + use crate::file::submodule; + fn submodule_url(value: &str) -> Error { let module = submodule(&format!("[submodule.a]\nurl = {value}")); module.url("a".into()).unwrap_err() @@ -189,11 +192,12 @@ mod url { } mod update { - use crate::file::submodule; - use gix_submodule::config::update::Error; - use gix_submodule::config::Update; use std::str::FromStr; + use gix_submodule::config::{update::Error, Update}; + + use crate::file::submodule; + fn submodule_update(value: &str) -> Error { let module = submodule(&format!("[submodule.a]\nupdate = {value}")); module.update("a".into()).unwrap_err() @@ -253,9 +257,10 @@ mod update { } mod fetch_recurse { - use crate::file::submodule; use gix_submodule::config::FetchRecurse; + use crate::file::submodule; + #[test] fn default() { assert_eq!( @@ -298,9 +303,10 @@ mod fetch_recurse { } mod ignore { - use crate::file::submodule; use gix_submodule::config::Ignore; + use crate::file::submodule; + #[test] fn default() { assert_eq!(Ignore::default(), Ignore::None, "as defined in the docs"); @@ -336,9 +342,10 @@ mod ignore { } mod branch { - use crate::file::submodule; use gix_submodule::config::Branch; + use crate::file::submodule; + #[test] fn valid() -> crate::Result { for (valid, expected) in [ @@ -382,9 +389,10 @@ fn shallow() -> crate::Result { } mod append_submodule_overrides { - use crate::file::submodule; use std::str::FromStr; + use crate::file::submodule; + #[test] fn last_of_multiple_values_wins() -> crate::Result { let mut module = submodule("[submodule.a] url = from-module"); diff --git a/gix-worktree-state/src/checkout/chunk.rs b/gix-worktree-state/src/checkout/chunk.rs index 46d09bac28c..930e70b89be 100644 --- a/gix-worktree-state/src/checkout/chunk.rs +++ b/gix-worktree-state/src/checkout/chunk.rs @@ -5,9 +5,9 @@ use std::{ use bstr::{BStr, BString}; use gix_hash::oid; +use gix_worktree::Stack; use crate::{checkout, checkout::entry}; -use gix_worktree::Stack; mod reduce { use std::marker::PhantomData; diff --git a/gix-worktree-state/src/checkout/entry.rs b/gix-worktree-state/src/checkout/entry.rs index 68cb796aa54..0ef81ed230c 100644 --- a/gix-worktree-state/src/checkout/entry.rs +++ b/gix-worktree-state/src/checkout/entry.rs @@ -8,9 +8,8 @@ use bstr::BStr; use gix_filter::{driver::apply::MaybeDelayed, pipeline::convert::ToWorktreeOutcome}; use gix_hash::oid; use gix_index::{entry::Stat, Entry}; -use io_close::Close; - use gix_worktree::Stack; +use io_close::Close; pub struct Context<'a, Find> { pub find: &'a mut Find, diff --git a/gix-worktree-state/src/checkout/function.rs b/gix-worktree-state/src/checkout/function.rs index b29a6e69356..507d59bc5cc 100644 --- a/gix-worktree-state/src/checkout/function.rs +++ b/gix-worktree-state/src/checkout/function.rs @@ -2,9 +2,9 @@ use std::sync::atomic::AtomicBool; use gix_features::{interrupt, parallel::in_parallel_with_finalize, progress::Progress}; use gix_hash::oid; +use gix_worktree::{stack, Stack}; use crate::checkout::chunk; -use gix_worktree::{stack, Stack}; /// Checkout the entire `index` into `dir`, and resolve objects found in index entries with `find` to write their content to their /// respective path in `dir`. diff --git a/gix/src/config/cache/access.rs b/gix/src/config/cache/access.rs index b91b1a0fcb3..5f373362860 100644 --- a/gix/src/config/cache/access.rs +++ b/gix/src/config/cache/access.rs @@ -4,11 +4,11 @@ use std::{borrow::Cow, path::PathBuf, time::Duration}; use gix_attributes::Source; use gix_lock::acquire::Fail; -use crate::config::boolean; use crate::{ bstr::BStr, config, config::{ + boolean, cache::util::{ApplyLeniency, ApplyLeniencyDefault, ApplyLeniencyDefaultValue}, checkout_options, tree::{gitoxide, Checkout, Core, Key}, diff --git a/gix/src/interrupt.rs b/gix/src/interrupt.rs index 0adc8f115d9..89e3bc5d428 100644 --- a/gix/src/interrupt.rs +++ b/gix/src/interrupt.rs @@ -138,14 +138,12 @@ mod init { Ok(Deregister::default()) } } -pub use init::Deregister; - use std::{ io, sync::atomic::{AtomicBool, Ordering}, }; -pub use init::init_handler; +pub use init::{init_handler, Deregister}; /// A wrapper for an inner iterator which will check for interruptions on each iteration. pub struct Iter { diff --git a/gix/src/pathspec.rs b/gix/src/pathspec.rs index b917498725e..f701f210961 100644 --- a/gix/src/pathspec.rs +++ b/gix/src/pathspec.rs @@ -1,9 +1,9 @@ //! Pathspec plumbing and abstractions -use crate::bstr::BStr; -use crate::{Pathspec, Repository}; use gix_odb::FindExt; pub use gix_pathspec::*; +use crate::{bstr::BStr, Pathspec, Repository}; + /// pub mod init { /// The error returned by [`Pathspec::new()`](super::Pathspec::new()). diff --git a/gix/src/remote/connection/fetch/update_refs/tests.rs b/gix/src/remote/connection/fetch/update_refs/tests.rs index f0470cb3e0b..3baacbaf3da 100644 --- a/gix/src/remote/connection/fetch/update_refs/tests.rs +++ b/gix/src/remote/connection/fetch/update_refs/tests.rs @@ -45,15 +45,19 @@ mod update { let repo = gix::open_opts(dir.path().join(name), restricted()).unwrap(); (repo, dir) } - use gix_ref::transaction::{LogChange, PreviousValue, RefEdit, RefLog}; - use gix_ref::{transaction::Change, Target, TargetRef}; + use gix_ref::{ + transaction::{Change, LogChange, PreviousValue, RefEdit, RefLog}, + Target, TargetRef, + }; - use crate::remote::fetch::refs::update::TypeChange; use crate::{ bstr::BString, remote::{ fetch, - fetch::{refs::tests::restricted, Mapping, RefLogMessage, Source, SpecIndex}, + fetch::{ + refs::{tests::restricted, update::TypeChange}, + Mapping, RefLogMessage, Source, SpecIndex, + }, }, }; diff --git a/gix/src/repository/pathspec.rs b/gix/src/repository/pathspec.rs index 37556ac1713..729ff0ecb91 100644 --- a/gix/src/repository/pathspec.rs +++ b/gix/src/repository/pathspec.rs @@ -1,8 +1,7 @@ -use crate::bstr::BStr; -use crate::config::cache::util::ApplyLeniencyDefault; -use crate::{Pathspec, Repository}; use gix_pathspec::MagicSignature; +use crate::{bstr::BStr, config::cache::util::ApplyLeniencyDefault, Pathspec, Repository}; + impl Repository { /// Create a new pathspec abstraction that allows to conduct searches using `patterns`. /// `inherit_ignore_case` should be `true` if `patterns` will match against files on disk, or `false` otherwise, for more natural matching diff --git a/gix/src/repository/submodule.rs b/gix/src/repository/submodule.rs index 5c7ac361915..78e43825e0d 100644 --- a/gix/src/repository/submodule.rs +++ b/gix/src/repository/submodule.rs @@ -1,6 +1,7 @@ -use crate::{submodule, Repository}; use std::rc::Rc; +use crate::{submodule, Repository}; + impl Repository { /// Open the `.gitmodules` file as present in the worktree, or return `None` if no such file is available. /// Note that git configuration is also contributing to the result based on the current snapshot. diff --git a/gix/src/submodule/mod.rs b/gix/src/submodule/mod.rs index 9f7bdb75e6f..ff88f3b439b 100644 --- a/gix/src/submodule/mod.rs +++ b/gix/src/submodule/mod.rs @@ -1,17 +1,17 @@ #![allow(clippy::result_large_err)] //! Submodule plumbing and abstractions //! -use crate::bstr::BStr; -use crate::{Id, Repository, Submodule}; -use gix_odb::FindExt; -use std::borrow::Cow; -use std::cell::{Ref, RefCell, RefMut}; -use std::path::PathBuf; +use std::{ + borrow::Cow, + cell::{Ref, RefCell, RefMut}, + path::PathBuf, +}; -use crate::ext::ObjectIdExt; -use crate::repository::IndexPersistedOrInMemory; +use gix_odb::FindExt; pub use gix_submodule::*; +use crate::{bstr::BStr, ext::ObjectIdExt, repository::IndexPersistedOrInMemory, Id, Repository, Submodule}; + pub(crate) type ModulesFileStorage = gix_features::threading::OwnShared>; /// A lazily loaded and auto-updated worktree index. pub type ModulesSnapshot = gix_fs::SharedFileSnapshot; diff --git a/gix/src/types.rs b/gix/src/types.rs index 881666a6f5d..db3c4395fed 100644 --- a/gix/src/types.rs +++ b/gix/src/types.rs @@ -1,10 +1,8 @@ -use std::rc::Rc; -use std::{cell::RefCell, path::PathBuf}; +use std::{cell::RefCell, path::PathBuf, rc::Rc}; use gix_hash::ObjectId; -use crate::bstr::BString; -use crate::{head, remote}; +use crate::{bstr::BString, head, remote}; /// A worktree checkout containing the files of the repository in consumable form. #[derive(Debug, Clone)] diff --git a/gix/src/worktree/mod.rs b/gix/src/worktree/mod.rs index 8ffe4d51208..18be6dc1fe6 100644 --- a/gix/src/worktree/mod.rs +++ b/gix/src/worktree/mod.rs @@ -185,10 +185,11 @@ pub mod attributes { /// pub mod pathspec { - use crate::bstr::BStr; - use crate::config::cache::util::ApplyLeniencyDefaultValue; - use crate::config::tree::gitoxide; - use crate::Worktree; + use crate::{ + bstr::BStr, + config::{cache::util::ApplyLeniencyDefaultValue, tree::gitoxide}, + Worktree, + }; /// The error returned by [`Worktree::pathspec()`]. #[derive(Debug, thiserror::Error)] diff --git a/gix/tests/config/tree.rs b/gix/tests/config/tree.rs index 40a1ac69167..f98c82fea99 100644 --- a/gix/tests/config/tree.rs +++ b/gix/tests/config/tree.rs @@ -146,8 +146,8 @@ mod ssh { } mod fetch { - use gix::bstr::ByteSlice; use gix::{ + bstr::ByteSlice, config::tree::{Fetch, Key}, remote::fetch::negotiate::Algorithm, }; diff --git a/gix/tests/interrupt.rs b/gix/tests/interrupt.rs index 6508e376598..c84674867fc 100644 --- a/gix/tests/interrupt.rs +++ b/gix/tests/interrupt.rs @@ -1,6 +1,7 @@ -use signal_hook::consts::SIGTERM; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; +use signal_hook::consts::SIGTERM; + #[test] fn multi_registration() -> gix_testtools::Result { static V1: AtomicUsize = AtomicUsize::new(0); diff --git a/gix/tests/repository/pathspec.rs b/gix/tests/repository/pathspec.rs index 052d731ecd1..2ff17d5d50b 100644 --- a/gix/tests/repository/pathspec.rs +++ b/gix/tests/repository/pathspec.rs @@ -1,8 +1,8 @@ -use crate::util::named_repo; -use gix::bstr::ByteSlice; -use gix::config::tree::gitoxide; +use gix::{bstr::ByteSlice, config::tree::gitoxide}; use gix_worktree::stack::state::attributes::Source; +use crate::util::named_repo; + #[test] fn defaults_are_taken_from_repo_config() -> crate::Result { let mut repo = named_repo("make_basic_repo.sh")?; diff --git a/gix/tests/repository/submodule.rs b/gix/tests/repository/submodule.rs index 35b5defe044..b83990074c9 100644 --- a/gix/tests/repository/submodule.rs +++ b/gix/tests/repository/submodule.rs @@ -58,10 +58,9 @@ mod modules_file { } mod submodules { - use crate::submodule::repo; - use crate::util::hex_to_id; - use gix::bstr::BString; - use gix::Id; + use gix::{bstr::BString, Id}; + + use crate::{submodule::repo, util::hex_to_id}; #[test] fn all_modules_are_active_by_default() -> crate::Result { diff --git a/gix/tests/submodule/mod.rs b/gix/tests/submodule/mod.rs index 1cd8201fe76..5f556deea61 100644 --- a/gix/tests/submodule/mod.rs +++ b/gix/tests/submodule/mod.rs @@ -4,9 +4,10 @@ pub fn repo(name: &str) -> crate::Result { } mod open { - use crate::submodule::repo; use gix::submodule; + use crate::submodule::repo; + #[test] fn various() -> crate::Result { for (name, expected) in [ diff --git a/src/plumbing/main.rs b/src/plumbing/main.rs index b32cbb68a4d..96bc8bf0b3a 100644 --- a/src/plumbing/main.rs +++ b/src/plumbing/main.rs @@ -10,10 +10,8 @@ use std::{ use anyhow::{Context, Result}; use clap::Parser; use gitoxide_core as core; -use gitoxide_core::pack::verify; -use gitoxide_core::repository::PathsOrPatterns; -use gix::bstr::io::BufReadExt; -use gix::bstr::BString; +use gitoxide_core::{pack::verify, repository::PathsOrPatterns}; +use gix::bstr::{io::BufReadExt, BString}; use crate::{ plumbing::{ diff --git a/src/plumbing/options/mod.rs b/src/plumbing/options/mod.rs index 7d9cfd75394..6243ced6588 100644 --- a/src/plumbing/options/mod.rs +++ b/src/plumbing/options/mod.rs @@ -589,9 +589,10 @@ pub mod revision { } pub mod attributes { - use crate::shared::CheckPathSpec; use gix::bstr::BString; + use crate::shared::CheckPathSpec; + #[derive(Debug, clap::Subcommand)] pub enum Subcommands { /// Run `git check-attr` and `git check-ignore` on all files of the index or all files passed via stdin and validate that @@ -617,9 +618,10 @@ pub mod attributes { } pub mod exclude { - use gix::bstr::BString; use std::ffi::OsString; + use gix::bstr::BString; + use crate::shared::CheckPathSpec; #[derive(Debug, clap::Subcommand)] @@ -647,10 +649,12 @@ pub mod exclude { } pub mod index { - use crate::shared::CheckPathSpec; - use gix::bstr::BString; use std::path::PathBuf; + use gix::bstr::BString; + + use crate::shared::CheckPathSpec; + pub mod entries { #[derive(Default, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)] pub enum Format {