From 122d69fee217eb264a335f0a056d03eba066332e Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 1 Jul 2020 20:17:42 +0800 Subject: [PATCH] assure pretty progress doesn't occlude the output --- src/plumbing/pretty.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/plumbing/pretty.rs b/src/plumbing/pretty.rs index a7ff9b46cd3..f948c97e8f4 100644 --- a/src/plumbing/pretty.rs +++ b/src/plumbing/pretty.rs @@ -1,7 +1,7 @@ use anyhow::Result; use git_features::progress; use gitoxide_core as core; -use std::io::{stderr, stdout}; +use std::io::{stderr, stdout, Write}; use structopt::StructOpt; mod options { @@ -93,9 +93,16 @@ pub fn main() -> Result<()> { progress, statistics, } => { - let (_keep, progress) = init_progress("verify-pack", verbose, progress); - core::verify_pack_or_pack_index(path, progress, statistics, stdout(), stderr()) - .map(|_| ()) + let (handle, progress) = init_progress("verify-pack", verbose, progress); + let mut buf = Vec::new(); + let res = + core::verify_pack_or_pack_index(path, progress, statistics, &mut buf, stderr()) + .map(|_| ()); + // We might have something interesting to show, which would be hidden by the alternate screen if there is a progress TUI + // We know that the printing happens at the end, so this is fine. + drop(handle); + stdout().write_all(&buf)?; + res } }?; Ok(())