Skip to content

Commit 7e5c05f

Browse files
authored
Merge pull request #2290 from gruebel/fix-tar-feat
fix tar feature in gix-archive
2 parents e4775d2 + cd826dc commit 7e5c05f

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

gix-archive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ gix-path = { version = "^0.10.22", path = "../gix-path", optional = true }
3333
gix-date = { version = "^0.11.0", path = "../gix-date" }
3434

3535
flate2 = { version = "1.1.1", optional = true, default-features = false, features = ["zlib-rs"] }
36-
zip = { version = "6.0.0", optional = true, default-features = false, features = ["deflate-flate2"] }
36+
zip = { version = "6.0.0", optional = true, default-features = false, features = ["deflate-flate2-zlib-rs"] }
3737
jiff = { version = "0.2.15", default-features = false, features = ["std"] }
3838

3939
thiserror = "2.0.17"

gix-archive/src/write.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,20 @@ where
3434

3535
impl<W: std::io::Write> State<W> {
3636
pub fn new(format: Format, mtime: gix_date::SecondsSinceUnixEpoch, out: W) -> Result<Self, Error> {
37-
Ok(match format {
37+
match format {
3838
Format::InternalTransientNonPersistable => unreachable!("handled earlier"),
39-
Format::Zip { .. } => return Err(Error::ZipWithoutSeek),
40-
#[cfg(feature = "tar")]
39+
Format::Zip { .. } => Err(Error::ZipWithoutSeek),
4140
Format::Tar => {
4241
#[cfg(feature = "tar")]
4342
{
44-
State::Tar((
43+
Ok(State::Tar((
4544
{
4645
let mut ar = tar::Builder::new(out);
4746
ar.mode(tar::HeaderMode::Deterministic);
4847
ar
4948
},
5049
Vec::with_capacity(64 * 1024),
51-
))
50+
)))
5251
}
5352
#[cfg(not(feature = "tar"))]
5453
{
@@ -58,7 +57,7 @@ where
5857
Format::TarGz { compression_level } => {
5958
#[cfg(feature = "tar_gz")]
6059
{
61-
State::TarGz((
60+
Ok(State::TarGz((
6261
{
6362
let gz = flate2::GzBuilder::new().mtime(mtime as u32).write(
6463
out,
@@ -72,14 +71,18 @@ where
7271
ar
7372
},
7473
Vec::with_capacity(64 * 1024),
75-
))
74+
)))
7675
}
7776
#[cfg(not(feature = "tar_gz"))]
7877
{
79-
Err(Error::SupportNotCompiledIn { wanted: Format::TarGz })
78+
Err(Error::SupportNotCompiledIn {
79+
wanted: Format::TarGz {
80+
compression_level: None,
81+
},
82+
})
8083
}
8184
}
82-
})
85+
}
8386
}
8487
}
8588

@@ -244,7 +247,7 @@ fn tar_entry_type(mode: gix_object::tree::EntryMode) -> tar::EntryType {
244247
}
245248
}
246249

247-
#[cfg(any(feature = "tar", feature = "tar_gz"))]
250+
#[cfg(any(feature = "tar", feature = "tar_gz", feature = "zip"))]
248251
fn add_prefix<'a>(relative_path: &'a bstr::BStr, prefix: Option<&bstr::BString>) -> std::borrow::Cow<'a, bstr::BStr> {
249252
use std::borrow::Cow;
250253
match prefix {

justfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ unit-tests:
149149
cargo nextest run -p gix-testtools --no-fail-fast
150150
cargo nextest run -p gix-testtools --features xz --no-fail-fast
151151
cargo nextest run -p gix-archive --no-default-features --no-fail-fast
152-
cargo nextest run -p gix-archive --features tar --no-fail-fast
153-
cargo nextest run -p gix-archive --features tar_gz --no-fail-fast
154-
cargo nextest run -p gix-archive --features zip --no-fail-fast
152+
cargo nextest run -p gix-archive --no-default-features --features tar --no-fail-fast
153+
cargo nextest run -p gix-archive --no-default-features --features tar_gz --no-fail-fast
154+
cargo nextest run -p gix-archive --no-default-features --features zip --no-fail-fast
155155
cargo nextest run -p gix-status-tests --features gix-features-parallel --no-fail-fast
156156
cargo nextest run -p gix-worktree-state-tests --features gix-features-parallel --no-fail-fast
157157
cargo nextest run -p gix-worktree-tests --features gix-features-parallel --no-fail-fast

0 commit comments

Comments
 (0)