From 141b47f0c6697117c04c5cf0cb4af7431d410cea Mon Sep 17 00:00:00 2001 From: gruebel Date: Wed, 10 Dec 2025 00:46:28 +0100 Subject: [PATCH 1/2] fix tar feature in gix-archive --- gix-archive/src/write.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/gix-archive/src/write.rs b/gix-archive/src/write.rs index bee23c09ace..a575ad58d8a 100644 --- a/gix-archive/src/write.rs +++ b/gix-archive/src/write.rs @@ -34,21 +34,20 @@ where impl State { pub fn new(format: Format, mtime: gix_date::SecondsSinceUnixEpoch, out: W) -> Result { - Ok(match format { + match format { Format::InternalTransientNonPersistable => unreachable!("handled earlier"), - Format::Zip { .. } => return Err(Error::ZipWithoutSeek), - #[cfg(feature = "tar")] + Format::Zip { .. } => Err(Error::ZipWithoutSeek), Format::Tar => { #[cfg(feature = "tar")] { - State::Tar(( + Ok(State::Tar(( { let mut ar = tar::Builder::new(out); ar.mode(tar::HeaderMode::Deterministic); ar }, Vec::with_capacity(64 * 1024), - )) + ))) } #[cfg(not(feature = "tar"))] { @@ -58,7 +57,7 @@ where Format::TarGz { compression_level } => { #[cfg(feature = "tar_gz")] { - State::TarGz(( + Ok(State::TarGz(( { let gz = flate2::GzBuilder::new().mtime(mtime as u32).write( out, @@ -72,14 +71,18 @@ where ar }, Vec::with_capacity(64 * 1024), - )) + ))) } #[cfg(not(feature = "tar_gz"))] { - Err(Error::SupportNotCompiledIn { wanted: Format::TarGz }) + Err(Error::SupportNotCompiledIn { + wanted: Format::TarGz { + compression_level: None, + }, + }) } } - }) + } } } From cd826dc4aed24b0f7909d6e6514c6aafc9f180ba Mon Sep 17 00:00:00 2001 From: gruebel Date: Wed, 10 Dec 2025 18:01:32 +0100 Subject: [PATCH 2/2] adjust test invocation and enable deflate-flate2-zlib-rs feature --- gix-archive/Cargo.toml | 2 +- gix-archive/src/write.rs | 2 +- justfile | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gix-archive/Cargo.toml b/gix-archive/Cargo.toml index ddb0e4cb911..ec0bff184da 100644 --- a/gix-archive/Cargo.toml +++ b/gix-archive/Cargo.toml @@ -33,7 +33,7 @@ gix-path = { version = "^0.10.22", path = "../gix-path", optional = true } gix-date = { version = "^0.11.0", path = "../gix-date" } flate2 = { version = "1.1.1", optional = true, default-features = false, features = ["zlib-rs"] } -zip = { version = "6.0.0", optional = true, default-features = false, features = ["deflate-flate2"] } +zip = { version = "6.0.0", optional = true, default-features = false, features = ["deflate-flate2-zlib-rs"] } jiff = { version = "0.2.15", default-features = false, features = ["std"] } thiserror = "2.0.17" diff --git a/gix-archive/src/write.rs b/gix-archive/src/write.rs index a575ad58d8a..c9813f36de3 100644 --- a/gix-archive/src/write.rs +++ b/gix-archive/src/write.rs @@ -247,7 +247,7 @@ fn tar_entry_type(mode: gix_object::tree::EntryMode) -> tar::EntryType { } } -#[cfg(any(feature = "tar", feature = "tar_gz"))] +#[cfg(any(feature = "tar", feature = "tar_gz", feature = "zip"))] fn add_prefix<'a>(relative_path: &'a bstr::BStr, prefix: Option<&bstr::BString>) -> std::borrow::Cow<'a, bstr::BStr> { use std::borrow::Cow; match prefix { diff --git a/justfile b/justfile index eeb7a76229e..a5b9ef8ff76 100755 --- a/justfile +++ b/justfile @@ -149,9 +149,9 @@ unit-tests: cargo nextest run -p gix-testtools --no-fail-fast cargo nextest run -p gix-testtools --features xz --no-fail-fast cargo nextest run -p gix-archive --no-default-features --no-fail-fast - cargo nextest run -p gix-archive --features tar --no-fail-fast - cargo nextest run -p gix-archive --features tar_gz --no-fail-fast - cargo nextest run -p gix-archive --features zip --no-fail-fast + cargo nextest run -p gix-archive --no-default-features --features tar --no-fail-fast + cargo nextest run -p gix-archive --no-default-features --features tar_gz --no-fail-fast + cargo nextest run -p gix-archive --no-default-features --features zip --no-fail-fast cargo nextest run -p gix-status-tests --features gix-features-parallel --no-fail-fast cargo nextest run -p gix-worktree-state-tests --features gix-features-parallel --no-fail-fast cargo nextest run -p gix-worktree-tests --features gix-features-parallel --no-fail-fast