Unified · Split
| @@ -1,8 +1,7 @@ | ||
| 1 | 1 | use std::borrow::Cow; |
| 2 | 2 | |
| 3 | −use crate::file::rename_section; | |
| 4 | 3 | use crate::{ |
| 5 | − file::{MutableSection, SectionBody}, | |
| 4 | + file::{rename_section, MutableSection, SectionBody}, | |
| 6 | 5 | lookup, |
| 7 | 6 | parse::section, |
| 8 | 7 | File, |
| @@ -2,9 +2,8 @@ use std::{borrow::Cow, collections::HashMap}; · 1 unmodified line | ||
| 2 | 2 | |
| 3 | 3 | use bstr::BStr; |
| 4 | 4 | |
| 5 | −use crate::file::mutable::value::EntryData; | |
| 6 | 5 | use crate::{ |
| 7 | − file::{Index, MutableMultiValue, MutableSection, MutableValue, Size}, | |
| 6 | + file::{mutable::value::EntryData, Index, MutableMultiValue, MutableSection, MutableValue, Size}, | |
| 8 | 7 | lookup, |
| 9 | 8 | parse::{section, Event}, |
| 10 | 9 | File, |
| @@ -1,6 +1,7 @@ | ||
| 1 | −use crate::File; | |
| 2 | 1 | use bstr::BString; |
| 3 | 2 | |
| 3 | +use crate::File; | |
| 4 | + | |
| 4 | 5 | impl File<'_> { |
| 5 | 6 | /// Serialize this type into a `BString` for convenience. |
| 6 | 7 | /// |
| @@ -1,5 +1,4 @@ | ||
| 1 | −use std::str::FromStr; | |
| 2 | −use std::{convert::TryFrom, fmt::Display}; | |
| 1 | +use std::{convert::TryFrom, fmt::Display, str::FromStr}; | |
| 3 | 2 | |
| 4 | 3 | use bstr::{BStr, BString}; |
| 5 | 4 | |
| @@ -2,8 +2,12 @@ use std::{borrow::Cow, path::PathBuf}; · 1 unmodified line | ||
| 2 | 2 | |
| 3 | 3 | use bstr::BString; |
| 4 | 4 | |
| 5 | −use crate::file::from_paths; | |
| 6 | −use crate::{file::init::resolve_includes, parse::section, path::interpolate, File}; | |
| 5 | +use crate::{ | |
| 6 | + file::{from_paths, init::resolve_includes}, | |
| 7 | + parse::section, | |
| 8 | + path::interpolate, | |
| 9 | + File, | |
| 10 | +}; | |
| 7 | 11 | |
| 8 | 12 | /// Represents the errors that may occur when calling [`File::from_env`][crate::File::from_env()]. |
| 9 | 13 | #[derive(Debug, thiserror::Error)] |
| @@ -6,9 +6,13 @@ use std::{ · 5 unmodified lines | ||
| 6 | 6 | use bstr::{BStr, BString, ByteSlice, ByteVec}; |
| 7 | 7 | use git_ref::Category; |
| 8 | 8 | |
| 9 | −use crate::file::init::from_paths; | |
| 10 | −use crate::file::init::from_paths::Options; | |
| 11 | −use crate::{file::SectionBodyId, File}; | |
| 9 | +use crate::{ | |
| 10 | + file::{ | |
| 11 | + init::{from_paths, from_paths::Options}, | |
| 12 | + SectionBodyId, | |
| 13 | + }, | |
| 14 | + File, | |
| 15 | +}; | |
| 12 | 16 | |
| 13 | 17 | pub(crate) fn resolve_includes( |
| 14 | 18 | conf: &mut File<'static>, |
| @@ -1,9 +1,9 @@ | ||
| 1 | −use crate::file::SectionBody; | |
| 2 | −use crate::parse::Event; | |
| 3 | −use bstr::{BStr, BString}; | |
| 4 | −use bstr::{ByteSlice, ByteVec}; | |
| 5 | 1 | use std::borrow::Cow; |
| 6 | 2 | |
| 3 | +use bstr::{BStr, BString, ByteSlice, ByteVec}; | |
| 4 | + | |
| 5 | +use crate::{file::SectionBody, parse::Event}; | |
| 6 | + | |
| 7 | 7 | fn escape_value(value: &BStr) -> BString { |
| 8 | 8 | let starts_with_whitespace = value.get(0).map_or(false, |b| b.is_ascii_whitespace()); |
| 9 | 9 | let ends_with_whitespace = value |
| @@ -6,9 +6,11 @@ use std::{ · 5 unmodified lines | ||
| 6 | 6 | |
| 7 | 7 | use bstr::{BStr, BString, ByteVec}; |
| 8 | 8 | |
| 9 | −use crate::file::mutable::{escape_value, Whitespace}; | |
| 10 | 9 | use crate::{ |
| 11 | − file::{Index, Size}, | |
| 10 | + file::{ | |
| 11 | + mutable::{escape_value, Whitespace}, | |
| 12 | + Index, Size, | |
| 13 | + }, | |
| 12 | 14 | lookup, parse, |
| 13 | 15 | parse::{section::Key, Event}, |
| 14 | 16 | value::{normalize, normalize_bstr, normalize_bstring}, |
| @@ -2,10 +2,15 @@ use std::{borrow::Cow, collections::HashMap, ops::DerefMut}; · 1 unmodified line | ||
| 2 | 2 | |
| 3 | 3 | use bstr::{BStr, BString, ByteVec}; |
| 4 | 4 | |
| 5 | −use crate::file::mutable::section::{MutableSection, SectionBody}; | |
| 6 | −use crate::file::mutable::{escape_value, Whitespace}; | |
| 7 | 5 | use crate::{ |
| 8 | − file::{Index, SectionBodyId, Size}, | |
| 6 | + file::{ | |
| 7 | + mutable::{ | |
| 8 | + escape_value, | |
| 9 | + section::{MutableSection, SectionBody}, | |
| 10 | + Whitespace, | |
| 11 | + }, | |
| 12 | + Index, SectionBodyId, Size, | |
| 13 | + }, | |
| 9 | 14 | lookup, |
| 10 | 15 | parse::{section, Event}, |
| 11 | 16 | value::{normalize_bstr, normalize_bstring}, |
| @@ -10,8 +10,10 @@ use std::{ · 9 unmodified lines | ||
| 10 | 10 | |
| 11 | 11 | use bstr::BStr; |
| 12 | 12 | |
| 13 | −use crate::file::{from_env, from_paths}; | |
| 14 | −use crate::{lookup, File}; | |
| 13 | +use crate::{ | |
| 14 | + file::{from_env, from_paths}, | |
| 15 | + lookup, File, | |
| 16 | +}; | |
| 15 | 17 | |
| 16 | 18 | // TODO: how does this relate to `File::from_env_paths()`? |
| 17 | 19 | #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] |
| @@ -1,8 +1,11 @@ | ||
| 1 | −use crate::parse::section::{into_cow_bstr, Header, Name}; | |
| 2 | −use crate::parse::Event; | |
| 1 | +use std::{borrow::Cow, fmt::Display}; | |
| 2 | + | |
| 3 | 3 | use bstr::{BStr, BString, ByteSlice, ByteVec}; |
| 4 | −use std::borrow::Cow; | |
| 5 | −use std::fmt::Display; | |
| 4 | + | |
| 5 | +use crate::parse::{ | |
| 6 | + section::{into_cow_bstr, Header, Name}, | |
| 7 | + Event, | |
| 8 | +}; | |
| 6 | 9 | |
| 7 | 10 | /// The error returned by [`Header::new(…)`][super::Header::new()]. |
| 8 | 11 | #[derive(Debug, PartialOrd, PartialEq, thiserror::Error)] |
| @@ -2,9 +2,10 @@ mod section { · 1 unmodified line | ||
| 2 | 2 | |
| 3 | 3 | mod header { |
| 4 | 4 | mod write_to { |
| 5 | − use crate::parse::section; | |
| 6 | 5 | use std::borrow::Cow; |
| 7 | 6 | |
| 7 | + use crate::parse::section; | |
| 8 | + | |
| 8 | 9 | fn header(name: &str, subsection: impl Into<Option<(&'static str, &'static str)>>) -> section::Header<'_> { |
| 9 | 10 | let name = section::Name(Cow::Borrowed(name.into())); |
| 10 | 11 | if let Some((separator, subsection_name)) = subsection.into() { |
| @@ -51,8 +52,7 @@ pub(crate) mod util { · 40 unmodified lines | ||
| 51 | 52 | //! This module is only included for tests, and contains common unit test helper |
| 52 | 53 | //! functions. |
| 53 | 54 | |
| 54 | − use std::borrow::Cow; | |
| 55 | − use std::convert::TryFrom; | |
| 55 | + use std::{borrow::Cow, convert::TryFrom}; | |
| 56 | 56 | |
| 57 | 57 | use crate::parse::{section, Comment, Event}; |
| 58 | 58 | |
| @@ -1,8 +1,7 @@ | ||
| 1 | 1 | mod rename_section { |
| 2 | − use git_config::file::rename_section; | |
| 3 | − use git_config::parse::section; | |
| 4 | − use std::borrow::Cow; | |
| 5 | − use std::convert::TryFrom; | |
| 2 | + use std::{borrow::Cow, convert::TryFrom}; | |
| 3 | + | |
| 4 | + use git_config::{file::rename_section, parse::section}; | |
| 6 | 5 | |
| 7 | 6 | #[test] |
| 8 | 7 | fn section_renaming_validates_new_name() { |
| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | use std::{borrow::Cow, env, fs}; |
| 2 | 2 | |
| 3 | −use git_config::file::from_paths::Options; | |
| 4 | −use git_config::file::{from_env, from_paths}; | |
| 5 | −use git_config::File; | |
| 3 | +use git_config::{ | |
| 4 | + file::{from_env, from_paths, from_paths::Options}, | |
| 5 | + File, | |
| 6 | +}; | |
| 6 | 7 | use serial_test::serial; |
| 7 | 8 | use tempfile::tempdir; |
| 8 | 9 | |
| @@ -8,8 +8,10 @@ use std::{ · 7 unmodified lines | ||
| 8 | 8 | |
| 9 | 9 | use bstr::{BString, ByteSlice}; |
| 10 | 10 | |
| 11 | −use crate::file::cow_str; | |
| 12 | −use crate::file::init::from_paths::{escape_backslashes, includes::conditional::options_with_git_dir}; | |
| 11 | +use crate::file::{ | |
| 12 | + cow_str, | |
| 13 | + init::from_paths::{escape_backslashes, includes::conditional::options_with_git_dir}, | |
| 14 | +}; | |
| 13 | 15 | |
| 14 | 16 | #[derive(Debug)] |
| 15 | 17 | pub struct GitEnv { |
| @@ -1,11 +1,9 @@ | ||
| 1 | 1 | use std::{fs, path::Path}; |
| 2 | 2 | |
| 3 | −use git_config::file::from_paths; | |
| 4 | −use git_config::{path, File}; | |
| 3 | +use git_config::{file::from_paths, path, File}; | |
| 5 | 4 | use tempfile::tempdir; |
| 6 | 5 | |
| 7 | −use crate::file::cow_str; | |
| 8 | −use crate::file::init::from_paths::escape_backslashes; | |
| 6 | +use crate::file::{cow_str, init::from_paths::escape_backslashes}; | |
| 9 | 7 | |
| 10 | 8 | mod gitdir; |
| 11 | 9 | mod onbranch; |
| @@ -1,11 +1,9 @@ | ||
| 1 | 1 | use std::fs; |
| 2 | 2 | |
| 3 | −use git_config::file::from_paths; | |
| 4 | −use git_config::File; | |
| 3 | +use git_config::{file::from_paths, File}; | |
| 5 | 4 | use tempfile::tempdir; |
| 6 | 5 | |
| 7 | −use crate::file::cow_str; | |
| 8 | −use crate::file::init::from_paths::escape_backslashes; | |
| 6 | +use crate::file::{cow_str, init::from_paths::escape_backslashes}; | |
| 9 | 7 | |
| 10 | 8 | #[test] |
| 11 | 9 | fn multiple() -> crate::Result { |
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | mod get { |
| 2 | − use crate::file::cow_str; | |
| 3 | − use crate::file::mutable::multi_value::init_config; | |
| 2 | + use crate::file::{cow_str, mutable::multi_value::init_config}; | |
| 4 | 3 | |
| 5 | 4 | #[test] |
| 6 | 5 | fn single_lines() -> crate::Result { |
| @@ -50,8 +49,7 @@ mod access { · 43 unmodified lines | ||
| 50 | 49 | } |
| 51 | 50 | |
| 52 | 51 | mod set { |
| 53 | − use crate::file::cow_str; | |
| 54 | − use crate::file::mutable::multi_value::init_config; | |
| 52 | + use crate::file::{cow_str, mutable::multi_value::init_config}; | |
| 55 | 53 | |
| 56 | 54 | #[test] |
| 57 | 55 | fn values_are_escaped() -> crate::Result { |
| @@ -1,8 +1,10 @@ | ||
| 1 | 1 | mod push { |
| 2 | − use crate::file::cow_str; | |
| 3 | − use git_config::parse::section::Key; | |
| 4 | 2 | use std::convert::TryFrom; |
| 5 | 3 | |
| 4 | + use git_config::parse::section::Key; | |
| 5 | + | |
| 6 | + use crate::file::cow_str; | |
| 7 | + | |
| 6 | 8 | #[test] |
| 7 | 9 | fn whitespace_is_derived_from_whitespace_before_first_value() -> crate::Result { |
| 8 | 10 | for (input, expected_pre_key, expected_sep) in [ |
| @@ -58,10 +60,12 @@ mod push { · 49 unmodified lines | ||
| 58 | 60 | } |
| 59 | 61 | |
| 60 | 62 | mod set_leading_whitespace { |
| 61 | − use crate::file::cow_str; | |
| 62 | − use git_config::parse::section::Key; | |
| 63 | 63 | use std::convert::TryFrom; |
| 64 | 64 | |
| 65 | + use git_config::parse::section::Key; | |
| 66 | + | |
| 67 | + use crate::file::cow_str; | |
| 68 | + | |
| 65 | 69 | #[test] |
| 66 | 70 | fn any_whitespace_is_ok() -> crate::Result { |
| 67 | 71 | let mut config = git_config::File::default(); |
| @@ -1,7 +1,8 @@ | ||
| 1 | 1 | mod get { |
| 2 | − use crate::file::mutable::value::init_config; | |
| 3 | 2 | use bstr::BString; |
| 4 | 3 | |
| 4 | + use crate::file::mutable::value::init_config; | |
| 5 | + | |
| 5 | 6 | fn config_get(input: &str) -> BString { |
| 6 | 7 | let mut file: git_config::File = input.parse().unwrap(); |
| 7 | 8 | file.raw_value_mut("a", None, "k").unwrap().get().unwrap().into_owned() |
| @@ -1,6 +1,7 @@ | ||
| 1 | −use super::*; | |
| 2 | 1 | use git_config::parse::Events; |
| 3 | 2 | |
| 3 | +use super::*; | |
| 4 | + | |
| 4 | 5 | #[test] |
| 5 | 6 | #[rustfmt::skip] |
| 6 | 7 | fn complex() { |
| @@ -1,5 +1,4 @@ | ||
| 1 | −use std::borrow::Cow; | |
| 2 | −use std::convert::TryFrom; | |
| 1 | +use std::{borrow::Cow, convert::TryFrom}; | |
| 3 | 2 | |
| 4 | 3 | use git_config::parse::{Event, Events, Section}; |
| 5 | 4 | |
| @@ -1,16 +1,17 @@ | ||
| 1 | −use git_config::parse::section; | |
| 2 | −use git_config::parse::Event; | |
| 3 | 1 | use std::borrow::Cow; |
| 4 | 2 | |
| 3 | +use git_config::parse::{section, Event}; | |
| 4 | + | |
| 5 | 5 | pub fn header_event(name: &'static str, subsection: impl Into<Option<&'static str>>) -> Event<'static> { |
| 6 | 6 | Event::SectionHeader(section::Header::new(name, subsection.into().map(Cow::Borrowed)).unwrap()) |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | mod header { |
| 10 | 10 | mod write_to { |
| 11 | − use git_config::parse::section; | |
| 12 | 11 | use std::borrow::Cow; |
| 13 | 12 | |
| 13 | + use git_config::parse::section; | |
| 14 | + | |
| 14 | 15 | #[test] |
| 15 | 16 | fn subsection_backslashes_and_quotes_are_escaped() -> crate::Result { |
| 16 | 17 | assert_eq!( |
| @@ -34,9 +35,10 @@ mod header { · 17 unmodified lines | ||
| 34 | 35 | } |
| 35 | 36 | } |
| 36 | 37 | mod new { |
| 37 | − use git_config::parse::section; | |
| 38 | 38 | use std::borrow::Cow; |
| 39 | 39 | |
| 40 | + use git_config::parse::section; | |
| 41 | + | |
| 40 | 42 | #[test] |
| 41 | 43 | fn names_must_be_mostly_ascii() { |
| 42 | 44 | for name in ["🤗", "x.y", "x y", "x\ny"] { |
| @@ -61,9 +63,10 @@ mod header { · 18 unmodified lines | ||
| 61 | 63 | } |
| 62 | 64 | } |
| 63 | 65 | mod name { |
| 64 | − use git_config::parse::section::Name; | |
| 65 | 66 | use std::convert::TryFrom; |
| 66 | 67 | |
| 68 | + use git_config::parse::section::Name; | |
| 69 | + | |
| 67 | 70 | #[test] |
| 68 | 71 | fn alphanum_and_dash_are_valid() { |
| 69 | 72 | assert!(Name::try_from("1a").is_ok()); |
| @@ -80,9 +83,9 @@ mod name { · 10 unmodified lines | ||
| 80 | 83 | } |
| 81 | 84 | |
| 82 | 85 | mod key { |
| 86 | + use std::{cmp::Ordering, convert::TryFrom}; | |
| 87 | + | |
| 83 | 88 | use git_config::parse::section::Key; |
| 84 | − use std::cmp::Ordering; | |
| 85 | − use std::convert::TryFrom; | |
| 86 | 89 | |
| 87 | 90 | fn key(k: &str) -> Key<'_> { |
| 88 | 91 | Key::try_from(k).unwrap() |