Skip to content

Commit 38c7961

Browse files
committed
[git-features] fix compilation
1 parent 8a83e11 commit 38c7961

File tree

2 files changed

+43
-31
lines changed

2 files changed

+43
-31
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,12 @@ check: ## Build all code in suitable configurations
108108
&& cargo check --features sha1 \
109109
&& cargo check --features fast-sha1 \
110110
&& cargo check --features interrupt-handler \
111-
&& cargo check --features disable-interrupts
111+
&& cargo check --features disable-interrupts \
112+
&& cargo check --features progress \
113+
&& cargo check --features io-pipe \
114+
&& cargo check --features crc32 \
115+
&& cargo check --features zlib \
116+
&& cargo check --features zlib,zlib-ng-compat
112117
cd git-commitgraph && cargo check --all-features \
113118
&& cargo check
114119
cd git-config && cargo check --all-features \

git-features/src/hash.rs

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -119,40 +119,47 @@ pub fn bytes_of_file(
119119
Ok(id)
120120
}
121121

122-
/// A utility to automatically generate a hash while writing into an inner writer.
123-
pub struct Write<T> {
124-
/// The hash implementation.
125-
pub hash: Sha1,
126-
/// The inner writer.
127-
pub inner: T,
128-
}
129-
130-
impl<T> std::io::Write for Write<T>
131-
where
132-
T: std::io::Write,
133-
{
134-
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
135-
let written = self.inner.write(buf)?;
136-
self.hash.update(&buf[..written]);
137-
Ok(written)
122+
#[cfg(any(feature = "sha1", feature = "fast-sha1"))]
123+
mod write {
124+
use crate::hash::Sha1;
125+
126+
/// A utility to automatically generate a hash while writing into an inner writer.
127+
pub struct Write<T> {
128+
/// The hash implementation.
129+
pub hash: Sha1,
130+
/// The inner writer.
131+
pub inner: T,
138132
}
139133

140-
fn flush(&mut self) -> std::io::Result<()> {
141-
self.inner.flush()
134+
impl<T> std::io::Write for Write<T>
135+
where
136+
T: std::io::Write,
137+
{
138+
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
139+
let written = self.inner.write(buf)?;
140+
self.hash.update(&buf[..written]);
141+
Ok(written)
142+
}
143+
144+
fn flush(&mut self) -> std::io::Result<()> {
145+
self.inner.flush()
146+
}
142147
}
143-
}
144148

145-
impl<T> Write<T>
146-
where
147-
T: std::io::Write,
148-
{
149-
/// Create a new hash writer which hashes all bytes written to `inner` with a hash of `kind`.
150-
pub fn new(inner: T, kind: git_hash::Kind) -> Self {
151-
match kind {
152-
git_hash::Kind::Sha1 => Write {
153-
inner,
154-
hash: Sha1::default(),
155-
},
149+
impl<T> Write<T>
150+
where
151+
T: std::io::Write,
152+
{
153+
/// Create a new hash writer which hashes all bytes written to `inner` with a hash of `kind`.
154+
pub fn new(inner: T, kind: git_hash::Kind) -> Self {
155+
match kind {
156+
git_hash::Kind::Sha1 => Write {
157+
inner,
158+
hash: Sha1::default(),
159+
},
160+
}
156161
}
157162
}
158163
}
164+
#[cfg(any(feature = "sha1", feature = "fast-sha1"))]
165+
pub use write::Write;

0 commit comments

Comments
 (0)