@@ -15,7 +15,7 @@ use crate::core::formatting::Pluralize;
1515use crate :: core:: repo_ext:: RepoExt ;
1616use crate :: git:: {
1717 BranchType , CategorizedReferenceName , GitRunInfo , MaybeZeroOid , NonZeroOid , ReferenceName ,
18- Repo , ResolvedReferenceInfo ,
18+ Repo , ResolvedReferenceInfo , SignOption ,
1919} ;
2020use crate :: util:: { ExitCode , EyreExitOr } ;
2121
@@ -435,7 +435,8 @@ mod in_memory {
435435 use crate :: core:: rewrite:: move_branches;
436436 use crate :: core:: rewrite:: plan:: { OidOrLabel , RebaseCommand , RebasePlan } ;
437437 use crate :: git:: {
438- CherryPickFastError , CherryPickFastOptions , GitRunInfo , MaybeZeroOid , NonZeroOid , Repo ,
438+ self , CherryPickFastError , CherryPickFastOptions , GitRunInfo , MaybeZeroOid , NonZeroOid ,
439+ Repo ,
439440 } ;
440441 use crate :: util:: EyreExitOr ;
441442
@@ -498,6 +499,7 @@ mod in_memory {
498499 force_on_disk : _,
499500 resolve_merge_conflicts : _, // May be needed once we can resolve merge conflicts in memory.
500501 check_out_commit_options : _, // Caller is responsible for checking out to new HEAD.
502+ sign_option,
501503 } = options;
502504
503505 let mut current_oid = rebase_plan. first_dest_oid ;
@@ -535,6 +537,8 @@ mod in_memory {
535537 . count ( ) ;
536538 let ( effects, progress) = effects. start_operation ( OperationType :: RebaseCommits ) ;
537539
540+ let signer = git:: get_signer ( & repo, sign_option) ?;
541+
538542 for command in rebase_plan. commands . iter ( ) {
539543 match command {
540544 RebaseCommand :: CreateLabel { label_name } => {
@@ -633,7 +637,7 @@ mod in_memory {
633637 commit_message,
634638 & commit_tree,
635639 vec ! [ & current_commit] ,
636- None ,
640+ signer . as_deref ( ) ,
637641 )
638642 . wrap_err ( "Applying rebased commit" ) ?;
639643
@@ -753,7 +757,7 @@ mod in_memory {
753757 replacement_commit_message,
754758 & replacement_tree,
755759 parents. iter ( ) . collect ( ) ,
756- None ,
760+ signer . as_deref ( ) ,
757761 )
758762 . wrap_err ( "Applying rebased commit" ) ?;
759763
@@ -864,6 +868,7 @@ mod in_memory {
864868 force_on_disk : _,
865869 resolve_merge_conflicts : _,
866870 check_out_commit_options,
871+ sign_option : _,
867872 } = options;
868873
869874 // Note that if an OID has been mapped to multiple other OIDs, then the last
@@ -959,6 +964,7 @@ mod on_disk {
959964 force_on_disk : _,
960965 resolve_merge_conflicts : _,
961966 check_out_commit_options : _, // Checkout happens after rebase has concluded.
967+ sign_option,
962968 } = options;
963969
964970 let ( effects, _progress) = effects. start_operation ( OperationType :: InitializeRebase ) ;
@@ -1073,6 +1079,16 @@ mod on_disk {
10731079 )
10741080 } ) ?;
10751081
1082+ let gpg_sign_opt_file = rebase_state_dir. join ( "gpg_sign_opt" ) ;
1083+ if let Some ( sign_flag) = sign_option. as_rebase_flag ( repo) ? {
1084+ std:: fs:: write ( & gpg_sign_opt_file, sign_flag) . wrap_err_with ( || {
1085+ format ! (
1086+ "Writing `gpg_sign_opt` to: {:?}" ,
1087+ gpg_sign_opt_file. as_path( )
1088+ )
1089+ } ) ?;
1090+ }
1091+
10761092 let end_file_path = rebase_state_dir. join ( "end" ) ;
10771093 std:: fs:: write (
10781094 end_file_path. as_path ( ) ,
@@ -1132,6 +1148,7 @@ mod on_disk {
11321148 force_on_disk : _,
11331149 resolve_merge_conflicts : _,
11341150 check_out_commit_options : _, // Checkout happens after rebase has concluded.
1151+ sign_option : _,
11351152 } = options;
11361153
11371154 match write_rebase_state_to_disk ( effects, git_run_info, repo, rebase_plan, options) ? {
@@ -1176,6 +1193,9 @@ pub struct ExecuteRebasePlanOptions {
11761193
11771194 /// If `HEAD` was moved, the options for checking out the new `HEAD` commit.
11781195 pub check_out_commit_options : CheckOutCommitOptions ,
1196+
1197+ /// GPG-sign commits.
1198+ pub sign_option : SignOption ,
11791199}
11801200
11811201/// The result of executing a rebase plan.
@@ -1221,6 +1241,7 @@ pub fn execute_rebase_plan(
12211241 force_on_disk,
12221242 resolve_merge_conflicts,
12231243 check_out_commit_options : _,
1244+ sign_option : _,
12241245 } = options;
12251246
12261247 if !force_on_disk {
0 commit comments