@@ -9,6 +9,7 @@ use std::{
99
1010use anyhow:: Result ;
1111use clap:: Parser ;
12+ use git_repository:: bstr:: io:: BufReadExt ;
1213use gitoxide_core as core;
1314use gitoxide_core:: pack:: verify;
1415
@@ -206,12 +207,23 @@ pub fn main() -> Result<()> {
206207 progress_keep_open,
207208 None ,
208209 move |_progress, out, _err| {
210+ use git:: bstr:: ByteSlice ;
209211 core:: repository:: exclude:: query (
210212 repository. into ( ) ,
213+ if pathspecs. is_empty ( ) {
214+ Box :: new (
215+ stdin_or_bail ( ) ?
216+ . byte_lines ( )
217+ . filter_map ( Result :: ok)
218+ . map ( |line| git:: path:: Spec :: from_bytes ( line. as_bstr ( ) ) )
219+ . flatten ( ) ,
220+ ) as Box < dyn Iterator < Item = git:: path:: Spec > >
221+ } else {
222+ Box :: new ( pathspecs. into_iter ( ) )
223+ } ,
211224 out,
212225 core:: repository:: exclude:: query:: Options {
213226 format,
214- pathspecs,
215227 show_ignore_patterns,
216228 overrides : patterns,
217229 } ,
@@ -341,16 +353,7 @@ pub fn main() -> Result<()> {
341353 progress_keep_open,
342354 core:: pack:: create:: PROGRESS_RANGE ,
343355 move |progress, out, _err| {
344- let input = if has_tips {
345- None
346- } else {
347- if atty:: is ( atty:: Stream :: Stdin ) {
348- anyhow:: bail!(
349- "Refusing to read from standard input as no path is given, but it's a terminal."
350- )
351- }
352- Some ( BufReader :: new ( stdin ( ) ) )
353- } ;
356+ let input = if has_tips { None } else { stdin_or_bail ( ) ?. into ( ) } ;
354357 let repository = repository. unwrap_or_else ( || PathBuf :: from ( "." ) ) ;
355358 let context = core:: pack:: create:: Context {
356359 thread_limit,
@@ -641,6 +644,13 @@ pub fn main() -> Result<()> {
641644 Ok ( ( ) )
642645}
643646
647+ fn stdin_or_bail ( ) -> anyhow:: Result < std:: io:: BufReader < std:: io:: Stdin > > {
648+ if atty:: is ( atty:: Stream :: Stdin ) {
649+ anyhow:: bail!( "Refusing to read from standard input while a terminal is connected" )
650+ }
651+ Ok ( BufReader :: new ( stdin ( ) ) )
652+ }
653+
644654fn verify_mode ( decode : bool , re_encode : bool ) -> verify:: Mode {
645655 match ( decode, re_encode) {
646656 ( true , false ) => verify:: Mode :: HashCrc32Decode ,
0 commit comments