@@ -15,11 +15,7 @@ fn from_josh_err(err: josh::JoshError) -> anyhow::Error {
1515
1616/// Spawn a git command directly to the terminal so users can see progress
1717/// Falls back to captured output if not in a TTY environment
18- fn spawn_git_command (
19- cwd : & std:: path:: Path ,
20- args : & [ & str ] ,
21- env : & [ ( & str , & str ) ] ,
22- ) -> Result < i32 > {
18+ fn spawn_git_command ( cwd : & std:: path:: Path , args : & [ & str ] , env : & [ ( & str , & str ) ] ) -> Result < i32 > {
2319 debug ! ( "spawn_git_command: {:?}" , args) ;
2420 let mut command = ProcessCommand :: new ( "git" ) ;
2521 command. current_dir ( cwd) . args ( args) ;
@@ -280,14 +276,12 @@ fn apply_josh_filtering(
280276 filter : & str ,
281277 remote_name : & str ,
282278) -> Result < ( ) > {
283-
284279 // Use josh API directly instead of calling josh-filter binary
285280 let filterobj = josh:: filter:: parse ( filter)
286281 . map_err ( from_josh_err)
287282 . context ( "Failed to parse filter" ) ?;
288283
289- josh:: cache_sled:: sled_load ( & repo_path. join ( ".git" ) )
290- . context ( "Failed to load sled cache" ) ?;
284+ josh:: cache_sled:: sled_load ( & repo_path. join ( ".git" ) ) . context ( "Failed to load sled cache" ) ?;
291285
292286 let cache = std:: sync:: Arc :: new (
293287 josh:: cache_stack:: CacheStack :: new ( )
@@ -358,14 +352,13 @@ fn apply_josh_filtering(
358352
359353 // Fetch the filtered refs to create standard remote refs
360354 let path_env = std:: env:: var ( "PATH" ) . unwrap_or_default ( ) ;
361- let exit_code = spawn_git_command (
362- repo_path,
363- & [ "fetch" , remote_name] ,
364- & [ ( "PATH" , & path_env) ] ,
365- ) ?;
355+ let exit_code = spawn_git_command ( repo_path, & [ "fetch" , remote_name] , & [ ( "PATH" , & path_env) ] ) ?;
366356
367357 if exit_code != 0 {
368- return Err ( anyhow:: anyhow!( "Failed to fetch filtered refs: exit code {}" , exit_code) ) ;
358+ return Err ( anyhow:: anyhow!(
359+ "Failed to fetch filtered refs: exit code {}" ,
360+ exit_code
361+ ) ) ;
369362 }
370363
371364 Ok ( ( ) )
@@ -379,8 +372,8 @@ fn handle_clone(args: &CloneArgs) -> Result<()> {
379372 std:: fs:: create_dir_all ( & output_dir) ?;
380373
381374 // Initialize a new git repository inside the directory using git2
382- let _repo = git2 :: Repository :: init ( & output_dir )
383- . context ( "Failed to initialize git repository" ) ?;
375+ let _repo =
376+ git2 :: Repository :: init ( & output_dir ) . context ( "Failed to initialize git repository" ) ?;
384377
385378 let original_dir = std:: env:: current_dir ( ) ?;
386379
@@ -422,8 +415,7 @@ fn handle_clone(args: &CloneArgs) -> Result<()> {
422415 let default_branch = if args. branch == "HEAD" {
423416 // Read the remote HEAD symref to get the default branch
424417 let head_ref = format ! ( "refs/remotes/origin/HEAD" ) ;
425- let repo = git2:: Repository :: open ( & output_dir)
426- . context ( "Failed to open repository" ) ?;
418+ let repo = git2:: Repository :: open ( & output_dir) . context ( "Failed to open repository" ) ?;
427419
428420 let head_reference = repo
429421 . find_reference ( & head_ref)
@@ -491,8 +483,7 @@ fn handle_clone(args: &CloneArgs) -> Result<()> {
491483
492484fn handle_pull ( args : & PullArgs ) -> Result < ( ) > {
493485 // Check if we're in a git repository
494- let repo = git2:: Repository :: open_from_env ( )
495- . context ( "Not in a git repository" ) ?;
486+ let repo = git2:: Repository :: open_from_env ( ) . context ( "Not in a git repository" ) ?;
496487 let repo_path = repo. path ( ) . parent ( ) . unwrap ( ) . to_path_buf ( ) ;
497488
498489 // Create FetchArgs from PullArgs
@@ -543,23 +534,20 @@ fn handle_pull(args: &PullArgs) -> Result<()> {
543534
544535fn handle_fetch ( args : & FetchArgs ) -> Result < ( ) > {
545536 // Check if we're in a git repository
546- let repo = git2:: Repository :: open_from_env ( )
547- . context ( "Not in a git repository" ) ?;
537+ let repo = git2:: Repository :: open_from_env ( ) . context ( "Not in a git repository" ) ?;
548538 let repo_path = repo. path ( ) . parent ( ) . unwrap ( ) . to_path_buf ( ) ;
549539
550540 handle_fetch_internal ( args, & repo_path)
551541}
552542
553543fn handle_fetch_internal ( args : & FetchArgs , repo_path : & std:: path:: Path ) -> Result < ( ) > {
554- let repo = git2:: Repository :: open ( repo_path)
555- . context ( "Failed to open repository" ) ?;
544+ let repo = git2:: Repository :: open ( repo_path) . context ( "Failed to open repository" ) ?;
556545
557546 // Get PATH environment variable for shell commands
558547 let path_env = std:: env:: var ( "PATH" ) . unwrap_or_default ( ) ;
559548
560549 // Read the remote URL from josh-remote config
561- let config = repo. config ( )
562- . context ( "Failed to get git config" ) ?;
550+ let config = repo. config ( ) . context ( "Failed to get git config" ) ?;
563551
564552 let remote_url = config
565553 . get_string ( & format ! ( "josh-remote.{}.url" , args. remote) )
@@ -643,12 +631,10 @@ fn handle_fetch_internal(args: &FetchArgs, repo_path: &std::path::Path) -> Resul
643631
644632fn handle_push ( args : & PushArgs ) -> Result < ( ) > {
645633 // Read filter from git config for the specific remote
646- let repo = git2:: Repository :: open_from_env ( )
647- . context ( "Not in a git repository" ) ?;
634+ let repo = git2:: Repository :: open_from_env ( ) . context ( "Not in a git repository" ) ?;
648635 let repo_path = repo. path ( ) . parent ( ) . unwrap ( ) ;
649636
650- let config = repo. config ( )
651- . context ( "Failed to get git config" ) ?;
637+ let config = repo. config ( ) . context ( "Failed to get git config" ) ?;
652638
653639 // Step 2: Apply reverse filtering and push to actual remote
654640 let filter_str = config
@@ -660,8 +646,7 @@ fn handle_push(args: &PushArgs) -> Result<()> {
660646 . map_err ( from_josh_err)
661647 . context ( "Failed to parse filter" ) ?;
662648
663- josh:: cache_sled:: sled_load ( repo_path)
664- . context ( "Failed to load sled cache" ) ?;
649+ josh:: cache_sled:: sled_load ( repo_path) . context ( "Failed to load sled cache" ) ?;
665650 let cache = std:: sync:: Arc :: new (
666651 josh:: cache_stack:: CacheStack :: new ( )
667652 . with_backend ( josh:: cache_sled:: SledCacheBackend :: default ( ) )
@@ -861,7 +846,11 @@ fn handle_push(args: &PushArgs) -> Result<()> {
861846 ) ?;
862847
863848 if exit_code != 0 {
864- return Err ( anyhow:: anyhow!( "git push failed for {}: exit code {}" , refname, exit_code) ) ;
849+ return Err ( anyhow:: anyhow!(
850+ "git push failed for {}: exit code {}" ,
851+ refname,
852+ exit_code
853+ ) ) ;
865854 }
866855
867856 println ! ( "Pushed {} to {}/{}" , oid, args. remote, refname) ;
@@ -879,16 +868,14 @@ fn handle_remote(args: &RemoteArgs) -> Result<()> {
879868
880869fn handle_remote_add ( args : & RemoteAddArgs ) -> Result < ( ) > {
881870 // Check if we're in a git repository
882- let repo = git2:: Repository :: open_from_env ( )
883- . context ( "Not in a git repository" ) ?;
871+ let repo = git2:: Repository :: open_from_env ( ) . context ( "Not in a git repository" ) ?;
884872 let repo_path = repo. path ( ) . parent ( ) . unwrap ( ) ;
885873
886874 handle_remote_add_internal ( args, repo_path)
887875}
888876
889877fn handle_remote_add_internal ( args : & RemoteAddArgs , repo_path : & std:: path:: Path ) -> Result < ( ) > {
890- let repo = git2:: Repository :: open ( repo_path)
891- . context ( "Failed to open repository" ) ?;
878+ let repo = git2:: Repository :: open ( repo_path) . context ( "Failed to open repository" ) ?;
892879
893880 // Store the remote information in josh-remote config instead of adding a git remote
894881 let remote_path = if args. url . starts_with ( "http" ) || args. url . starts_with ( "ssh://" ) {
@@ -909,8 +896,7 @@ fn handle_remote_add_internal(args: &RemoteAddArgs, repo_path: &std::path::Path)
909896 format ! ( "{}:prune=trivial-merge" , args. filter)
910897 } ;
911898
912- let mut config = repo. config ( )
913- . context ( "Failed to get git config" ) ?;
899+ let mut config = repo. config ( ) . context ( "Failed to get git config" ) ?;
914900
915901 // Store remote URL in josh-remote section
916902 config
@@ -947,7 +933,10 @@ fn handle_remote_add_internal(args: &RemoteAddArgs, repo_path: &std::path::Path)
947933 ) ?;
948934
949935 if exit_code != 0 {
950- return Err ( anyhow:: anyhow!( "Failed to add git remote: exit code {}" , exit_code) ) ;
936+ return Err ( anyhow:: anyhow!(
937+ "Failed to add git remote: exit code {}" ,
938+ exit_code
939+ ) ) ;
951940 }
952941
953942 // Set up namespace configuration for the remote
@@ -965,7 +954,10 @@ fn handle_remote_add_internal(args: &RemoteAddArgs, repo_path: &std::path::Path)
965954 ) ?;
966955
967956 if exit_code != 0 {
968- return Err ( anyhow:: anyhow!( "Failed to set remote uploadpack: exit code {}" , exit_code) ) ;
957+ return Err ( anyhow:: anyhow!(
958+ "Failed to set remote uploadpack: exit code {}" ,
959+ exit_code
960+ ) ) ;
969961 }
970962
971963 println ! (
@@ -978,8 +970,7 @@ fn handle_remote_add_internal(args: &RemoteAddArgs, repo_path: &std::path::Path)
978970
979971/// Handle the `josh filter` command - apply filtering to existing refs without fetching
980972fn handle_filter ( args : & FilterArgs ) -> Result < ( ) > {
981- let repo = git2:: Repository :: open_from_env ( )
982- . context ( "Not in a git repository" ) ?;
973+ let repo = git2:: Repository :: open_from_env ( ) . context ( "Not in a git repository" ) ?;
983974 let repo_path = repo. path ( ) . parent ( ) . unwrap ( ) . to_path_buf ( ) ;
984975
985976 handle_filter_internal ( args, & repo_path, true )
@@ -991,12 +982,10 @@ fn handle_filter_internal(
991982 repo_path : & std:: path:: Path ,
992983 print_messages : bool ,
993984) -> Result < ( ) > {
994- let repo = git2:: Repository :: open ( repo_path)
995- . context ( "Failed to open repository" ) ?;
985+ let repo = git2:: Repository :: open ( repo_path) . context ( "Failed to open repository" ) ?;
996986
997987 // Read the filter from git config for this remote
998- let config = repo. config ( )
999- . context ( "Failed to get git config" ) ?;
988+ let config = repo. config ( ) . context ( "Failed to get git config" ) ?;
1000989
1001990 let filter_key = format ! ( "josh-remote.{}.filter" , args. remote) ;
1002991 let filter = config
0 commit comments