Skip to content

Commit f2c6a19

Browse files
djcByron
authored andcommitted
fix!: make gix-packeline features additive.
For good measure, everything that was touched is marked as breaking change.
1 parent fbf9c39 commit f2c6a19

Some content is hidden

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

76 files changed

+650
-3431
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",

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: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub mod invoke {
4141
#[error("Failed to read or write to the process")]
4242
Io(#[from] std::io::Error),
4343
#[error(transparent)]
44-
PacketlineDecode(#[from] gix_packetline_blocking::decode::Error),
44+
PacketlineDecode(#[from] gix_packetline::decode::Error),
4545
}
4646

4747
impl From<super::Error> for Error {
@@ -65,18 +65,19 @@ impl Client {
6565
versions: &[usize],
6666
desired_capabilities: &[&str],
6767
) -> Result<Self, handshake::Error> {
68-
let mut out =
69-
gix_packetline_blocking::Writer::new(process.stdin.take().expect("configured stdin when spawning"));
68+
let mut out = gix_packetline::write::blocking_io::Writer::new(
69+
process.stdin.take().expect("configured stdin when spawning"),
70+
);
7071
out.write_all(format!("{welcome_prefix}-client").as_bytes())?;
7172
for version in versions {
7273
out.write_all(format!("version={version}").as_bytes())?;
7374
}
74-
gix_packetline_blocking::encode::flush_to_write(out.inner_mut())?;
75+
gix_packetline::encode::blocking_io::flush_to_write(out.inner_mut())?;
7576
out.flush()?;
7677

77-
let mut input = gix_packetline_blocking::StreamingPeekableIter::new(
78+
let mut input = gix_packetline::read::blocking_io::StreamingPeekableIter::new(
7879
process.stdout.take().expect("configured stdout when spawning"),
79-
&[gix_packetline_blocking::PacketLineRef::Flush],
80+
&[gix_packetline::PacketLineRef::Flush],
8081
false, /* packet tracing */
8182
);
8283
let mut read = input.as_read();
@@ -126,10 +127,10 @@ impl Client {
126127
for capability in desired_capabilities {
127128
out.write_all(format!("capability={capability}").as_bytes())?;
128129
}
129-
gix_packetline_blocking::encode::flush_to_write(out.inner_mut())?;
130+
gix_packetline::encode::blocking_io::flush_to_write(out.inner_mut())?;
130131
out.flush()?;
131132

132-
read.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
133+
read.reset_with(&[gix_packetline::PacketLineRef::Flush]);
133134
let mut capabilities = HashSet::new();
134135
loop {
135136
buf.clear();
@@ -168,7 +169,7 @@ impl Client {
168169
) -> Result<process::Status, invoke::Error> {
169170
self.send_command_and_meta(command, meta)?;
170171
std::io::copy(content, &mut self.input)?;
171-
gix_packetline_blocking::encode::flush_to_write(self.input.inner_mut())?;
172+
gix_packetline::encode::blocking_io::flush_to_write(self.input.inner_mut())?;
172173
self.input.flush()?;
173174
Ok(self.read_status()?)
174175
}
@@ -190,15 +191,15 @@ impl Client {
190191
inspect_line(line.as_bstr());
191192
}
192193
}
193-
self.out.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
194+
self.out.reset_with(&[gix_packetline::PacketLineRef::Flush]);
194195
let status = self.read_status()?;
195196
Ok(status)
196197
}
197198

198199
/// Return a `Read` implementation that reads the server process output until the next flush package, and validates
199200
/// the status. If the status indicates failure, the last read will also fail.
200201
pub fn as_read(&mut self) -> impl std::io::Read + '_ {
201-
self.out.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
202+
self.out.reset_with(&[gix_packetline::PacketLineRef::Flush]);
202203
ReadProcessOutputAndStatus {
203204
inner: self.out.as_read(),
204205
}
@@ -226,7 +227,7 @@ impl Client {
226227
buf.push_str(&value);
227228
self.input.write_all(&buf)?;
228229
}
229-
gix_packetline_blocking::encode::flush_to_write(self.input.inner_mut())?;
230+
gix_packetline::encode::blocking_io::flush_to_write(self.input.inner_mut())?;
230231
Ok(())
231232
}
232233
}
@@ -249,7 +250,7 @@ fn read_status(read: &mut PacketlineReader<'_>) -> std::io::Result<process::Stat
249250
if count > 0 && matches!(status, process::Status::Previous) {
250251
status = process::Status::Unset;
251252
}
252-
read.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
253+
read.reset_with(&[gix_packetline::PacketLineRef::Flush]);
253254
Ok(status)
254255
}
255256

@@ -261,7 +262,7 @@ impl std::io::Read for ReadProcessOutputAndStatus<'_> {
261262
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
262263
let num_read = self.inner.read(buf)?;
263264
if num_read == 0 {
264-
self.inner.reset_with(&[gix_packetline_blocking::PacketLineRef::Flush]);
265+
self.inner.reset_with(&[gix_packetline::PacketLineRef::Flush]);
265266
let status = read_status(&mut self.inner)?;
266267
if status.is_success() {
267268
Ok(0)

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ pub struct Client {
1212
/// The negotiated version of the protocol.
1313
version: usize,
1414
/// A way to send packet-line encoded information to the process.
15-
input: gix_packetline_blocking::Writer<std::process::ChildStdin>,
15+
input: gix_packetline::write::blocking_io::Writer<std::process::ChildStdin>,
1616
/// A way to read information sent to us by the process.
17-
out: gix_packetline_blocking::StreamingPeekableIter<std::process::ChildStdout>,
17+
out: gix_packetline::read::blocking_io::StreamingPeekableIter<std::process::ChildStdout>,
1818
}
1919

2020
/// A handle to facilitate typical server interactions that include the handshake and command-invocations.
@@ -24,9 +24,9 @@ pub struct Server {
2424
/// The negotiated version of the protocol, it's the highest supported one.
2525
version: usize,
2626
/// A way to receive information from the client.
27-
input: gix_packetline_blocking::StreamingPeekableIter<std::io::StdinLock<'static>>,
27+
input: gix_packetline::read::blocking_io::StreamingPeekableIter<std::io::StdinLock<'static>>,
2828
/// A way to send information to the client.
29-
out: gix_packetline_blocking::Writer<std::io::StdoutLock<'static>>,
29+
out: gix_packetline::write::blocking_io::Writer<std::io::StdoutLock<'static>>,
3030
}
3131

3232
/// The return status of an [invoked command][Client::invoke()].
@@ -109,8 +109,5 @@ pub mod client;
109109
///
110110
pub mod server;
111111

112-
type PacketlineReader<'a, T = std::process::ChildStdout> = gix_packetline_blocking::read::WithSidebands<
113-
'a,
114-
T,
115-
fn(bool, &[u8]) -> gix_packetline_blocking::read::ProgressAction,
116-
>;
112+
type PacketlineReader<'a, T = std::process::ChildStdout> =
113+
gix_packetline::read::blocking_io::WithSidebands<'a, T, fn(bool, &[u8]) -> gix_packetline::read::ProgressAction>;

0 commit comments

Comments
 (0)