@@ -496,33 +496,23 @@ impl<'gctx> PathSource<'gctx> {
496
496
) ;
497
497
498
498
let pkg_path = pkg. root ( ) ;
499
- let mut target_prefix;
500
499
let repo_relative_pkg_path = pkg_path. strip_prefix ( root) . unwrap_or ( Path :: new ( "" ) ) ;
500
+ let target_prefix = gix:: path:: to_unix_separators_on_windows ( gix:: path:: into_bstr (
501
+ repo_relative_pkg_path. join ( "target" ) ,
502
+ ) ) ;
503
+ let package_prefix =
504
+ gix:: path:: to_unix_separators_on_windows ( gix:: path:: into_bstr ( repo_relative_pkg_path) ) ;
501
505
502
506
let pathspec = {
503
- let mut include = gix :: path :: to_unix_separators_on_windows ( gix :: path :: into_bstr (
504
- repo_relative_pkg_path ,
505
- ) ) ;
507
+ // Include the package root.
508
+ let mut include = BString :: from ( ":/" ) ;
509
+ include . push_str ( package_prefix . as_ref ( ) ) ;
506
510
507
- target_prefix = include. clone ( ) ;
508
- target_prefix. to_mut ( ) . push_str ( if include. is_empty ( ) {
509
- "target/"
510
- } else {
511
- "/target/"
512
- } ) ;
513
-
514
- // The `target` directory is never included if it is in the package root.
515
- let exclude = {
516
- let mut pattern = include. clone ( ) ;
517
- pattern
518
- . to_mut ( )
519
- . insert_str ( 0 , if include. is_empty ( ) { ":!" } else { ":!/" } ) ;
520
- pattern. to_mut ( ) . push_str ( b"/target/" ) ;
521
- pattern
522
- } ;
523
- include. to_mut ( ) . insert_str ( 0 , ":/" ) ;
511
+ // Exclude the target directory.
512
+ let mut exclude = BString :: from ( ":!" ) ;
513
+ exclude. push_str ( target_prefix. as_ref ( ) ) ;
524
514
525
- vec ! [ include. into_owned ( ) , exclude. into_owned ( ) ]
515
+ vec ! [ include, exclude]
526
516
} ;
527
517
528
518
let mut files = Vec :: < PathBuf > :: new ( ) ;
0 commit comments