@@ -338,6 +338,51 @@ pub fn get_global_file_mode() -> Result<Option<bool>, String> {
338338 }
339339}
340340
341+ #[ tauri:: command]
342+ pub fn get_global_pull_rebase ( ) -> Result < Option < String > , String > {
343+ git_config_global_get ( "pull.rebase" )
344+ }
345+
346+ #[ tauri:: command]
347+ pub fn get_global_pull_ff ( ) -> Result < Option < String > , String > {
348+ git_config_global_get ( "pull.ff" )
349+ }
350+
351+ #[ tauri:: command]
352+ pub fn get_global_pull_autostash ( ) -> Result < Option < String > , String > {
353+ git_config_global_get ( "pull.autostash" )
354+ }
355+
356+ #[ tauri:: command]
357+ pub fn get_global_fetch_prune ( ) -> Result < Option < String > , String > {
358+ git_config_global_get ( "fetch.prune" )
359+ }
360+
361+ #[ tauri:: command]
362+ pub fn get_global_push_default ( ) -> Result < Option < String > , String > {
363+ git_config_global_get ( "push.default" )
364+ }
365+
366+ #[ tauri:: command]
367+ pub fn get_global_push_auto_setup_remote ( ) -> Result < Option < String > , String > {
368+ git_config_global_get ( "push.autoSetupRemote" )
369+ }
370+
371+ #[ tauri:: command]
372+ pub fn get_global_core_editor ( ) -> Result < Option < String > , String > {
373+ git_config_global_get ( "core.editor" )
374+ }
375+
376+ #[ tauri:: command]
377+ pub fn get_global_core_autocrlf ( ) -> Result < Option < String > , String > {
378+ git_config_global_get ( "core.autocrlf" )
379+ }
380+
381+ #[ tauri:: command]
382+ pub fn get_global_credential_helper ( ) -> Result < Option < String > , String > {
383+ git_config_global_get ( "credential.helper" )
384+ }
385+
341386#[ tauri:: command]
342387pub fn get_active_git_executable_path ( ) -> String {
343388 crate :: resolve_active_git_executable_path ( )
@@ -695,6 +740,139 @@ pub fn set_global_default_branch(default_branch: String) -> Result<OperationResu
695740 } )
696741}
697742
743+ fn validate_config_choice ( value : & str , allowed : & [ & str ] , label : & str ) -> Result < String , String > {
744+ let value = value. trim ( ) ;
745+ if allowed. contains ( & value) {
746+ Ok ( value. to_string ( ) )
747+ } else {
748+ Err ( format ! ( "Invalid {label}: {value}" ) )
749+ }
750+ }
751+
752+ fn set_optional_global_config (
753+ key : & str ,
754+ value : & str ,
755+ empty_message : & str ,
756+ ) -> Result < OperationResult , String > {
757+ let value = value. trim ( ) ;
758+ let message = if value. is_empty ( ) {
759+ git_config_global_unset ( key) ?;
760+ empty_message. to_string ( )
761+ } else {
762+ git_config_global_set ( key, value) ?;
763+ format ! ( "Set git global {key}={value}" )
764+ } ;
765+
766+ Ok ( OperationResult {
767+ message,
768+ output : None ,
769+ repo_path : None ,
770+ backend_used : "git-cli" . to_string ( ) ,
771+ } )
772+ }
773+
774+ #[ tauri:: command]
775+ pub fn set_global_pull_rebase ( pull_rebase : String ) -> Result < OperationResult , String > {
776+ let value = validate_config_choice (
777+ & pull_rebase,
778+ & [ "" , "false" , "true" , "merges" , "interactive" ] ,
779+ "pull.rebase" ,
780+ ) ?;
781+ set_optional_global_config (
782+ "pull.rebase" ,
783+ & value,
784+ "Cleared pull.rebase from global git config" ,
785+ )
786+ }
787+
788+ #[ tauri:: command]
789+ pub fn set_global_pull_ff ( pull_ff : String ) -> Result < OperationResult , String > {
790+ let value = validate_config_choice ( & pull_ff, & [ "" , "true" , "false" , "only" ] , "pull.ff" ) ?;
791+ set_optional_global_config ( "pull.ff" , & value, "Cleared pull.ff from global git config" )
792+ }
793+
794+ #[ tauri:: command]
795+ pub fn set_global_pull_autostash ( pull_autostash : String ) -> Result < OperationResult , String > {
796+ let value = validate_config_choice ( & pull_autostash, & [ "" , "true" , "false" ] , "pull.autostash" ) ?;
797+ set_optional_global_config (
798+ "pull.autostash" ,
799+ & value,
800+ "Cleared pull.autostash from global git config" ,
801+ )
802+ }
803+
804+ #[ tauri:: command]
805+ pub fn set_global_fetch_prune ( fetch_prune : String ) -> Result < OperationResult , String > {
806+ let value = validate_config_choice ( & fetch_prune, & [ "" , "true" , "false" ] , "fetch.prune" ) ?;
807+ set_optional_global_config (
808+ "fetch.prune" ,
809+ & value,
810+ "Cleared fetch.prune from global git config" ,
811+ )
812+ }
813+
814+ #[ tauri:: command]
815+ pub fn set_global_push_default ( push_default : String ) -> Result < OperationResult , String > {
816+ let value = validate_config_choice (
817+ & push_default,
818+ & [ "" , "nothing" , "current" , "upstream" , "simple" , "matching" ] ,
819+ "push.default" ,
820+ ) ?;
821+ set_optional_global_config (
822+ "push.default" ,
823+ & value,
824+ "Cleared push.default from global git config" ,
825+ )
826+ }
827+
828+ #[ tauri:: command]
829+ pub fn set_global_push_auto_setup_remote (
830+ push_auto_setup_remote : String ,
831+ ) -> Result < OperationResult , String > {
832+ let value = validate_config_choice (
833+ & push_auto_setup_remote,
834+ & [ "" , "true" , "false" ] ,
835+ "push.autoSetupRemote" ,
836+ ) ?;
837+ set_optional_global_config (
838+ "push.autoSetupRemote" ,
839+ & value,
840+ "Cleared push.autoSetupRemote from global git config" ,
841+ )
842+ }
843+
844+ #[ tauri:: command]
845+ pub fn set_global_core_editor ( core_editor : String ) -> Result < OperationResult , String > {
846+ set_optional_global_config (
847+ "core.editor" ,
848+ & core_editor,
849+ "Cleared core.editor from global git config" ,
850+ )
851+ }
852+
853+ #[ tauri:: command]
854+ pub fn set_global_core_autocrlf ( core_autocrlf : String ) -> Result < OperationResult , String > {
855+ let value = validate_config_choice (
856+ & core_autocrlf,
857+ & [ "" , "false" , "true" , "input" ] ,
858+ "core.autocrlf" ,
859+ ) ?;
860+ set_optional_global_config (
861+ "core.autocrlf" ,
862+ & value,
863+ "Cleared core.autocrlf from global git config" ,
864+ )
865+ }
866+
867+ #[ tauri:: command]
868+ pub fn set_global_credential_helper ( credential_helper : String ) -> Result < OperationResult , String > {
869+ set_optional_global_config (
870+ "credential.helper" ,
871+ & credential_helper,
872+ "Cleared credential.helper from global git config" ,
873+ )
874+ }
875+
698876#[ tauri:: command]
699877pub fn set_global_file_mode ( file_mode : bool ) -> Result < OperationResult , String > {
700878 let value = if file_mode { "true" } else { "false" } ;
0 commit comments