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
1212 quick_error! {
1313 #[derive(Debug)]
1414 pub enum Error {
15− ParseIntegerError(msg: &'static str, kind: Vec<u8>, err: btoi::ParseIntegerError) {
16− display("{}: {:?}", msg, std::str::from_utf8(&kind))
15+ ParseIntegerError(msg: &'static str, kind: bstr::BString, err: btoi::ParseIntegerError) {
16+ display("{}: {:?}", msg, kind)
1717 cause(err)
1818 }
1919 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
3434 let hours = btoi::<i32>(&tzhour).map_err(|e| {
3535 nom::Err::Error(Error::ParseIntegerError(
3636 "invalid 'hours' string",
37− tzhour.to_owned(),
37+ tzhour.into(),
3838 e,
3939 ))
4040 })?;
4141 let minutes = btoi::<i32>(&tzminute).map_err(|e| {
4242 nom::Err::Error(Error::ParseIntegerError(
4343 "invalid 'minutes' string",
44− tzminute.to_owned(),
44+ tzminute.into(),
4545 e,
4646 ))
4747 })?;
@@ -56,7 +56,7 @@ pub(crate) fn parse_signature(i: &[u8]) -> IResult<&[u8], Signature, Error> { · 8 unmodified lines
5656 time: btoi::<u32>(time_in_seconds).map_err(|e| {
5757 nom::Err::Error(Error::ParseIntegerError(
5858 "Could parse to seconds",
59− time_in_seconds.to_owned(),
59+ time_in_seconds.into(),
6060 e,
6161 ))
6262 })?,
git-object/src/types.rs+2−2
@@ -37,7 +37,7 @@ pub enum Kind { · 36 unmodified lines
3737 quick_error! {
3838 #[derive(Debug)]
3939 pub enum Error {
40− InvalidObjectKind(kind: Vec<u8>) {
40+ InvalidObjectKind(kind: bstr::BString) {
4141 display("Unknown object kind: {:?}", std::str::from_utf8(&kind))
4242 }
4343 }
@@ -50,7 +50,7 @@ impl Kind { · 6 unmodified lines
5050 b"commit" => Kind::Commit,
5151 b"tree" => Kind::Tree,
5252 b"blob" => Kind::Blob,
53− _ => return Err(Error::InvalidObjectKind(s.to_owned())),
53+ _ => return Err(Error::InvalidObjectKind(s.into())),
5454 })
5555 }
5656 }
tasks.md+1−0
@@ -8,3 +8,4 @@ · 7 unmodified lines
88 * [x] parser tests handle binary strings nicely
99 * [x] switch parsing to nom (binary only)
1010 * [ ] 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