@@ -515,6 +515,76 @@ impl Splitter {
515515 // Initialize using gix
516516 gix:: init ( target_path)
517517 . with_context ( || format ! ( "Failed to initialize git repository at {}" , target_path. display( ) ) ) ?;
518+
519+ // Configure git identity from source repository
520+ self . configure_git_identity ( target_path) ?;
521+ }
522+
523+ Ok ( ( ) )
524+ }
525+
526+ /// Configure git identity in the target repository by copying from source
527+ fn configure_git_identity ( & self , target_path : & Path ) -> RailResult < ( ) > {
528+ use std:: process:: Command ;
529+
530+ // Get identity from source repository
531+ let user_name = Command :: new ( "git" )
532+ . current_dir ( & self . workspace_root )
533+ . args ( [ "config" , "user.name" ] )
534+ . output ( )
535+ . ok ( )
536+ . and_then ( |o| {
537+ if o. status . success ( ) {
538+ Some ( String :: from_utf8_lossy ( & o. stdout ) . trim ( ) . to_string ( ) )
539+ } else {
540+ None
541+ }
542+ } ) ;
543+
544+ let user_email = Command :: new ( "git" )
545+ . current_dir ( & self . workspace_root )
546+ . args ( [ "config" , "user.email" ] )
547+ . output ( )
548+ . ok ( )
549+ . and_then ( |o| {
550+ if o. status . success ( ) {
551+ Some ( String :: from_utf8_lossy ( & o. stdout ) . trim ( ) . to_string ( ) )
552+ } else {
553+ None
554+ }
555+ } ) ;
556+
557+ // Set identity in target repository
558+ // Use a fallback if source doesn't have identity configured
559+ let name = user_name. as_deref ( ) . unwrap_or ( "Cargo Rail" ) ;
560+ let email = user_email. as_deref ( ) . unwrap_or ( "cargo-rail@localhost" ) ;
561+
562+ let output = Command :: new ( "git" )
563+ . current_dir ( target_path)
564+ . args ( [ "config" , "user.name" , name] )
565+ . output ( )
566+ . context ( "Failed to configure git user.name" ) ?;
567+
568+ if !output. status . success ( ) {
569+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
570+ return Err ( RailError :: Git ( GitError :: CommandFailed {
571+ command : "git config user.name" . to_string ( ) ,
572+ stderr : stderr. to_string ( ) ,
573+ } ) ) ;
574+ }
575+
576+ let output = Command :: new ( "git" )
577+ . current_dir ( target_path)
578+ . args ( [ "config" , "user.email" , email] )
579+ . output ( )
580+ . context ( "Failed to configure git user.email" ) ?;
581+
582+ if !output. status . success ( ) {
583+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
584+ return Err ( RailError :: Git ( GitError :: CommandFailed {
585+ command : "git config user.email" . to_string ( ) ,
586+ stderr : stderr. to_string ( ) ,
587+ } ) ) ;
518588 }
519589
520590 Ok ( ( ) )
0 commit comments