This is when I learned that there is also a long-running processes format that uses packet-line to communicate. Thus it doesn't belong in transport anymore, which was the previous 'best fit'. Since it's a serialization format, setting up its own crate makes quite some sense.
Unified · Split
| @@ -649,13 +649,25 @@ dependencies = [ · 648 unmodified lines | |||
| 649 | "walkdir", | 649 | "walkdir", |
| 650 | ] | 650 | ] |
| 651 | 651 | ||
| 652 | [[package]] | ||
| 653 | name = "git-packetline" | ||
| 654 | version = "0.1.0" | ||
| 655 | dependencies = [ | ||
| 656 | "bstr", | ||
| 657 | "git-features", | ||
| 658 | "git-odb", | ||
| 659 | "hex", | ||
| 660 | "quick-error 2.0.0", | ||
| 661 | "serde", | ||
| 662 | ] | ||
| 663 | |||
| 652 | [[package]] | 664 | [[package]] |
| 653 | name = "git-protocol" | 665 | name = "git-protocol" |
| 654 | version = "0.1.0" | 666 | version = "0.1.0" |
| 655 | dependencies = [ | 667 | dependencies = [ |
| 656 | "bstr", | 668 | "bstr", |
| 657 | "btoi", | 669 | "btoi", |
| 658 | "git-transport", | 670 | "git-packetline", |
| 659 | "nom", | 671 | "nom", |
| 660 | "quick-error 2.0.0", | 672 | "quick-error 2.0.0", |
| 661 | "serde", | 673 | "serde", |
| @@ -683,9 +695,7 @@ dependencies = [ · 21 unmodified lines | |||
| 683 | "bstr", | 695 | "bstr", |
| 684 | "curl", | 696 | "curl", |
| 685 | "git-features", | 697 | "git-features", |
| 686 | "git-odb", | ||
| 687 | "git-url", | 698 | "git-url", |
| 688 | "hex", | ||
| 689 | "quick-error 2.0.0", | 699 | "quick-error 2.0.0", |
| 690 | "serde", | 700 | "serde", |
| 691 | ] | 701 | ] |
| @@ -91,5 +91,6 @@ members = [ · 90 unmodified lines | |||
| 91 | "git-protocol", | 91 | "git-protocol", |
| 92 | "git-url", | 92 | "git-url", |
| 93 | "git-transport", | 93 | "git-transport", |
| 94 | "git-packetline", | ||
| 94 | "git-tui", | 95 | "git-tui", |
| 95 | ] | 96 | ] |
| @@ -83,6 +83,8 @@ check: ## Build all code in suitable configurations · 82 unmodified lines | |||
| 83 | cd git-object && cargo check --all-features | 83 | cd git-object && cargo check --all-features |
| 84 | cd git-odb && cargo check --all-features \ | 84 | cd git-odb && cargo check --all-features \ |
| 85 | && cargo check | 85 | && cargo check |
| 86 | cd git-packetline && cargo check --all-features \ | ||
| 87 | && cargo check | ||
| 86 | cd git-protocol && cargo check --all-features \ | 88 | cd git-protocol && cargo check --all-features \ |
| 87 | && cargo check | 89 | && cargo check |
| 88 | cd git-url && cargo check --all-features \ | 90 | cd git-url && cargo check --all-features \ |
| @@ -142,6 +142,9 @@ Please see _'Development Status'_ for a listing of all crates and their capabili · 141 unmodified lines | |||
| 142 | * [x] initialize | 142 | * [x] initialize |
| 143 | * [ ] Proper configuration depending on platform (e.g. ignorecase, filemode, …) | 143 | * [ ] Proper configuration depending on platform (e.g. ignorecase, filemode, …) |
| 144 | * [ ] [Signed commits and tags](https://github.com/Byron/gitoxide/issues/12) | 144 | * [ ] [Signed commits and tags](https://github.com/Byron/gitoxide/issues/12) |
| 145 | * [ ] sparse checkout support | ||
| 146 | * [ ] .gitignore handling | ||
| 147 | * [ ] checkout/stage conversions clean + smudge as in .gitattributes | ||
| 145 | * [ ] read and write all data types | 148 | * [ ] read and write all data types |
| 146 | * [ ] rev-parsing and ref history | 149 | * [ ] rev-parsing and ref history |
| 147 | * [ ] remotes with push and pull | 150 | * [ ] remotes with push and pull |
| @@ -22,6 +22,7 @@ indent cargo diet -n --package-size-limit 25KB · 21 unmodified lines | |||
| 22 | (enter git-object && indent cargo diet -n --package-size-limit 15KB) | 22 | (enter git-object && indent cargo diet -n --package-size-limit 15KB) |
| 23 | (enter git-odb && indent cargo diet -n --package-size-limit 50KB) | 23 | (enter git-odb && indent cargo diet -n --package-size-limit 50KB) |
| 24 | (enter git-protocol && indent cargo diet -n --package-size-limit 5KB) | 24 | (enter git-protocol && indent cargo diet -n --package-size-limit 5KB) |
| 25 | (enter git-packetline && indent cargo diet -n --package-size-limit 7KB) | ||
| 25 | (enter git-repository && indent cargo diet -n --package-size-limit 10KB) | 26 | (enter git-repository && indent cargo diet -n --package-size-limit 10KB) |
| 26 | (enter git-transport && indent cargo diet -n --package-size-limit 10KB) | 27 | (enter git-transport && indent cargo diet -n --package-size-limit 5KB) |
| 27 | (enter gitoxide-core && indent cargo diet -n --package-size-limit 10KB) | 28 | (enter gitoxide-core && indent cargo diet -n --package-size-limit 10KB) |
| @@ -4,6 +4,6 @@ set -eu -o pipefail · 3 unmodified lines | |||
| 4 | 4 | ||
| 5 | ./etc/check-package-size.sh | 5 | ./etc/check-package-size.sh |
| 6 | 6 | ||
| 7 | for crate in git-features git-ref git-object git-odb git-repository gitoxide-core .; do | 7 | for crate in git-features git-ref git-object git-odb git-packetline git-transport git-protocol git-repository gitoxide-core .; do |
| 8 | (cd $crate && cargo release "$@") | 8 | (cd $crate && cargo release "$@") |
| 9 | done | 9 | done |
| @@ -0,0 +1,27 @@ | |||
| 1 | [package] | ||
| 2 | name = "git-packetline" | ||
| 3 | version = "0.1.0" | ||
| 4 | repository = "https://github.com/Byron/git-oxide" | ||
| 5 | license = "MIT/Apache-2.0" | ||
| 6 | description = "A WIP crate of the gitoxide project implementing the pkt-line serialization format" | ||
| 7 | authors = ["Sebastian Thiel <sebastian.thiel@icloud.com>"] | ||
| 8 | edition = "2018" | ||
| 9 | include = ["src/**/*"] | ||
| 10 | |||
| 11 | [lib] | ||
| 12 | doctest = false | ||
| 13 | |||
| 14 | [features] | ||
| 15 | serde1 = ["serde", "bstr/serde1"] | ||
| 16 | |||
| 17 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
| 18 | |||
| 19 | [dependencies] | ||
| 20 | git-features = { version = "^0.3.0", path = "../git-features" } | ||
| 21 | serde = { version = "1.0.114", optional = true, default-features = false, features = ["std", "derive"]} | ||
| 22 | quick-error = "2.0.0" | ||
| 23 | hex = "0.4.2" | ||
| 24 | bstr = { version = "0.2.13", default-features = false, features = ["std"] } | ||
| 25 | |||
| 26 | [dev-dependencies] | ||
| 27 | git-odb = { version = "0.3.0", path = "../git-odb" } | ||
| @@ -1,4 +1,4 @@ | |||
| 1 | use crate::packet_line::{encode, Channel}; | 1 | use crate::{encode, Channel}; |
| 2 | use bstr::BStr; | 2 | use bstr::BStr; |
| 3 | use std::io; | 3 | use std::io; |
| 4 | 4 | ||
| @@ -1,8 +1,5 @@ | |||
| 1 | use crate::{ | 1 | use crate::{ |
| 2 | packet_line::{ | 2 | PacketLine, {DELIMITER_LINE, ERR_PREFIX, FLUSH_LINE, MAX_DATA_LEN, MAX_LINE_LEN, RESPONSE_END_LINE, U16_HEX_BYTES}, |
| 3 | DELIMITER_LINE, ERR_PREFIX, FLUSH_LINE, MAX_DATA_LEN, MAX_LINE_LEN, RESPONSE_END_LINE, U16_HEX_BYTES, | ||
| 4 | }, | ||
| 5 | PacketLine, | ||
| 6 | }; | 3 | }; |
| 7 | use bstr::BString; | 4 | use bstr::BString; |
| 8 | use quick_error::quick_error; | 5 | use quick_error::quick_error; |
| @@ -1,4 +1,4 @@ | |||
| 1 | use crate::packet_line::{Channel, DELIMITER_LINE, ERR_PREFIX, FLUSH_LINE, MAX_DATA_LEN, RESPONSE_END_LINE}; | 1 | use crate::{Channel, DELIMITER_LINE, ERR_PREFIX, FLUSH_LINE, MAX_DATA_LEN, RESPONSE_END_LINE}; |
| 2 | use quick_error::quick_error; | 2 | use quick_error::quick_error; |
| 3 | use std::io; | 3 | use std::io; |
| 4 | 4 | ||
| @@ -1,3 +1,4 @@ | |||
| 1 | #![forbid(unsafe_code)] | ||
| 1 | pub(crate) const U16_HEX_BYTES: usize = 4; | 2 | pub(crate) const U16_HEX_BYTES: usize = 4; |
| 2 | pub(crate) const MAX_DATA_LEN: usize = 65516; | 3 | pub(crate) const MAX_DATA_LEN: usize = 65516; |
| 3 | pub(crate) const MAX_LINE_LEN: usize = MAX_DATA_LEN + U16_HEX_BYTES; | 4 | pub(crate) const MAX_LINE_LEN: usize = MAX_DATA_LEN + U16_HEX_BYTES; |
| @@ -14,8 +15,18 @@ pub enum Channel { · 10 unmodified lines | |||
| 14 | Error = 3, | 15 | Error = 3, |
| 15 | } | 16 | } |
| 16 | 17 | ||
| 18 | #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)] | ||
| 19 | #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] | ||
| 20 | pub struct RemoteProgress<'a> { | ||
| 21 | #[cfg_attr(feature = "serde1", serde(borrow))] | ||
| 22 | pub action: &'a bstr::BStr, | ||
| 23 | pub percent: Option<u32>, | ||
| 24 | pub step: Option<usize>, | ||
| 25 | pub max: Option<usize>, | ||
| 26 | } | ||
| 27 | |||
| 17 | pub mod borrowed; | 28 | pub mod borrowed; |
| 18 | pub use borrowed::Borrowed; | 29 | pub use borrowed::Borrowed as PacketLine; |
| 19 | 30 | ||
| 20 | pub mod read; | 31 | pub mod read; |
| 21 | #[doc(inline)] | 32 | #[doc(inline)] |
| @@ -1,4 +1,4 @@ | |||
| 1 | use crate::packet_line::{ | 1 | use crate::{ |
| 2 | borrowed::{Band, Text}, | 2 | borrowed::{Band, Text}, |
| 3 | decode, MAX_DATA_LEN, MAX_LINE_LEN, | 3 | decode, MAX_DATA_LEN, MAX_LINE_LEN, |
| 4 | }; | 4 | }; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
| @@ -1,10 +1,9 @@ | |||
| 1 | mod streaming { | 1 | mod streaming { |
| 2 | use crate::packet_line::assert_err_display; | 2 | use crate::packet_line::assert_err_display; |
| 3 | use bstr::ByteSlice; | 3 | use bstr::ByteSlice; |
| 4 | use git_transport::packet_line::Channel; | 4 | use git_packetline::{ |
| 5 | use git_transport::{ | 5 | decode::{self, streaming, Stream}, |
| 6 | packet_line::decode::{self, streaming, Stream}, | 6 | Channel, PacketLine, |
| 7 | PacketLine, | ||
| 8 | }; | 7 | }; |
| 9 | 8 | ||
| 10 | fn assert_complete( | 9 | fn assert_complete( |
| @@ -120,7 +119,7 @@ mod streaming { · 109 unmodified lines | |||
| 120 | } | 119 | } |
| 121 | 120 | ||
| 122 | mod incomplete { | 121 | mod incomplete { |
| 123 | use git_transport::packet_line::decode::{self, streaming, Stream}; | 122 | use git_packetline::decode::{self, streaming, Stream}; |
| 124 | 123 | ||
| 125 | fn assert_incomplete(res: Result<Stream, decode::Error>, expected_missing: usize) -> crate::Result { | 124 | fn assert_incomplete(res: Result<Stream, decode::Error>, expected_missing: usize) -> crate::Result { |
| 126 | match res? { | 125 | match res? { |
| @@ -1,7 +1,7 @@ | |||
| 1 | mod data_to_write { | 1 | mod data_to_write { |
| 2 | use crate::packet_line::assert_err_display; | 2 | use crate::packet_line::assert_err_display; |
| 3 | use bstr::ByteSlice; | 3 | use bstr::ByteSlice; |
| 4 | use git_transport::packet_line::encode::{ | 4 | use git_packetline::encode::{ |
| 5 | data_to_write, delim_to_write, error_to_write, flush_to_write, response_end_to_write, text_to_write, | 5 | data_to_write, delim_to_write, error_to_write, flush_to_write, response_end_to_write, text_to_write, |
| 6 | }; | 6 | }; |
| 7 | use std::io; | 7 | use std::io; |
File renamed without changes.
| @@ -1,4 +1,4 @@ | |||
| 1 | use git_transport::{packet_line, PacketLine}; | 1 | use git_packetline::PacketLine; |
| 2 | use std::{io, path::PathBuf}; | 2 | use std::{io, path::PathBuf}; |
| 3 | 3 | ||
| 4 | fn fixture_path(path: &str) -> PathBuf { | 4 | fn fixture_path(path: &str) -> PathBuf { |
| @@ -13,12 +13,12 @@ mod to_read { · 8 unmodified lines | |||
| 13 | use crate::packet_line::read::{exhaust, fixture_bytes}; | 13 | use crate::packet_line::read::{exhaust, fixture_bytes}; |
| 14 | use bstr::ByteSlice; | 14 | use bstr::ByteSlice; |
| 15 | use git_odb::pack; | 15 | use git_odb::pack; |
| 16 | use git_transport::{packet_line, RemoteProgress}; | 16 | use git_packetline::RemoteProgress; |
| 17 | 17 | ||
| 18 | #[test] | 18 | #[test] |
| 19 | fn read_pack_with_progress_extraction() -> crate::Result { | 19 | fn read_pack_with_progress_extraction() -> crate::Result { |
| 20 | let buf = fixture_bytes("v1/01-clone.combined-output"); | 20 | let buf = fixture_bytes("v1/01-clone.combined-output"); |
| 21 | let mut rd = packet_line::Reader::new(&buf[..], None); | 21 | let mut rd = git_packetline::Reader::new(&buf[..], None); |
| 22 | assert_eq!(exhaust(&mut rd), 2); | 22 | assert_eq!(exhaust(&mut rd), 2); |
| 23 | rd.reset(); | 23 | rd.reset(); |
| 24 | assert_eq!(rd.read_line()??.to_text().0.as_bstr(), b"NAK".as_bstr()); | 24 | assert_eq!(rd.read_line()??.to_text().0.as_bstr(), b"NAK".as_bstr()); |
| @@ -47,7 +47,7 @@ mod to_read { · 22 unmodified lines | |||
| 47 | fn read_from_file_and_reader_advancement() -> crate::Result { | 47 | fn read_from_file_and_reader_advancement() -> crate::Result { |
| 48 | let mut bytes = fixture_bytes("v1/fetch/01-many-refs.response"); | 48 | let mut bytes = fixture_bytes("v1/fetch/01-many-refs.response"); |
| 49 | bytes.extend(fixture_bytes("v1/fetch/01-many-refs.response").into_iter()); | 49 | bytes.extend(fixture_bytes("v1/fetch/01-many-refs.response").into_iter()); |
| 50 | let mut rd = packet_line::Reader::new(&bytes[..], None); | 50 | let mut rd = git_packetline::Reader::new(&bytes[..], None); |
| 51 | assert_eq!( | 51 | assert_eq!( |
| 52 | rd.read_line()??.as_bstr(), | 52 | rd.read_line()??.as_bstr(), |
| 53 | PacketLine::Data(b"7814e8a05a59c0cf5fb186661d1551c75d1299b5 HEAD\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed symref=HEAD:refs/heads/master object-format=sha1 agent=git/2.28.0\n").as_bstr() | 53 | PacketLine::Data(b"7814e8a05a59c0cf5fb186661d1551c75d1299b5 HEAD\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed symref=HEAD:refs/heads/master object-format=sha1 agent=git/2.28.0\n").as_bstr() |
| @@ -68,7 +68,7 @@ fn read_from_file_and_reader_advancement() -> crate::Result { · 14 unmodified lines | |||
| 68 | Ok(()) | 68 | Ok(()) |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | fn exhaust(rd: &mut packet_line::Reader<&[u8]>) -> i32 { | 71 | fn exhaust(rd: &mut git_packetline::Reader<&[u8]>) -> i32 { |
| 72 | let mut count = 0; | 72 | let mut count = 0; |
| 73 | while let Ok(_) = rd.read_line() { | 73 | while let Ok(_) = rd.read_line() { |
| 74 | count += 1; | 74 | count += 1; |
| @@ -0,0 +1,3 @@ | |||
| 1 | pub type Result = std::result::Result<(), Box<dyn std::error::Error>>; | ||
| 2 | |||
| 3 | mod packet_line; | ||
| @@ -15,7 +15,7 @@ doctest = false · 14 unmodified lines | |||
| 15 | serde1 = ["serde", "bstr/serde1"] | 15 | serde1 = ["serde", "bstr/serde1"] |
| 16 | 16 | ||
| 17 | [dependencies] | 17 | [dependencies] |
| 18 | git-transport = { version = "^0.1.0", path = "../git-transport" } | 18 | git-packetline = { version = "^0.1.0", path = "../git-packetline" } |
| 19 | 19 | ||
| 20 | quick-error = "2.0.0" | 20 | quick-error = "2.0.0" |
| 21 | serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]} | 21 | serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]} |
| @@ -1,4 +1,4 @@ | |||
| 1 | use git_transport::RemoteProgress; | 1 | use git_packetline::RemoteProgress; |
| 2 | use nom::{ | 2 | use nom::{ |
| 3 | bytes::complete::{tag, take_till, take_till1}, | 3 | bytes::complete::{tag, take_till, take_till1}, |
| 4 | combinator::{map_res, opt}, | 4 | combinator::{map_res, opt}, |
| @@ -1,7 +1,7 @@ | |||
| 1 | mod parse { | 1 | mod parse { |
| 2 | use bstr::ByteSlice; | 2 | use bstr::ByteSlice; |
| 3 | use git_packetline::RemoteProgress; | ||
| 3 | use git_protocol::parse_remote_progress; | 4 | use git_protocol::parse_remote_progress; |
| 4 | use git_transport::RemoteProgress; | ||
| 5 | 5 | ||
| 6 | #[test] | 6 | #[test] |
| 7 | fn a_message_we_dont_understand() { | 7 | fn a_message_we_dont_understand() { |
| @@ -23,11 +23,7 @@ git-url = { version = "^0.1.0", path = "../git-url" } · 22 unmodified lines | |||
| 23 | 23 | ||
| 24 | serde = { version = "1.0.114", optional = true, default-features = false, features = ["std", "derive"]} | 24 | serde = { version = "1.0.114", optional = true, default-features = false, features = ["std", "derive"]} |
| 25 | quick-error = "2.0.0" | 25 | quick-error = "2.0.0" |
| 26 | hex = "0.4.2" | ||
| 27 | bstr = { version = "0.2.13", default-features = false, features = ["std"] } | 26 | bstr = { version = "0.2.13", default-features = false, features = ["std"] } |
| 28 | 27 | ||
| 29 | # for http-curl | 28 | # for http-curl |
| 30 | curl = { version = "0.4.31", optional = true, features = ["static-ssl", "static-curl"] } | 29 | curl = { version = "0.4.31", optional = true, features = ["static-ssl", "static-curl"] } |
| 31 | |||
| 32 | [dev-dependencies] | ||
| 33 | git-odb = { version = "0.3.0", path = "../git-odb" } | ||
| @@ -1,20 +1,4 @@ | |||
| 1 | #![forbid(unsafe_code)] | 1 | #![forbid(unsafe_code)] |
| 2 | use bstr::BStr; | ||
| 3 | |||
| 4 | pub mod packet_line; | ||
| 5 | |||
| 6 | #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)] | ||
| 7 | #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] | ||
| 8 | pub struct RemoteProgress<'a> { | ||
| 9 | #[cfg_attr(feature = "serde1", serde(borrow))] | ||
| 10 | pub action: &'a BStr, | ||
| 11 | pub percent: Option<u32>, | ||
| 12 | pub step: Option<usize>, | ||
| 13 | pub max: Option<usize>, | ||
| 14 | } | ||
| 15 | |||
| 16 | #[doc(inline)] | ||
| 17 | pub use packet_line::Borrowed as PacketLine; | ||
| 18 | 2 | ||
| 19 | #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)] | 3 | #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)] |
| 20 | #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] | 4 | #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] |
| @@ -1,3 +1 @@ | |||
| 1 | pub type Result = std::result::Result<(), Box<dyn std::error::Error>>; | 1 | pub type Result = std::result::Result<(), Box<dyn std::error::Error>>; |
| 2 | |||
| 3 | mod packet_line; | ||