History

use bstr were possible

Sebastian Thiel committed 6 years ago

Commit 01dd4e21 parent e0125fd4 files · +8 −7Browse files

Unified · Split

4 files
  1. git-object/src/borrowed/mod.rs +2 −2
  2. git-object/src/borrowed/util.rs +3 −3
  3. git-object/src/types.rs +2 −2
  4. tasks.md +1 −0
git-object/src/borrowed/mod.rs+2−2
@@ -12,8 +12,8 @@ pub use tag::Tag; · 11 unmodified lines
12quick_error! {12quick_error! {
13 #[derive(Debug)]13 #[derive(Debug)]
14 pub enum Error {14 pub enum Error {
15 ParseIntegerError(msg: &'static str, kind: Vec<u8>, err: btoi::ParseIntegerError) {15 ParseIntegerError(msg: &'static str, kind: bstr::BString, err: btoi::ParseIntegerError) {
16 display("{}: {:?}", msg, std::str::from_utf8(&kind))16 display("{}: {:?}", msg, kind)
17 cause(err)17 cause(err)
18 }18 }
19 Nom(err_msg: String) {19 Nom(err_msg: String) {
git-object/src/borrowed/util.rs+3−3
@@ -34,14 +34,14 @@ pub(crate) fn parse_signature(i: &[u8]) -> IResult<&[u8], Signature, Error> { · 33 unmodified lines
34 let hours = btoi::<i32>(&tzhour).map_err(|e| {34 let hours = btoi::<i32>(&tzhour).map_err(|e| {
35 nom::Err::Error(Error::ParseIntegerError(35 nom::Err::Error(Error::ParseIntegerError(
36 "invalid 'hours' string",36 "invalid 'hours' string",
37 tzhour.to_owned(),37 tzhour.into(),
38 e,38 e,
39 ))39 ))
40 })?;40 })?;
41 let minutes = btoi::<i32>(&tzminute).map_err(|e| {41 let minutes = btoi::<i32>(&tzminute).map_err(|e| {
42 nom::Err::Error(Error::ParseIntegerError(42 nom::Err::Error(Error::ParseIntegerError(
43 "invalid 'minutes' string",43 "invalid 'minutes' string",
44 tzminute.to_owned(),44 tzminute.into(),
45 e,45 e,
46 ))46 ))
47 })?;47 })?;
@@ -56,7 +56,7 @@ pub(crate) fn parse_signature(i: &[u8]) -> IResult<&[u8], Signature, Error> { · 8 unmodified lines
56 time: btoi::<u32>(time_in_seconds).map_err(|e| {56 time: btoi::<u32>(time_in_seconds).map_err(|e| {
57 nom::Err::Error(Error::ParseIntegerError(57 nom::Err::Error(Error::ParseIntegerError(
58 "Could parse to seconds",58 "Could parse to seconds",
59 time_in_seconds.to_owned(),59 time_in_seconds.into(),
60 e,60 e,
61 ))61 ))
62 })?,62 })?,
git-object/src/types.rs+2−2
@@ -37,7 +37,7 @@ pub enum Kind { · 36 unmodified lines
37quick_error! {37quick_error! {
38 #[derive(Debug)]38 #[derive(Debug)]
39 pub enum Error {39 pub enum Error {
40 InvalidObjectKind(kind: Vec<u8>) {40 InvalidObjectKind(kind: bstr::BString) {
41 display("Unknown object kind: {:?}", std::str::from_utf8(&kind))41 display("Unknown object kind: {:?}", std::str::from_utf8(&kind))
42 }42 }
43 }43 }
@@ -50,7 +50,7 @@ impl Kind { · 6 unmodified lines
50 b"commit" => Kind::Commit,50 b"commit" => Kind::Commit,
51 b"tree" => Kind::Tree,51 b"tree" => Kind::Tree,
52 b"blob" => Kind::Blob,52 b"blob" => Kind::Blob,
53 _ => return Err(Error::InvalidObjectKind(s.to_owned())),53 _ => return Err(Error::InvalidObjectKind(s.into())),
54 })54 })
55 }55 }
56}56}
tasks.md+1−0
@@ -8,3 +8,4 @@ · 7 unmodified lines
8* [x] parser tests handle binary strings nicely8* [x] parser tests handle binary strings nicely
9* [x] switch parsing to nom (binary only)9* [x] switch parsing to nom (binary only)
10* [ ] test tags without signature10* [ ] test tags without signature
11* [ ] Review loose object parsing, but don't use Nom for that

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t