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 | 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 | 664 | [[package]] |
| 653 | 665 | name = "git-protocol" |
| 654 | 666 | version = "0.1.0" |
| 655 | 667 | dependencies = [ |
| 656 | 668 | "bstr", |
| 657 | 669 | "btoi", |
| 658 | − "git-transport", | |
| 670 | + "git-packetline", | |
| 659 | 671 | "nom", |
| 660 | 672 | "quick-error 2.0.0", |
| 661 | 673 | "serde", |
| @@ -683,9 +695,7 @@ dependencies = [ · 21 unmodified lines | ||
| 683 | 695 | "bstr", |
| 684 | 696 | "curl", |
| 685 | 697 | "git-features", |
| 686 | − "git-odb", | |
| 687 | 698 | "git-url", |
| 688 | − "hex", | |
| 689 | 699 | "quick-error 2.0.0", |
| 690 | 700 | "serde", |
| 691 | 701 | ] |
| @@ -91,5 +91,6 @@ members = [ · 90 unmodified lines | ||
| 91 | 91 | "git-protocol", |
| 92 | 92 | "git-url", |
| 93 | 93 | "git-transport", |
| 94 | + "git-packetline", | |
| 94 | 95 | "git-tui", |
| 95 | 96 | ] |
| @@ -83,6 +83,8 @@ check: ## Build all code in suitable configurations · 82 unmodified lines | ||
| 83 | 83 | cd git-object && cargo check --all-features |
| 84 | 84 | cd git-odb && cargo check --all-features \ |
| 85 | 85 | && cargo check |
| 86 | + cd git-packetline && cargo check --all-features \ | |
| 87 | + && cargo check | |
| 86 | 88 | cd git-protocol && cargo check --all-features \ |
| 87 | 89 | && cargo check |
| 88 | 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 | 142 | * [x] initialize |
| 143 | 143 | * [ ] Proper configuration depending on platform (e.g. ignorecase, filemode, …) |
| 144 | 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 | 148 | * [ ] read and write all data types |
| 146 | 149 | * [ ] rev-parsing and ref history |
| 147 | 150 | * [ ] remotes with push and pull |
| @@ -22,6 +22,7 @@ indent cargo diet -n --package-size-limit 25KB · 21 unmodified lines | ||
| 22 | 22 | (enter git-object && indent cargo diet -n --package-size-limit 15KB) |
| 23 | 23 | (enter git-odb && indent cargo diet -n --package-size-limit 50KB) |
| 24 | 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 | 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 | 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 | 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 | 8 | (cd $crate && cargo release "$@") |
| 9 | 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 | 2 | use bstr::BStr; |
| 3 | 3 | use std::io; |
| 4 | 4 | |
| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | use crate::{ |
| 2 | − packet_line::{ | |
| 3 | − DELIMITER_LINE, ERR_PREFIX, FLUSH_LINE, MAX_DATA_LEN, MAX_LINE_LEN, RESPONSE_END_LINE, U16_HEX_BYTES, | |
| 4 | − }, | |
| 5 | − PacketLine, | |
| 2 | + PacketLine, {DELIMITER_LINE, ERR_PREFIX, FLUSH_LINE, MAX_DATA_LEN, MAX_LINE_LEN, RESPONSE_END_LINE, U16_HEX_BYTES}, | |
| 6 | 3 | }; |
| 7 | 4 | use bstr::BString; |
| 8 | 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 | 2 | use quick_error::quick_error; |
| 3 | 3 | use std::io; |
| 4 | 4 | |
| @@ -1,3 +1,4 @@ | ||
| 1 | +#![forbid(unsafe_code)] | |
| 1 | 2 | pub(crate) const U16_HEX_BYTES: usize = 4; |
| 2 | 3 | pub(crate) const MAX_DATA_LEN: usize = 65516; |
| 3 | 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 | 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 | 28 | pub mod borrowed; |
| 18 | −pub use borrowed::Borrowed; | |
| 29 | +pub use borrowed::Borrowed as PacketLine; | |
| 19 | 30 | |
| 20 | 31 | pub mod read; |
| 21 | 32 | #[doc(inline)] |
| @@ -1,4 +1,4 @@ | ||
| 1 | −use crate::packet_line::{ | |
| 1 | +use crate::{ | |
| 2 | 2 | borrowed::{Band, Text}, |
| 3 | 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 | 1 | mod streaming { |
| 2 | 2 | use crate::packet_line::assert_err_display; |
| 3 | 3 | use bstr::ByteSlice; |
| 4 | − use git_transport::packet_line::Channel; | |
| 5 | − use git_transport::{ | |
| 6 | − packet_line::decode::{self, streaming, Stream}, | |
| 7 | − PacketLine, | |
| 4 | + use git_packetline::{ | |
| 5 | + decode::{self, streaming, Stream}, | |
| 6 | + Channel, PacketLine, | |
| 8 | 7 | }; |
| 9 | 8 | |
| 10 | 9 | fn assert_complete( |
| @@ -120,7 +119,7 @@ mod streaming { · 109 unmodified lines | ||
| 120 | 119 | } |
| 121 | 120 | |
| 122 | 121 | mod incomplete { |
| 123 | − use git_transport::packet_line::decode::{self, streaming, Stream}; | |
| 122 | + use git_packetline::decode::{self, streaming, Stream}; | |
| 124 | 123 | |
| 125 | 124 | fn assert_incomplete(res: Result<Stream, decode::Error>, expected_missing: usize) -> crate::Result { |
| 126 | 125 | match res? { |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | mod data_to_write { |
| 2 | 2 | use crate::packet_line::assert_err_display; |
| 3 | 3 | use bstr::ByteSlice; |
| 4 | − use git_transport::packet_line::encode::{ | |
| 4 | + use git_packetline::encode::{ | |
| 5 | 5 | data_to_write, delim_to_write, error_to_write, flush_to_write, response_end_to_write, text_to_write, |
| 6 | 6 | }; |
| 7 | 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 | 2 | use std::{io, path::PathBuf}; |
| 3 | 3 | |
| 4 | 4 | fn fixture_path(path: &str) -> PathBuf { |
| @@ -13,12 +13,12 @@ mod to_read { · 8 unmodified lines | ||
| 13 | 13 | use crate::packet_line::read::{exhaust, fixture_bytes}; |
| 14 | 14 | use bstr::ByteSlice; |
| 15 | 15 | use git_odb::pack; |
| 16 | − use git_transport::{packet_line, RemoteProgress}; | |
| 16 | + use git_packetline::RemoteProgress; | |
| 17 | 17 | |
| 18 | 18 | #[test] |
| 19 | 19 | fn read_pack_with_progress_extraction() -> crate::Result { |
| 20 | 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 | 22 | assert_eq!(exhaust(&mut rd), 2); |
| 23 | 23 | rd.reset(); |
| 24 | 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 | 47 | fn read_from_file_and_reader_advancement() -> crate::Result { |
| 48 | 48 | let mut bytes = fixture_bytes("v1/fetch/01-many-refs.response"); |
| 49 | 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 | 51 | assert_eq!( |
| 52 | 52 | rd.read_line()??.as_bstr(), |
| 53 | 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 | 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 | 72 | let mut count = 0; |
| 73 | 73 | while let Ok(_) = rd.read_line() { |
| 74 | 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 | 15 | serde1 = ["serde", "bstr/serde1"] |
| 16 | 16 | |
| 17 | 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 | 20 | quick-error = "2.0.0" |
| 21 | 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 | 2 | use nom::{ |
| 3 | 3 | bytes::complete::{tag, take_till, take_till1}, |
| 4 | 4 | combinator::{map_res, opt}, |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | mod parse { |
| 2 | 2 | use bstr::ByteSlice; |
| 3 | + use git_packetline::RemoteProgress; | |
| 3 | 4 | use git_protocol::parse_remote_progress; |
| 4 | − use git_transport::RemoteProgress; | |
| 5 | 5 | |
| 6 | 6 | #[test] |
| 7 | 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 | 24 | serde = { version = "1.0.114", optional = true, default-features = false, features = ["std", "derive"]} |
| 25 | 25 | quick-error = "2.0.0" |
| 26 | −hex = "0.4.2" | |
| 27 | 26 | bstr = { version = "0.2.13", default-features = false, features = ["std"] } |
| 28 | 27 | |
| 29 | 28 | # for http-curl |
| 30 | 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 | 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 | 3 | #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)] |
| 20 | 4 | #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] |
| @@ -1,3 +1 @@ | ||
| 1 | 1 | pub type Result = std::result::Result<(), Box<dyn std::error::Error>>; |
| 2 | − | |
| 3 | −mod packet_line; | |