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

Unified · Split

44 files
  1. Cargo.lock +0 −2
  2. git-ref/Cargo.toml +1 −2
  3. git-ref/src/fullname.rs +1 −1
  4. git-ref/src/lib.rs +3 −2
  5. git-ref/src/name.rs +1 −1
  6. git-ref/src/namespace.rs +1 −1
  7. git-ref/src/parse.rs +1 −1
  8. git-ref/src/peel.rs +1 −1
  9. git-ref/src/raw.rs +1 −1
  10. git-ref/src/store/file/find.rs +1 −1
  11. git-ref/src/store/file/log/iter.rs +2 −2
  12. git-ref/src/store/file/log/line.rs +4 −4
  13. git-ref/src/store/file/log/mod.rs +1 −1
  14. git-ref/src/store/file/loose/iter.rs +1 −1
  15. git-ref/src/store/file/loose/reference/decode.rs +1 −1
  16. git-ref/src/store/file/loose/reflog.rs +1 −1
  17. git-ref/src/store/file/loose/reflog/create_or_update/tests.rs +1 −1
  18. git-ref/src/store/file/mod.rs +2 −2
  19. git-ref/src/store/file/overlay.rs +1 −1
  20. git-ref/src/store/file/transaction/commit.rs +1 −1
  21. git-ref/src/store/file/transaction/mod.rs +1 −1
  22. git-ref/src/store/file/transaction/prepare.rs +1 −1
  23. git-ref/src/store/packed/decode.rs +1 −1
  24. git-ref/src/store/packed/decode/tests.rs +1 −1
  25. git-ref/src/store/packed/find.rs +1 −1
  26. git-ref/src/store/packed/iter.rs +2 −2
  27. git-ref/src/store/packed/mod.rs +1 −1
  28. git-ref/src/target.rs +1 −1
  29. git-ref/src/transaction/ext.rs +1 −1
  30. git-ref/src/transaction/mod.rs +1 −1
  31. git-ref/tests/file/log.rs +2 −2
  32. git-ref/tests/file/reference.rs +1 −1
  33. git-ref/tests/file/store/iter.rs +2 −2
  34. git-ref/tests/file/transaction/mod.rs +1 −1
  35. git-ref/tests/file/transaction/prepare_and_commit/create_or_update.rs +1 −1
  36. git-ref/tests/packed/iter.rs +1 −1
  37. git-ref/tests/transaction/mod.rs +1 −1
  38. git-repository/Cargo.toml +0 −1
  39. git-repository/src/commit.rs +1 −1
  40. git-repository/src/easy/ext/object.rs +1 −1
  41. git-repository/src/easy/ext/reference.rs +1 −1
  42. git-repository/src/lib.rs +1 −0
  43. git-repository/src/reference.rs +1 −1
  44. git-repository/src/repository.rs +1 −1
Cargo.lock+0−2
@@ -1165,7 +1165,6 @@ dependencies = [ · 1164 unmodified lines
11651165 name = "git-ref"
11661166 version = "0.7.0"
11671167 dependencies = [
1168− "bstr",
11691168 "filebuffer",
11701169 "git-actor",
11711170 "git-features",
@@ -1188,7 +1187,6 @@ name = "git-repository" · 16 unmodified lines
11881187 version = "0.8.1"
11891188 dependencies = [
11901189 "anyhow",
1191− "bstr",
11921190 "git-actor",
11931191 "git-config",
11941192 "git-diff",
git-ref/Cargo.toml+1−2
@@ -13,7 +13,7 @@ doctest = false · 12 unmodified lines
1313 test = true
1414
1515 [features]
16−serde1 = ["serde", "bstr/serde1", "git-hash/serde1", "git-actor/serde1"]
16+serde1 = ["serde", "git-hash/serde1", "git-actor/serde1", "git-object/serde1"]
1717 internal-testing-git-features-parallel = ["git-features/parallel"] # test sorted parallel loose file traversal
1818
1919 [[test]]
@@ -33,7 +33,6 @@ git-lock = { version ="^1.0.0", path = "../git-lock" } · 13 unmodified lines
3333 git-tempfile = { version ="^1.0.0", path = "../git-tempfile" }
3434
3535 quick-error = "2.0.0"
36−bstr = { version = "0.2.13", default-features = false, features = ["std"] }
3736 nom = { version = "7", default-features = false, features = ["std"]}
3837 serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]}
3938 os_str_bytes = "3.1.0"
git-ref/src/fullname.rs+1−1
@@ -1,6 +1,6 @@
11 use std::{borrow::Cow, convert::TryFrom, path::Path};
22
3−use bstr::{BStr, BString, ByteSlice};
3+use git_object::bstr::{BStr, BString, ByteSlice};
44
55 use crate::{FullName, FullNameRef};
66
git-ref/src/lib.rs+3−2
@@ -18,8 +18,9 @@ · 17 unmodified lines
1818 //! * supersedes all of the above to allow handling hundreds of thousands of references.
1919 #![forbid(unsafe_code)]
2020 #![deny(missing_docs, rust_2018_idioms)]
21−use bstr::{BStr, BString};
2221 use git_hash::{oid, ObjectId};
22+pub use git_object::bstr;
23+use git_object::bstr::{BStr, BString};
2324
2425 mod store;
2526 pub use store::{file, packed};
@@ -41,8 +42,8 @@ mod target; · 15 unmodified lines
4142
4243 ///
4344 pub mod log {
44− use bstr::BString;
4545 use git_hash::ObjectId;
46+ use git_object::bstr::BString;
4647
4748 /// A parsed ref log line that can be changed
4849 #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
git-ref/src/name.rs+1−1
@@ -4,7 +4,7 @@ use std::{ · 3 unmodified lines
44 path::Path,
55 };
66
7−use bstr::{BStr, ByteSlice};
7+use git_object::bstr::{BStr, ByteSlice};
88
99 use crate::{FullNameRef, PartialNameRef};
1010
git-ref/src/namespace.rs+1−1
@@ -1,6 +1,6 @@
11 use std::{borrow::Cow, convert::TryInto, path::Path};
22
3−use bstr::{BStr, BString, ByteSlice, ByteVec};
3+use git_object::bstr::{BStr, BString, ByteSlice, ByteVec};
44
55 use crate::{Namespace, PartialNameRef};
66
git-ref/src/parse.rs+1−1
@@ -1,4 +1,4 @@
1−use bstr::{BStr, ByteSlice};
1+use git_object::bstr::{BStr, ByteSlice};
22 use nom::{
33 branch::alt,
44 bytes::complete::{tag, take_while_m_n},
git-ref/src/peel.rs+1−1
@@ -10,7 +10,7 @@ pub fn none( · 9 unmodified lines
1010 pub mod to_id {
1111 use std::path::PathBuf;
1212
13− use bstr::BString;
13+ use git_object::bstr::BString;
1414 use quick_error::quick_error;
1515
1616 use crate::file;
git-ref/src/raw.rs+1−1
@@ -55,7 +55,7 @@ mod convert { · 54 unmodified lines
5555 }
5656
5757 mod access {
58− use bstr::ByteSlice;
58+ use git_object::bstr::ByteSlice;
5959
6060 use crate::{raw::Reference, FullNameRef, Namespace};
6161
git-ref/src/store/file/find.rs+1−1
@@ -4,8 +4,8 @@ use std::{ · 3 unmodified lines
44 path::{Path, PathBuf},
55 };
66
7−use bstr::ByteSlice;
87 pub use error::Error;
8+use git_object::bstr::ByteSlice;
99
1010 use crate::{
1111 file,
git-ref/src/store/file/log/iter.rs+2−2
@@ -1,4 +1,4 @@
1−use bstr::ByteSlice;
1+use git_object::bstr::ByteSlice;
22
33 use crate::store::file::{log, log::iter::decode::LineNumber};
44
@@ -59,7 +59,7 @@ pub fn forward(lines: &[u8]) -> Forward<'_> { · 54 unmodified lines
5959
6060 /// An iterator yielding parsed lines in a file from start to end, oldest to newest.
6161 pub struct Forward<'a> {
62− inner: std::iter::Enumerate<bstr::Lines<'a>>,
62+ inner: std::iter::Enumerate<git_object::bstr::Lines<'a>>,
6363 }
6464
6565 impl<'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
1212 mod write {
1313 use std::io;
1414
15− use bstr::{BStr, ByteSlice};
15+ use git_object::bstr::{BStr, ByteSlice};
1616 use quick_error::quick_error;
1717
1818 use crate::log::Line;
@@ -77,7 +77,7 @@ impl<'a> From<LineRef<'a>> for Line { · 58 unmodified lines
7777
7878 ///
7979 pub mod decode {
80− use bstr::{BStr, ByteSlice};
80+ use git_object::bstr::{BStr, ByteSlice};
8181 use nom::{
8282 bytes::complete::{tag, take_while},
8383 combinator::opt,
@@ -90,7 +90,7 @@ pub mod decode { · 6 unmodified lines
9090
9191 ///
9292 mod error {
93− use bstr::{BString, ByteSlice};
93+ use git_object::bstr::{BString, ByteSlice};
9494
9595 /// The error returned by [from_bytes(…)][super::Line::from_bytes()]
9696 #[derive(Debug)]
@@ -172,9 +172,9 @@ pub mod decode { · 75 unmodified lines
172172
173173 #[cfg(test)]
174174 mod test {
175− use bstr::ByteSlice;
176175 use git_actor::{Sign, Time};
177176 use git_hash::ObjectId;
177+ use git_object::bstr::ByteSlice;
178178
179179 use super::*;
180180
git-ref/src/store/file/log/mod.rs+1−1
@@ -1,4 +1,4 @@
1−use bstr::BStr;
1+use git_object::bstr::BStr;
22
33 pub use super::loose::reflog::{create_or_update, Error};
44
git-ref/src/store/file/loose/iter.rs+1−1
@@ -3,8 +3,8 @@ use std::{ · 2 unmodified lines
33 path::{Path, PathBuf},
44 };
55
6−use bstr::ByteSlice;
76 use git_features::fs::walkdir::DirEntryIter;
7+use git_object::bstr::ByteSlice;
88 use os_str_bytes::OsStrBytes;
99
1010 use crate::{
git-ref/src/store/file/loose/reference/decode.rs+1−1
@@ -1,7 +1,7 @@
11 use std::convert::{TryFrom, TryInto};
22
3−use bstr::BString;
43 use git_hash::ObjectId;
4+use git_object::bstr::BString;
55 use nom::{
66 bytes::complete::{tag, take_while},
77 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
8989 path::{Path, PathBuf},
9090 };
9191
92− use bstr::BStr;
9392 use git_hash::{oid, ObjectId};
93+ use git_object::bstr::BStr;
9494
9595 use crate::store::{file, file::WriteReflog};
9696
git-ref/src/store/file/loose/reflog/create_or_update/tests.rs+1−1
@@ -1,8 +1,8 @@
11 use super::*;
22 use crate::{file::WriteReflog, FullNameRef};
3−use bstr::ByteSlice;
43 use git_actor::{Sign, Signature, Time};
54 use git_lock::acquire::Fail;
5+use git_object::bstr::ByteSlice;
66 use git_testtools::hex_to_id;
77 use std::{convert::TryInto, path::Path};
88 use tempfile::TempDir;
git-ref/src/store/file/mod.rs+2−2
@@ -38,12 +38,12 @@ pub struct Transaction<'s> { · 37 unmodified lines
3838 namespace: Option<crate::Namespace>,
3939 }
4040
41−pub(in crate::store::file) fn path_to_name(path: impl Into<PathBuf>) -> bstr::BString {
41+pub(in crate::store::file) fn path_to_name(path: impl Into<PathBuf>) -> git_object::bstr::BString {
4242 use os_str_bytes::OsStringBytes;
4343 let path = path.into().into_raw_vec();
4444 #[cfg(windows)]
4545 let path = {
46− use bstr::ByteSlice;
46+ use git_object::bstr::ByteSlice;
4747 path.replace(b"\\", b"/")
4848 };
4949 path.into()
git-ref/src/store/file/overlay.rs+1−1
@@ -150,7 +150,7 @@ impl file::Store { · 149 unmodified lines
150150 mod error {
151151 use std::{io, path::PathBuf};
152152
153− use bstr::BString;
153+ use git_object::bstr::BString;
154154 use quick_error::quick_error;
155155
156156 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
155155 }
156156 }
157157 mod error {
158− use bstr::BString;
158+ use git_object::bstr::BString;
159159 use quick_error::quick_error;
160160
161161 use crate::store::{file, packed};
git-ref/src/store/file/transaction/mod.rs+1−1
@@ -1,5 +1,5 @@
1−use bstr::BString;
21 use git_hash::ObjectId;
2+use git_object::bstr::BString;
33
44 use crate::{
55 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
339339 }
340340
341341 mod error {
342− use bstr::BString;
342+ use git_object::bstr::BString;
343343 use quick_error::quick_error;
344344
345345 use crate::{
git-ref/src/store/packed/decode.rs+1−1
@@ -1,6 +1,6 @@
11 use std::convert::TryFrom;
22
3−use bstr::{BStr, ByteSlice};
3+use git_object::bstr::{BStr, ByteSlice};
44 use nom::{
55 bytes::complete::{tag, take_while},
66 combinator::{map, map_res, opt},
git-ref/src/store/packed/decode/tests.rs+1−1
@@ -46,7 +46,7 @@ mod reference { · 45 unmodified lines
4646 }
4747
4848 mod header {
49− use bstr::ByteSlice;
49+ use git_object::bstr::ByteSlice;
5050 use git_testtools::to_bstr_err;
5151
5252 use super::Result;
git-ref/src/store/packed/find.rs+1−1
@@ -1,6 +1,6 @@
11 use std::{borrow::Cow, convert::TryInto};
22
3−use bstr::{BStr, BString, ByteSlice};
3+use git_object::bstr::{BStr, BString, ByteSlice};
44
55 use crate::{store::packed, PartialNameRef};
66
git-ref/src/store/packed/iter.rs+2−2
@@ -1,4 +1,4 @@
1−use bstr::{BString, ByteSlice};
1+use git_object::bstr::{BString, ByteSlice};
22
33 use crate::store::{packed, packed::decode};
44
@@ -94,7 +94,7 @@ impl<'a> packed::Iter<'a> { · 89 unmodified lines
9494 }
9595
9696 mod error {
97− use bstr::BString;
97+ use git_object::bstr::BString;
9898 use quick_error::quick_error;
9999
100100 quick_error! {
git-ref/src/store/packed/mod.rs+1−1
@@ -1,8 +1,8 @@
11 use std::path::PathBuf;
22
3−use bstr::{BStr, BString};
43 use filebuffer::FileBuffer;
54 use git_hash::ObjectId;
5+use git_object::bstr::{BStr, BString};
66
77 use crate::{transaction::RefEdit, FullNameRef};
88
git-ref/src/target.rs+1−1
@@ -1,7 +1,7 @@
11 use std::fmt;
22
3−use bstr::BStr;
43 use git_hash::{oid, ObjectId};
4+use git_object::bstr::BStr;
55
66 use crate::{FullName, Kind, Target, TargetRef};
77 use std::convert::TryFrom;
git-ref/src/transaction/ext.rs+1−1
@@ -1,4 +1,4 @@
1−use bstr::{BString, ByteVec};
1+use git_object::bstr::{BString, ByteVec};
22
33 use crate::{
44 transaction::{Change, LogChange, PreviousValue, RefEdit, RefLog, Target},
git-ref/src/transaction/mod.rs+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212 //! - errors during preparations will cause a perfect rollback
1313 //! * prepared transactions are committed to finalize the change
1414 //! - errors when committing while leave the ref store in an inconsistent, but operational state.
15−use bstr::BString;
15+use git_object::bstr::BString;
1616
1717 use crate::{FullName, Target};
1818
git-ref/tests/file/log.rs+2−2
@@ -1,6 +1,6 @@
11 mod line {
22 mod write_to {
3− use bstr::ByteVec;
3+ use git_object::bstr::ByteVec;
44 use git_ref::file::log;
55
66 #[test]
@@ -159,8 +159,8 @@ mod iter { · 152 unmodified lines
159159 }
160160 }
161161 mod forward {
162− use bstr::B;
163162 use git_hash::ObjectId;
163+ use git_object::bstr::B;
164164
165165 use crate::file::log::iter::reflog;
166166
git-ref/tests/file/reference.rs+1−1
@@ -191,7 +191,7 @@ mod parse { · 190 unmodified lines
191191 mktest!(ref_tag, b"reff: hello", "\"reff: hello\" could not be parsed");
192192 }
193193 mod valid {
194− use bstr::ByteSlice;
194+ use git_object::bstr::ByteSlice;
195195 use git_ref::file::loose::Reference;
196196 use git_testtools::hex_to_id;
197197
git-ref/tests/file/store/iter.rs+2−2
@@ -1,12 +1,12 @@
11 use std::convert::TryInto;
22
3−use bstr::ByteSlice;
3+use git_object::bstr::ByteSlice;
44 use git_testtools::hex_to_id;
55
66 use crate::file::{store, store_at, store_with_packed_refs};
77
88 mod with_namespace {
9− use bstr::BString;
9+ use git_object::bstr::BString;
1010 use git_object::bstr::ByteSlice;
1111
1212 use crate::file::store_at;
git-ref/tests/file/transaction/mod.rs+1−1
@@ -1,7 +1,7 @@
11 mod prepare_and_commit {
2− use bstr::BString;
32 use git_actor::{Sign, Time};
43 use git_hash::ObjectId;
4+ use git_object::bstr::BString;
55 use git_ref::file;
66
77 fn reflog_lines(store: &file::Store, name: &str) -> crate::Result<Vec<git_ref::log::Line>> {
git-ref/tests/file/transaction/prepare_and_commit/create_or_update.rs+1−1
@@ -2,10 +2,10 @@ use crate::file::{ · 1 unmodified line
22 store_with_packed_refs, store_writable,
33 transaction::prepare_and_commit::{committer, empty_store, log_line, reflog_lines},
44 };
5−use bstr::ByteSlice;
65 use git_hash::ObjectId;
76 use git_lock::acquire::Fail;
87 use git_object::bstr::BString;
8+use git_object::bstr::ByteSlice;
99 use git_ref::file::ReferenceExt;
1010 use git_ref::transaction::PreviousValue;
1111 use git_ref::{
git-ref/tests/packed/iter.rs+1−1
@@ -1,6 +1,6 @@
11 use std::convert::TryInto;
22
3−use bstr::ByteSlice;
3+use git_object::bstr::ByteSlice;
44 use git_ref::packed;
55
66 use crate::file::{store_at, store_with_packed_refs};
git-ref/tests/transaction/mod.rs+1−1
@@ -1,7 +1,7 @@
11 mod refedit_ext {
22 use std::{cell::RefCell, collections::BTreeMap, convert::TryInto};
33
4− use bstr::{BString, ByteSlice};
4+ use git_object::bstr::{BString, ByteSlice};
55 use git_ref::{
66 transaction::{Change, PreviousValue, RefEdit, RefEditsExt, RefLog},
77 PartialNameRef, Target,
git-repository/Cargo.toml+0−1
@@ -54,7 +54,6 @@ git-protocol = { version ="^0.10.0", path = "../git-protocol", optional = true } · 53 unmodified lines
5454 git-diff = { version ="^0.9.0", path = "../git-diff", optional = true }
5555 git-features = { version = "^0.16.0", path = "../git-features", features = ["progress"] }
5656
57−bstr = "0.2.15"
5857 signal-hook = { version = "0.3.9", default-features = false }
5958 thiserror = "1.0.26"
6059 parking_lot = { version = "0.11.2", features = ["arc_lock"] }
git-repository/src/commit.rs+1−1
@@ -1,6 +1,6 @@
11 use std::borrow::Cow;
22
3−use bstr::{BStr, BString, ByteSlice, ByteVec};
3+use git_object::bstr::{BStr, BString, ByteSlice, ByteVec};
44
55 /// An empty array of a type usable with the `git::easy` API to help declaring no parents should be used
66 pub const NO_PARENT_IDS: [git_hash::ObjectId; 0] = [];
git-repository/src/easy/ext/object.rs+1−1
@@ -1,7 +1,7 @@
11 use std::{convert::TryInto, ops::DerefMut};
22
3−use bstr::BString;
43 use git_hash::ObjectId;
4+use git_object::bstr::BString;
55 use git_odb::{Find, FindExt};
66 use git_ref::{
77 transaction::{LogChange, PreviousValue, RefLog},
git-repository/src/easy/ext/reference.rs+1−1
@@ -1,9 +1,9 @@
11 use std::convert::TryInto;
22
3−use bstr::BString;
43 use git_actor as actor;
54 use git_hash::ObjectId;
65 use git_lock as lock;
6+use git_object::bstr::BString;
77 use git_ref::{
88 transaction::{Change, LogChange, PreviousValue, RefEdit, RefLog},
99 FullName, PartialNameRef, Target,
git-repository/src/lib.rs+1−0
@@ -69,6 +69,7 @@ · 68 unmodified lines
6969 //! * [`odb`]
7070 //! * [`pack`][odb::pack]
7171 //! * [`refs`]
72+//! * [`bstr`][refs::bstr]
7273 //! * [`interrupt`]
7374 //! * [`tempfile`]
7475 //! * [`lock`]
git-repository/src/reference.rs+1−1
@@ -1,6 +1,6 @@
11 ///
22 pub mod log {
3− use bstr::{BString, ByteSlice, ByteVec};
3+ use git_object::bstr::{BString, ByteSlice, ByteVec};
44 use git_object::Commit;
55
66 use crate::commit;
git-repository/src/repository.rs+1−1
@@ -50,7 +50,7 @@ pub mod open { · 49 unmodified lines
5050 #[error(transparent)]
5151 ObjectStoreInitialization(#[from] git_odb::linked::init::Error),
5252 #[error("Cannot handle objects formatted as {:?}", .name)]
53− UnsupportedObjectFormat { name: bstr::BString },
53+ UnsupportedObjectFormat { name: git_object::bstr::BString },
5454 }
5555
5656 impl Repository {