Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -540,41 +540,6 @@ jobs:
- name: gix-pack with all features (including wasm)
run: cargo build -p gix-pack --all-features --target "$TARGET"

check-packetline:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
# We consider this script read-only and its effect is the same everywhere.
# However, when changes are made to `etc/scripts/copy-packetline.sh`, re-enable the other platforms for testing.
# - macos-latest
# - windows-latest

runs-on: ${{ matrix.os }}

defaults:
run:
# Use `bash` even on Windows, if we ever reenable `windows-latest` for testing.
shell: bash

steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Check that working tree is initially clean
run: |
set -x
git status
git diff --exit-code
- name: Regenerate gix-packetline-blocking/src
run: etc/scripts/copy-packetline.sh
- name: Check that gix-packetline-blocking/src was already up to date
run: |
set -x
git status
git diff --exit-code

# Check that all `actions/checkout` in CI jobs have `persist-credentials: false`.
check-no-persist-credentials:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -655,7 +620,6 @@ jobs:
- test-32bit-windows-size-doc
- lint
- cargo-deny
- check-packetline
- check-no-persist-credentials
- check-blocking

Expand Down
14 changes: 1 addition & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ members = [
"gix-status",
"gix-revision",
"gix-packetline",
"gix-packetline-blocking",
"gix-mailmap",
"gix-macros",
"gix-note",
Expand Down
152 changes: 0 additions & 152 deletions etc/scripts/copy-packetline.sh

This file was deleted.

2 changes: 1 addition & 1 deletion gix-filter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ gix-command = { version = "^0.6.3", path = "../gix-command" }
gix-quote = { version = "^0.6.1", path = "../gix-quote" }
gix-utils = { version = "^0.3.1", path = "../gix-utils" }
gix-path = { version = "^0.10.21", path = "../gix-path" }
gix-packetline-blocking = { version = "^0.19.2", path = "../gix-packetline-blocking" }
gix-packetline = { version = "^0.19.2", path = "../gix-packetline", features = ["blocking-io"] }
gix-attributes = { version = "^0.28.0", path = "../gix-attributes" }

encoding_rs = "0.8.32"
Expand Down
28 changes: 14 additions & 14 deletions gix-filter/src/driver/process/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{collections::HashSet, io::Write, str::FromStr};

use bstr::{BStr, BString, ByteVec};
use gix_packetline::blocking_io::{encode, StreamingPeekableIter, Writer};

use crate::driver::{
process,
Expand Down Expand Up @@ -41,7 +42,7 @@ pub mod invoke {
#[error("Failed to read or write to the process")]
Io(#[from] std::io::Error),
#[error(transparent)]
PacketlineDecode(#[from] gix_packetline_blocking::decode::Error),
PacketlineDecode(#[from] gix_packetline::decode::Error),
}

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

let mut input = gix_packetline_blocking::StreamingPeekableIter::new(
let mut input = StreamingPeekableIter::new(
process.stdout.take().expect("configured stdout when spawning"),
&[gix_packetline_blocking::PacketLineRef::Flush],
&[gix_packetline::PacketLineRef::Flush],
false, /* packet tracing */
);
let mut read = input.as_read();
Expand Down Expand Up @@ -126,10 +126,10 @@ impl Client {
for capability in desired_capabilities {
out.write_all(format!("capability={capability}").as_bytes())?;
}
gix_packetline_blocking::encode::flush_to_write(out.inner_mut())?;
encode::flush_to_write(out.inner_mut())?;
out.flush()?;

read.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
read.reset_with(&[gix_packetline::PacketLineRef::Flush]);
let mut capabilities = HashSet::new();
loop {
buf.clear();
Expand Down Expand Up @@ -168,7 +168,7 @@ impl Client {
) -> Result<process::Status, invoke::Error> {
self.send_command_and_meta(command, meta)?;
std::io::copy(content, &mut self.input)?;
gix_packetline_blocking::encode::flush_to_write(self.input.inner_mut())?;
encode::flush_to_write(self.input.inner_mut())?;
self.input.flush()?;
Ok(self.read_status()?)
}
Expand All @@ -190,15 +190,15 @@ impl Client {
inspect_line(line.as_bstr());
}
}
self.out.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
self.out.reset_with(&[gix_packetline::PacketLineRef::Flush]);
let status = self.read_status()?;
Ok(status)
}

/// Return a `Read` implementation that reads the server process output until the next flush package, and validates
/// the status. If the status indicates failure, the last read will also fail.
pub fn as_read(&mut self) -> impl std::io::Read + '_ {
self.out.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
self.out.reset_with(&[gix_packetline::PacketLineRef::Flush]);
ReadProcessOutputAndStatus {
inner: self.out.as_read(),
}
Expand Down Expand Up @@ -226,7 +226,7 @@ impl Client {
buf.push_str(&value);
self.input.write_all(&buf)?;
}
gix_packetline_blocking::encode::flush_to_write(self.input.inner_mut())?;
encode::flush_to_write(self.input.inner_mut())?;
Ok(())
}
}
Expand All @@ -249,7 +249,7 @@ fn read_status(read: &mut PacketlineReader<'_>) -> std::io::Result<process::Stat
if count > 0 && matches!(status, process::Status::Previous) {
status = process::Status::Unset;
}
read.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
read.reset_with(&[gix_packetline::PacketLineRef::Flush]);
Ok(status)
}

Expand All @@ -261,7 +261,7 @@ impl std::io::Read for ReadProcessOutputAndStatus<'_> {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
let num_read = self.inner.read(buf)?;
if num_read == 0 {
self.inner.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
self.inner.reset_with(&[gix_packetline::PacketLineRef::Flush]);
let status = read_status(&mut self.inner)?;
if status.is_success() {
Ok(0)
Expand Down
17 changes: 8 additions & 9 deletions gix-filter/src/driver/process/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::collections::HashSet;

use gix_packetline::blocking_io::{StreamingPeekableIter, WithSidebands, Writer};

/// A set of capabilities that have been negotiated between client and server.
pub type Capabilities = HashSet<String>;

Expand All @@ -12,9 +14,9 @@ pub struct Client {
/// The negotiated version of the protocol.
version: usize,
/// A way to send packet-line encoded information to the process.
input: gix_packetline_blocking::Writer<std::process::ChildStdin>,
input: Writer<std::process::ChildStdin>,
/// A way to read information sent to us by the process.
out: gix_packetline_blocking::StreamingPeekableIter<std::process::ChildStdout>,
out: StreamingPeekableIter<std::process::ChildStdout>,
}

/// A handle to facilitate typical server interactions that include the handshake and command-invocations.
Expand All @@ -24,9 +26,9 @@ pub struct Server {
/// The negotiated version of the protocol, it's the highest supported one.
version: usize,
/// A way to receive information from the client.
input: gix_packetline_blocking::StreamingPeekableIter<std::io::StdinLock<'static>>,
input: StreamingPeekableIter<std::io::StdinLock<'static>>,
/// A way to send information to the client.
out: gix_packetline_blocking::Writer<std::io::StdoutLock<'static>>,
out: Writer<std::io::StdoutLock<'static>>,
}

/// The return status of an [invoked command][Client::invoke()].
Expand Down Expand Up @@ -109,8 +111,5 @@ pub mod client;
///
pub mod server;

type PacketlineReader<'a, T = std::process::ChildStdout> = gix_packetline_blocking::read::WithSidebands<
'a,
T,
fn(bool, &[u8]) -> gix_packetline_blocking::read::ProgressAction,
>;
type PacketlineReader<'a, T = std::process::ChildStdout> =
WithSidebands<'a, T, fn(bool, &[u8]) -> gix_packetline::read::ProgressAction>;
Loading
Loading