Skip to content

Commit cbf7445

Browse files
authored
Merge pull request #2220 from djc/dedup-packetline
Deduplicate packetline crates
2 parents fbf9c39 + 7289a04 commit cbf7445

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+761
-3584
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -540,41 +540,6 @@ jobs:
540540
- name: gix-pack with all features (including wasm)
541541
run: cargo build -p gix-pack --all-features --target "$TARGET"
542542

543-
check-packetline:
544-
strategy:
545-
fail-fast: false
546-
matrix:
547-
os:
548-
- ubuntu-latest
549-
# We consider this script read-only and its effect is the same everywhere.
550-
# However, when changes are made to `etc/scripts/copy-packetline.sh`, re-enable the other platforms for testing.
551-
# - macos-latest
552-
# - windows-latest
553-
554-
runs-on: ${{ matrix.os }}
555-
556-
defaults:
557-
run:
558-
# Use `bash` even on Windows, if we ever reenable `windows-latest` for testing.
559-
shell: bash
560-
561-
steps:
562-
- uses: actions/checkout@v5
563-
with:
564-
persist-credentials: false
565-
- name: Check that working tree is initially clean
566-
run: |
567-
set -x
568-
git status
569-
git diff --exit-code
570-
- name: Regenerate gix-packetline-blocking/src
571-
run: etc/scripts/copy-packetline.sh
572-
- name: Check that gix-packetline-blocking/src was already up to date
573-
run: |
574-
set -x
575-
git status
576-
git diff --exit-code
577-
578543
# Check that all `actions/checkout` in CI jobs have `persist-credentials: false`.
579544
check-no-persist-credentials:
580545
runs-on: ubuntu-latest
@@ -655,7 +620,6 @@ jobs:
655620
- test-32bit-windows-size-doc
656621
- lint
657622
- cargo-deny
658-
- check-packetline
659623
- check-no-persist-credentials
660624
- check-blocking
661625

Cargo.lock

Lines changed: 1 addition & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ members = [
239239
"gix-status",
240240
"gix-revision",
241241
"gix-packetline",
242-
"gix-packetline-blocking",
243242
"gix-mailmap",
244243
"gix-macros",
245244
"gix-note",

crate-status.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ A utility crate with types and functionality related to shallow-file handling.
415415
* [x] decode (zero-copy)
416416
* [x] [error line](https://github.com/git/git/blob/master/Documentation/technical/pack-protocol.txt#L28:L28)
417417
* [x] [V2 additions](https://github.com/git/git/blob/master/Documentation/technical/protocol-v2.txt#L35:L36)
418-
* [x] [side-band mode](https://github.com/git/git/blob/master/Documentation/technical/pack-protocol.txt#L467:L467)
418+
* [x] [sideband mode](https://github.com/git/git/blob/master/Documentation/technical/pack-protocol.txt#L467:L467)
419419
* [x] `Read` from packet line with (optional) progress support via sidebands
420420
* [x] `Write` with built-in packet line encoding
421421
* [x] `async` support

etc/scripts/copy-packetline.sh

Lines changed: 0 additions & 152 deletions
This file was deleted.

gix-filter/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ gix-command = { version = "^0.6.3", path = "../gix-command" }
2222
gix-quote = { version = "^0.6.1", path = "../gix-quote" }
2323
gix-utils = { version = "^0.3.1", path = "../gix-utils" }
2424
gix-path = { version = "^0.10.21", path = "../gix-path" }
25-
gix-packetline-blocking = { version = "^0.19.2", path = "../gix-packetline-blocking" }
25+
gix-packetline = { version = "^0.19.2", path = "../gix-packetline", features = ["blocking-io"] }
2626
gix-attributes = { version = "^0.28.0", path = "../gix-attributes" }
2727

2828
encoding_rs = "0.8.32"

gix-filter/src/driver/process/client.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::{collections::HashSet, io::Write, str::FromStr};
22

33
use bstr::{BStr, BString, ByteVec};
4+
use gix_packetline::blocking_io::{encode, StreamingPeekableIter, Writer};
45

56
use crate::driver::{
67
process,
@@ -41,7 +42,7 @@ pub mod invoke {
4142
#[error("Failed to read or write to the process")]
4243
Io(#[from] std::io::Error),
4344
#[error(transparent)]
44-
PacketlineDecode(#[from] gix_packetline_blocking::decode::Error),
45+
PacketlineDecode(#[from] gix_packetline::decode::Error),
4546
}
4647

4748
impl From<super::Error> for Error {
@@ -65,18 +66,17 @@ impl Client {
6566
versions: &[usize],
6667
desired_capabilities: &[&str],
6768
) -> Result<Self, handshake::Error> {
68-
let mut out =
69-
gix_packetline_blocking::Writer::new(process.stdin.take().expect("configured stdin when spawning"));
69+
let mut out = Writer::new(process.stdin.take().expect("configured stdin when spawning"));
7070
out.write_all(format!("{welcome_prefix}-client").as_bytes())?;
7171
for version in versions {
7272
out.write_all(format!("version={version}").as_bytes())?;
7373
}
74-
gix_packetline_blocking::encode::flush_to_write(out.inner_mut())?;
74+
encode::flush_to_write(out.inner_mut())?;
7575
out.flush()?;
7676

77-
let mut input = gix_packetline_blocking::StreamingPeekableIter::new(
77+
let mut input = StreamingPeekableIter::new(
7878
process.stdout.take().expect("configured stdout when spawning"),
79-
&[gix_packetline_blocking::PacketLineRef::Flush],
79+
&[gix_packetline::PacketLineRef::Flush],
8080
false, /* packet tracing */
8181
);
8282
let mut read = input.as_read();
@@ -126,10 +126,10 @@ impl Client {
126126
for capability in desired_capabilities {
127127
out.write_all(format!("capability={capability}").as_bytes())?;
128128
}
129-
gix_packetline_blocking::encode::flush_to_write(out.inner_mut())?;
129+
encode::flush_to_write(out.inner_mut())?;
130130
out.flush()?;
131131

132-
read.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
132+
read.reset_with(&[gix_packetline::PacketLineRef::Flush]);
133133
let mut capabilities = HashSet::new();
134134
loop {
135135
buf.clear();
@@ -168,7 +168,7 @@ impl Client {
168168
) -> Result<process::Status, invoke::Error> {
169169
self.send_command_and_meta(command, meta)?;
170170
std::io::copy(content, &mut self.input)?;
171-
gix_packetline_blocking::encode::flush_to_write(self.input.inner_mut())?;
171+
encode::flush_to_write(self.input.inner_mut())?;
172172
self.input.flush()?;
173173
Ok(self.read_status()?)
174174
}
@@ -190,15 +190,15 @@ impl Client {
190190
inspect_line(line.as_bstr());
191191
}
192192
}
193-
self.out.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
193+
self.out.reset_with(&[gix_packetline::PacketLineRef::Flush]);
194194
let status = self.read_status()?;
195195
Ok(status)
196196
}
197197

198198
/// Return a `Read` implementation that reads the server process output until the next flush package, and validates
199199
/// the status. If the status indicates failure, the last read will also fail.
200200
pub fn as_read(&mut self) -> impl std::io::Read + '_ {
201-
self.out.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
201+
self.out.reset_with(&[gix_packetline::PacketLineRef::Flush]);
202202
ReadProcessOutputAndStatus {
203203
inner: self.out.as_read(),
204204
}
@@ -226,7 +226,7 @@ impl Client {
226226
buf.push_str(&value);
227227
self.input.write_all(&buf)?;
228228
}
229-
gix_packetline_blocking::encode::flush_to_write(self.input.inner_mut())?;
229+
encode::flush_to_write(self.input.inner_mut())?;
230230
Ok(())
231231
}
232232
}
@@ -249,7 +249,7 @@ fn read_status(read: &mut PacketlineReader<'_>) -> std::io::Result<process::Stat
249249
if count > 0 && matches!(status, process::Status::Previous) {
250250
status = process::Status::Unset;
251251
}
252-
read.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
252+
read.reset_with(&[gix_packetline::PacketLineRef::Flush]);
253253
Ok(status)
254254
}
255255

@@ -261,7 +261,7 @@ impl std::io::Read for ReadProcessOutputAndStatus<'_> {
261261
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
262262
let num_read = self.inner.read(buf)?;
263263
if num_read == 0 {
264-
self.inner.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
264+
self.inner.reset_with(&[gix_packetline::PacketLineRef::Flush]);
265265
let status = read_status(&mut self.inner)?;
266266
if status.is_success() {
267267
Ok(0)

0 commit comments

Comments
 (0)