Skip to content

Commit

Permalink
upgrade to prodash v21 (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Oct 17, 2022
1 parent f869b22 commit a0655dc
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 38 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ git-repository = { version = "^0.25.0", path = "git-repository", default-feature
git-transport-for-configuration-only = { package = "git-transport", optional = true, version = "^0.21.0", path = "git-transport" }

clap = { version = "3.2.5", features = ["derive", "cargo"] }
prodash = { version = "20.2.0", optional = true, default-features = false }
prodash = { version = "21", optional = true, default-features = false }
atty = { version = "0.2.14", optional = true, default-features = false }
env_logger = { version = "0.9.0", default-features = false }
crosstermion = { version = "0.10.1", optional = true, default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion git-features/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ crc32fast = { version = "1.2.1", optional = true }
sha1 = { version = "0.10.0", optional = true }

# progress
prodash = { version = "20.2.0", optional = true, default-features = false, features = ["unit-bytes", "unit-human"] }
prodash = { version = "21", optional = true, default-features = false, features = ["unit-bytes", "unit-human"] }

# pipe
bytes = { version = "1.0.0", optional = true }
Expand Down
10 changes: 7 additions & 3 deletions git-pack/src/bundle/write/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,19 @@ impl crate::Bundle {
/// As it sends portions of the input to a thread it requires the 'static lifetime for the interrupt flags. This can only
/// be satisfied by a static AtomicBool which is only suitable for programs that only run one of these operations at a time
/// or don't mind that all of them abort when the flag is set.
pub fn write_to_directory_eagerly(
pub fn write_to_directory_eagerly<P>(
pack: impl io::Read + Send + 'static,
pack_size: Option<u64>,
directory: Option<impl AsRef<Path>>,
mut progress: impl Progress,
mut progress: P,
should_interrupt: &'static AtomicBool,
thin_pack_base_object_lookup_fn: Option<ThinPackLookupFnSend>,
options: Options,
) -> Result<Outcome, Error> {
) -> Result<Outcome, Error>
where
P: Progress,
<P as Progress>::SubProgress: 'static,
{
let mut read_progress = progress.add_child("read pack");
read_progress.init(pack_size.map(|s| s as usize), progress::bytes());
let pack = progress::Read {
Expand Down
2 changes: 1 addition & 1 deletion git-pack/src/data/output/entry/iter_from_counts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::data::output;
pub fn iter_from_counts<Find>(
mut counts: Vec<output::Count>,
db: Find,
mut progress: impl Progress,
mut progress: impl Progress + 'static,
Options {
version,
mode,
Expand Down
15 changes: 9 additions & 6 deletions git-protocol/src/fetch_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,19 @@ impl Default for FetchConnection {
///
/// _Note_ that depending on the `delegate`, the actual action performed can be `ls-refs`, `clone` or `fetch`.
#[maybe_async]
pub async fn fetch<F, D, T>(
pub async fn fetch<F, D, T, P>(
mut transport: T,
mut delegate: D,
authenticate: F,
mut progress: impl Progress,
mut progress: P,
fetch_mode: FetchConnection,
) -> Result<(), Error>
where
F: FnMut(credentials::helper::Action) -> credentials::protocol::Result,
D: Delegate,
T: client::Transport,
P: Progress,
<P as Progress>::SubProgress: 'static,
{
let handshake::Outcome {
server_protocol_version: protocol_version,
Expand Down Expand Up @@ -141,10 +143,11 @@ where
Ok(())
}

fn setup_remote_progress(
progress: &mut impl Progress,
reader: &mut Box<dyn git_transport::client::ExtendedBufRead + Unpin + '_>,
) {
fn setup_remote_progress<T>(progress: &mut T, reader: &mut Box<dyn git_transport::client::ExtendedBufRead + Unpin + '_>)
where
T: Progress,
<T as Progress>::SubProgress: 'static,
{
reader.set_progress_handler(Some(Box::new({
let mut remote_progress = progress.add_child("remote");
move |is_err: bool, data: &[u8]| {
Expand Down
20 changes: 14 additions & 6 deletions git-repository/src/clone/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ impl PrepareFetch {
///
/// Note that all data we created will be removed once this instance drops if the operation wasn't successful.
#[cfg(feature = "blocking-network-client")]
pub fn fetch_only(
pub fn fetch_only<P>(
&mut self,
progress: impl crate::Progress,
progress: P,
should_interrupt: &std::sync::atomic::AtomicBool,
) -> Result<(Repository, crate::remote::fetch::Outcome), Error> {
) -> Result<(Repository, crate::remote::fetch::Outcome), Error>
where
P: crate::Progress,
<P as crate::Progress>::SubProgress: 'static,
{
fn replace_changed_local_config(repo: &mut Repository, config: git_config::File<'static>) {
let repo_config = git_features::threading::OwnShared::make_mut(&mut repo.config.resolved);
let ids_to_remove: Vec<_> = repo_config
Expand Down Expand Up @@ -189,11 +193,15 @@ impl PrepareFetch {

/// Similar to [`fetch_only()`][Self::fetch_only()`], but passes ownership to a utility type to configure a checkout operation.
#[cfg(feature = "blocking-network-client")]
pub fn fetch_then_checkout(
pub fn fetch_then_checkout<P>(
&mut self,
progress: impl crate::Progress,
progress: P,
should_interrupt: &std::sync::atomic::AtomicBool,
) -> Result<(crate::clone::PrepareCheckout, crate::remote::fetch::Outcome), Error> {
) -> Result<(crate::clone::PrepareCheckout, crate::remote::fetch::Outcome), Error>
where
P: crate::Progress,
<P as crate::Progress>::SubProgress: 'static,
{
let (repo, fetch_outcome) = self.fetch_only(progress, should_interrupt)?;
Ok((crate::clone::PrepareCheckout { repo: repo.into() }, fetch_outcome))
}
Expand Down
10 changes: 7 additions & 3 deletions git-repository/src/remote/connection/fetch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl<'remote, 'repo, T, P> Prepare<'remote, 'repo, T, P>
where
T: Transport,
P: Progress,
<P as Progress>::SubProgress: 'static,
{
/// Receive the pack and perform the operation as configured by git via `git-config` or overridden by various builder methods.
/// Return `Ok(None)` if there was nothing to do because all remote refs are at the same state as they are locally, or `Ok(Some(outcome))`
Expand Down Expand Up @@ -267,10 +268,13 @@ where
}
}

fn setup_remote_progress(
progress: &mut impl Progress,
fn setup_remote_progress<P>(
progress: &mut P,
reader: &mut Box<dyn git_protocol::transport::client::ExtendedBufRead + Unpin + '_>,
) {
) where
P: Progress,
<P as Progress>::SubProgress: 'static,
{
use git_protocol::transport::client::ExtendedBufRead;
reader.set_progress_handler(Some(Box::new({
let mut remote_progress = progress.add_child("remote");
Expand Down
6 changes: 4 additions & 2 deletions gitoxide-core/src/pack/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ pub struct Context<W> {
pub out: W,
}

pub fn create<W>(
pub fn create<W, P>(
repository_path: impl AsRef<Path>,
tips: impl IntoIterator<Item = impl AsRef<OsStr>>,
input: Option<impl io::BufRead + Send + 'static>,
output_directory: Option<impl AsRef<Path>>,
mut progress: impl Progress,
mut progress: P,
Context {
expansion,
nondeterministic_thread_count,
Expand All @@ -115,6 +115,8 @@ pub fn create<W>(
) -> anyhow::Result<()>
where
W: std::io::Write,
P: Progress,
P::SubProgress: 'static,
{
let repo = git::discover(repository_path)?.into_sync();
progress.init(Some(2), progress::steps());
Expand Down
10 changes: 7 additions & 3 deletions gitoxide-core/src/pack/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,16 @@ pub enum PathOrRead {
Read(Box<dyn std::io::Read + Send + 'static>),
}

pub fn from_pack(
pub fn from_pack<P>(
pack: PathOrRead,
directory: Option<PathBuf>,
progress: impl Progress,
progress: P,
ctx: Context<'static, impl io::Write>,
) -> anyhow::Result<()> {
) -> anyhow::Result<()>
where
P: Progress,
P::SubProgress: 'static,
{
use anyhow::Context;
let options = pack::bundle::write::Options {
thread_limit: ctx.thread_limit,
Expand Down
9 changes: 7 additions & 2 deletions gitoxide-core/src/pack/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,20 @@ mod blocking_io {
}
}

pub fn receive<P: Progress, W: io::Write>(
pub fn receive<P, W>(
protocol: Option<net::Protocol>,
url: &str,
directory: Option<PathBuf>,
refs_directory: Option<PathBuf>,
wanted_refs: Vec<BString>,
progress: P,
ctx: Context<W>,
) -> anyhow::Result<()> {
) -> anyhow::Result<()>
where
W: std::io::Write,
P: Progress,
P::SubProgress: 'static,
{
let transport = net::connect(url, protocol.unwrap_or_default().into())?;
let delegate = CloneDelegate {
ctx,
Expand Down
15 changes: 10 additions & 5 deletions gitoxide-core/src/repository/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,29 @@ pub(crate) mod function {
use anyhow::bail;
use git_repository as git;
use git_repository::remote::fetch::Status;
use git_repository::Progress;
use std::ffi::OsStr;

use super::Options;
use crate::repository::fetch::function::print_updates;
use crate::OutputFormat;

pub fn clone(
pub fn clone<P>(
remote: impl AsRef<OsStr>,
directory: impl AsRef<std::path::Path>,
mut progress: impl git::Progress,
mut progress: P,
mut out: impl std::io::Write,
err: impl std::io::Write,
Options {
format,
handshake_info,
bare,
}: Options,
) -> anyhow::Result<()> {
) -> anyhow::Result<()>
where
P: Progress,
P::SubProgress: 'static,
{
if format != OutputFormat::Human {
bail!("JSON output isn't yet supported for fetching.");
}
Expand All @@ -48,7 +53,7 @@ pub(crate) mod function {
},
)?;
let (mut checkout, fetch_outcome) =
prepare.fetch_then_checkout(progress.add_child("fetch"), &git::interrupt::IS_INTERRUPTED)?;
prepare.fetch_then_checkout(&mut progress, &git::interrupt::IS_INTERRUPTED)?;

if handshake_info {
writeln!(out, "Handshake Information")?;
Expand Down Expand Up @@ -89,7 +94,7 @@ pub(crate) mod function {
let repo = if bare {
checkout.persist()
} else {
checkout.main_worktree(progress.add_child("clone"), &git::interrupt::IS_INTERRUPTED)?
checkout.main_worktree(progress, &git::interrupt::IS_INTERRUPTED)?
};
writeln!(
out,
Expand Down
10 changes: 7 additions & 3 deletions gitoxide-core/src/repository/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ pub(crate) mod function {
use super::Options;
use crate::OutputFormat;

pub fn fetch(
pub fn fetch<P>(
repo: git::Repository,
progress: impl git::Progress,
progress: P,
mut out: impl std::io::Write,
err: impl std::io::Write,
Options {
Expand All @@ -34,7 +34,11 @@ pub(crate) mod function {
handshake_info,
ref_specs,
}: Options,
) -> anyhow::Result<()> {
) -> anyhow::Result<()>
where
P: git::Progress,
P::SubProgress: 'static,
{
if format != OutputFormat::Human {
bail!("JSON output isn't yet supported for fetching.");
}
Expand Down

0 comments on commit a0655dc

Please sign in to comment.