History

[repository #190] cleanup usage of bstr…

…so that it always comes from git-object if possible, and so that major users like git-ref re-export it. The re-export is really something to possibly change to put that onto git-repository level, as well.

Sebastian Thiel committed 5 years ago

Commit e4411ff1 parent 1795a3344 files · +52 −54Browse files

Showing the changes to git-ref/src (28 of 44 files). Show all

Unified · Split

28 files
  1. git-ref/src/fullname.rs +1 −1
  2. git-ref/src/lib.rs +3 −2
  3. git-ref/src/name.rs +1 −1
  4. git-ref/src/namespace.rs +1 −1
  5. git-ref/src/parse.rs +1 −1
  6. git-ref/src/peel.rs +1 −1
  7. git-ref/src/raw.rs +1 −1
  8. git-ref/src/store/file/find.rs +1 −1
  9. git-ref/src/store/file/log/iter.rs +2 −2
  10. git-ref/src/store/file/log/line.rs +4 −4
  11. git-ref/src/store/file/log/mod.rs +1 −1
  12. git-ref/src/store/file/loose/iter.rs +1 −1
  13. git-ref/src/store/file/loose/reference/decode.rs +1 −1
  14. git-ref/src/store/file/loose/reflog.rs +1 −1
  15. git-ref/src/store/file/loose/reflog/create_or_update/tests.rs +1 −1
  16. git-ref/src/store/file/mod.rs +2 −2
  17. git-ref/src/store/file/overlay.rs +1 −1
  18. git-ref/src/store/file/transaction/commit.rs +1 −1
  19. git-ref/src/store/file/transaction/mod.rs +1 −1
  20. git-ref/src/store/file/transaction/prepare.rs +1 −1
  21. git-ref/src/store/packed/decode.rs +1 −1
  22. git-ref/src/store/packed/decode/tests.rs +1 −1
  23. git-ref/src/store/packed/find.rs +1 −1
  24. git-ref/src/store/packed/iter.rs +2 −2
  25. git-ref/src/store/packed/mod.rs +1 −1
  26. git-ref/src/target.rs +1 −1
  27. git-ref/src/transaction/ext.rs +1 −1
  28. git-ref/src/transaction/mod.rs +1 −1
git-ref/src/fullname.rs+1−1
@@ -1,6 +1,6 @@
1use std::{borrow::Cow, convert::TryFrom, path::Path};1use std::{borrow::Cow, convert::TryFrom, path::Path};
2 2
3use bstr::{BStr, BString, ByteSlice};3use git_object::bstr::{BStr, BString, ByteSlice};
4 4
5use crate::{FullName, FullNameRef};5use crate::{FullName, FullNameRef};
6 6
git-ref/src/lib.rs+3−2
@@ -18,8 +18,9 @@ · 17 unmodified lines
18//! * supersedes all of the above to allow handling hundreds of thousands of references.18//! * supersedes all of the above to allow handling hundreds of thousands of references.
19#![forbid(unsafe_code)]19#![forbid(unsafe_code)]
20#![deny(missing_docs, rust_2018_idioms)]20#![deny(missing_docs, rust_2018_idioms)]
21use bstr::{BStr, BString};
22use git_hash::{oid, ObjectId};21use git_hash::{oid, ObjectId};
22pub use git_object::bstr;
23use git_object::bstr::{BStr, BString};
23 24
24mod store;25mod store;
25pub use store::{file, packed};26pub use store::{file, packed};
@@ -41,8 +42,8 @@ mod target; · 15 unmodified lines
41 42
42///43///
43pub mod log {44pub mod log {
44 use bstr::BString;
45 use git_hash::ObjectId;45 use git_hash::ObjectId;
46 use git_object::bstr::BString;
46 47
47 /// A parsed ref log line that can be changed48 /// A parsed ref log line that can be changed
48 #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]49 #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
git-ref/src/name.rs+1−1
@@ -4,7 +4,7 @@ use std::{ · 3 unmodified lines
4 path::Path,4 path::Path,
5};5};
6 6
7use bstr::{BStr, ByteSlice};7use git_object::bstr::{BStr, ByteSlice};
8 8
9use crate::{FullNameRef, PartialNameRef};9use crate::{FullNameRef, PartialNameRef};
10 10
git-ref/src/namespace.rs+1−1
@@ -1,6 +1,6 @@
1use std::{borrow::Cow, convert::TryInto, path::Path};1use std::{borrow::Cow, convert::TryInto, path::Path};
2 2
3use bstr::{BStr, BString, ByteSlice, ByteVec};3use git_object::bstr::{BStr, BString, ByteSlice, ByteVec};
4 4
5use crate::{Namespace, PartialNameRef};5use crate::{Namespace, PartialNameRef};
6 6
git-ref/src/parse.rs+1−1
@@ -1,4 +1,4 @@
1use bstr::{BStr, ByteSlice};1use git_object::bstr::{BStr, ByteSlice};
2use nom::{2use nom::{
3 branch::alt,3 branch::alt,
4 bytes::complete::{tag, take_while_m_n},4 bytes::complete::{tag, take_while_m_n},
git-ref/src/peel.rs+1−1
@@ -10,7 +10,7 @@ pub fn none( · 9 unmodified lines
10pub mod to_id {10pub mod to_id {
11 use std::path::PathBuf;11 use std::path::PathBuf;
12 12
13 use bstr::BString;13 use git_object::bstr::BString;
14 use quick_error::quick_error;14 use quick_error::quick_error;
15 15
16 use crate::file;16 use crate::file;
git-ref/src/raw.rs+1−1
@@ -55,7 +55,7 @@ mod convert { · 54 unmodified lines
55}55}
56 56
57mod access {57mod access {
58 use bstr::ByteSlice;58 use git_object::bstr::ByteSlice;
59 59
60 use crate::{raw::Reference, FullNameRef, Namespace};60 use crate::{raw::Reference, FullNameRef, Namespace};
61 61
git-ref/src/store/file/find.rs+1−1
@@ -4,8 +4,8 @@ use std::{ · 3 unmodified lines
4 path::{Path, PathBuf},4 path::{Path, PathBuf},
5};5};
6 6
7use bstr::ByteSlice;
8pub use error::Error;7pub use error::Error;
8use git_object::bstr::ByteSlice;
9 9
10use crate::{10use crate::{
11 file,11 file,
git-ref/src/store/file/log/iter.rs+2−2
@@ -1,4 +1,4 @@
1use bstr::ByteSlice;1use git_object::bstr::ByteSlice;
2 2
3use crate::store::file::{log, log::iter::decode::LineNumber};3use crate::store::file::{log, log::iter::decode::LineNumber};
4 4
@@ -59,7 +59,7 @@ pub fn forward(lines: &[u8]) -> Forward<'_> { · 54 unmodified lines
59 59
60/// An iterator yielding parsed lines in a file from start to end, oldest to newest.60/// An iterator yielding parsed lines in a file from start to end, oldest to newest.
61pub struct Forward<'a> {61pub struct Forward<'a> {
62 inner: std::iter::Enumerate<bstr::Lines<'a>>,62 inner: std::iter::Enumerate<git_object::bstr::Lines<'a>>,
63}63}
64 64
65impl<'a> Iterator for Forward<'a> {65impl<'a> Iterator for Forward<'a> {
git-ref/src/store/file/log/line.rs+4−4
@@ -12,7 +12,7 @@ impl<'a> LineRef<'a> { · 11 unmodified lines
12mod write {12mod write {
13 use std::io;13 use std::io;
14 14
15 use bstr::{BStr, ByteSlice};15 use git_object::bstr::{BStr, ByteSlice};
16 use quick_error::quick_error;16 use quick_error::quick_error;
17 17
18 use crate::log::Line;18 use crate::log::Line;
@@ -77,7 +77,7 @@ impl<'a> From<LineRef<'a>> for Line { · 58 unmodified lines
77 77
78///78///
79pub mod decode {79pub mod decode {
80 use bstr::{BStr, ByteSlice};80 use git_object::bstr::{BStr, ByteSlice};
81 use nom::{81 use nom::{
82 bytes::complete::{tag, take_while},82 bytes::complete::{tag, take_while},
83 combinator::opt,83 combinator::opt,
@@ -90,7 +90,7 @@ pub mod decode { · 6 unmodified lines
90 90
91 ///91 ///
92 mod error {92 mod error {
93 use bstr::{BString, ByteSlice};93 use git_object::bstr::{BString, ByteSlice};
94 94
95 /// The error returned by [from_bytes(…)][super::Line::from_bytes()]95 /// The error returned by [from_bytes(…)][super::Line::from_bytes()]
96 #[derive(Debug)]96 #[derive(Debug)]
@@ -172,9 +172,9 @@ pub mod decode { · 75 unmodified lines
172 172
173 #[cfg(test)]173 #[cfg(test)]
174 mod test {174 mod test {
175 use bstr::ByteSlice;
176 use git_actor::{Sign, Time};175 use git_actor::{Sign, Time};
177 use git_hash::ObjectId;176 use git_hash::ObjectId;
177 use git_object::bstr::ByteSlice;
178 178
179 use super::*;179 use super::*;
180 180
git-ref/src/store/file/log/mod.rs+1−1
@@ -1,4 +1,4 @@
1use bstr::BStr;1use git_object::bstr::BStr;
2 2
3pub use super::loose::reflog::{create_or_update, Error};3pub use super::loose::reflog::{create_or_update, Error};
4 4
git-ref/src/store/file/loose/iter.rs+1−1
@@ -3,8 +3,8 @@ use std::{ · 2 unmodified lines
3 path::{Path, PathBuf},3 path::{Path, PathBuf},
4};4};
5 5
6use bstr::ByteSlice;
7use git_features::fs::walkdir::DirEntryIter;6use git_features::fs::walkdir::DirEntryIter;
7use git_object::bstr::ByteSlice;
8use os_str_bytes::OsStrBytes;8use os_str_bytes::OsStrBytes;
9 9
10use crate::{10use crate::{
git-ref/src/store/file/loose/reference/decode.rs+1−1
@@ -1,7 +1,7 @@
1use std::convert::{TryFrom, TryInto};1use std::convert::{TryFrom, TryInto};
2 2
3use bstr::BString;
4use git_hash::ObjectId;3use git_hash::ObjectId;
4use git_object::bstr::BString;
5use nom::{5use nom::{
6 bytes::complete::{tag, take_while},6 bytes::complete::{tag, take_while},
7 combinator::{map, opt},7 combinator::{map, opt},
git-ref/src/store/file/loose/reflog.rs+1−1
@@ -89,8 +89,8 @@ pub mod create_or_update { · 88 unmodified lines
89 path::{Path, PathBuf},89 path::{Path, PathBuf},
90 };90 };
91 91
92 use bstr::BStr;
93 use git_hash::{oid, ObjectId};92 use git_hash::{oid, ObjectId};
93 use git_object::bstr::BStr;
94 94
95 use crate::store::{file, file::WriteReflog};95 use crate::store::{file, file::WriteReflog};
96 96
git-ref/src/store/file/loose/reflog/create_or_update/tests.rs+1−1
@@ -1,8 +1,8 @@
1use super::*;1use super::*;
2use crate::{file::WriteReflog, FullNameRef};2use crate::{file::WriteReflog, FullNameRef};
3use bstr::ByteSlice;
4use git_actor::{Sign, Signature, Time};3use git_actor::{Sign, Signature, Time};
5use git_lock::acquire::Fail;4use git_lock::acquire::Fail;
5use git_object::bstr::ByteSlice;
6use git_testtools::hex_to_id;6use git_testtools::hex_to_id;
7use std::{convert::TryInto, path::Path};7use std::{convert::TryInto, path::Path};
8use tempfile::TempDir;8use tempfile::TempDir;
git-ref/src/store/file/mod.rs+2−2
@@ -38,12 +38,12 @@ pub struct Transaction<'s> { · 37 unmodified lines
38 namespace: Option<crate::Namespace>,38 namespace: Option<crate::Namespace>,
39}39}
40 40
41pub(in crate::store::file) fn path_to_name(path: impl Into<PathBuf>) -> bstr::BString {41pub(in crate::store::file) fn path_to_name(path: impl Into<PathBuf>) -> git_object::bstr::BString {
42 use os_str_bytes::OsStringBytes;42 use os_str_bytes::OsStringBytes;
43 let path = path.into().into_raw_vec();43 let path = path.into().into_raw_vec();
44 #[cfg(windows)]44 #[cfg(windows)]
45 let path = {45 let path = {
46 use bstr::ByteSlice;46 use git_object::bstr::ByteSlice;
47 path.replace(b"\\", b"/")47 path.replace(b"\\", b"/")
48 };48 };
49 path.into()49 path.into()
git-ref/src/store/file/overlay.rs+1−1
@@ -150,7 +150,7 @@ impl file::Store { · 149 unmodified lines
150mod error {150mod error {
151 use std::{io, path::PathBuf};151 use std::{io, path::PathBuf};
152 152
153 use bstr::BString;153 use git_object::bstr::BString;
154 use quick_error::quick_error;154 use quick_error::quick_error;
155 155
156 use crate::store::file;156 use crate::store::file;
git-ref/src/store/file/transaction/commit.rs+1−1
@@ -155,7 +155,7 @@ impl<'s> Transaction<'s> { · 154 unmodified lines
155 }155 }
156}156}
157mod error {157mod error {
158 use bstr::BString;158 use git_object::bstr::BString;
159 use quick_error::quick_error;159 use quick_error::quick_error;
160 160
161 use crate::store::{file, packed};161 use crate::store::{file, packed};
git-ref/src/store/file/transaction/mod.rs+1−1
@@ -1,5 +1,5 @@
1use bstr::BString;
2use git_hash::ObjectId;1use git_hash::ObjectId;
2use git_object::bstr::BString;
3 3
4use crate::{4use crate::{
5 store::{file, file::Transaction},5 store::{file, file::Transaction},
git-ref/src/store/file/transaction/prepare.rs+1−1
@@ -339,7 +339,7 @@ impl<'s> Transaction<'s> { · 338 unmodified lines
339}339}
340 340
341mod error {341mod error {
342 use bstr::BString;342 use git_object::bstr::BString;
343 use quick_error::quick_error;343 use quick_error::quick_error;
344 344
345 use crate::{345 use crate::{
git-ref/src/store/packed/decode.rs+1−1
@@ -1,6 +1,6 @@
1use std::convert::TryFrom;1use std::convert::TryFrom;
2 2
3use bstr::{BStr, ByteSlice};3use git_object::bstr::{BStr, ByteSlice};
4use nom::{4use nom::{
5 bytes::complete::{tag, take_while},5 bytes::complete::{tag, take_while},
6 combinator::{map, map_res, opt},6 combinator::{map, map_res, opt},
git-ref/src/store/packed/decode/tests.rs+1−1
@@ -46,7 +46,7 @@ mod reference { · 45 unmodified lines
46}46}
47 47
48mod header {48mod header {
49 use bstr::ByteSlice;49 use git_object::bstr::ByteSlice;
50 use git_testtools::to_bstr_err;50 use git_testtools::to_bstr_err;
51 51
52 use super::Result;52 use super::Result;
git-ref/src/store/packed/find.rs+1−1
@@ -1,6 +1,6 @@
1use std::{borrow::Cow, convert::TryInto};1use std::{borrow::Cow, convert::TryInto};
2 2
3use bstr::{BStr, BString, ByteSlice};3use git_object::bstr::{BStr, BString, ByteSlice};
4 4
5use crate::{store::packed, PartialNameRef};5use crate::{store::packed, PartialNameRef};
6 6
git-ref/src/store/packed/iter.rs+2−2
@@ -1,4 +1,4 @@
1use bstr::{BString, ByteSlice};1use git_object::bstr::{BString, ByteSlice};
2 2
3use crate::store::{packed, packed::decode};3use crate::store::{packed, packed::decode};
4 4
@@ -94,7 +94,7 @@ impl<'a> packed::Iter<'a> { · 89 unmodified lines
94}94}
95 95
96mod error {96mod error {
97 use bstr::BString;97 use git_object::bstr::BString;
98 use quick_error::quick_error;98 use quick_error::quick_error;
99 99
100 quick_error! {100 quick_error! {
git-ref/src/store/packed/mod.rs+1−1
@@ -1,8 +1,8 @@
1use std::path::PathBuf;1use std::path::PathBuf;
2 2
3use bstr::{BStr, BString};
4use filebuffer::FileBuffer;3use filebuffer::FileBuffer;
5use git_hash::ObjectId;4use git_hash::ObjectId;
5use git_object::bstr::{BStr, BString};
6 6
7use crate::{transaction::RefEdit, FullNameRef};7use crate::{transaction::RefEdit, FullNameRef};
8 8
git-ref/src/target.rs+1−1
@@ -1,7 +1,7 @@
1use std::fmt;1use std::fmt;
2 2
3use bstr::BStr;
4use git_hash::{oid, ObjectId};3use git_hash::{oid, ObjectId};
4use git_object::bstr::BStr;
5 5
6use crate::{FullName, Kind, Target, TargetRef};6use crate::{FullName, Kind, Target, TargetRef};
7use std::convert::TryFrom;7use std::convert::TryFrom;
git-ref/src/transaction/ext.rs+1−1
@@ -1,4 +1,4 @@
1use bstr::{BString, ByteVec};1use git_object::bstr::{BString, ByteVec};
2 2
3use crate::{3use crate::{
4 transaction::{Change, LogChange, PreviousValue, RefEdit, RefLog, Target},4 transaction::{Change, LogChange, PreviousValue, RefEdit, RefLog, Target},
git-ref/src/transaction/mod.rs+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
12//! - errors during preparations will cause a perfect rollback12//! - errors during preparations will cause a perfect rollback
13//! * prepared transactions are committed to finalize the change13//! * prepared transactions are committed to finalize the change
14//! - errors when committing while leave the ref store in an inconsistent, but operational state.14//! - errors when committing while leave the ref store in an inconsistent, but operational state.
15use bstr::BString;15use git_object::bstr::BString;
16 16
17use crate::{FullName, Target};17use crate::{FullName, Target};
18 18