@@ -97,6 +97,7 @@ struct rebase_options {
97
97
int allow_rerere_autoupdate ;
98
98
int keep_empty ;
99
99
int autosquash ;
100
+ char * gpg_sign_opt ;
100
101
};
101
102
102
103
static int is_interactive (struct rebase_options * opts )
@@ -209,6 +210,15 @@ static int read_basic_state(struct rebase_options *opts)
209
210
} else
210
211
opts -> allow_rerere_autoupdate = -1 ;
211
212
213
+ if (file_exists (state_dir_path ("gpg_sign_opt" , opts ))) {
214
+ strbuf_reset (& buf );
215
+ if (read_one (state_dir_path ("gpg_sign_opt" , opts ),
216
+ & buf ))
217
+ return -1 ;
218
+ free (opts -> gpg_sign_opt );
219
+ opts -> gpg_sign_opt = xstrdup (buf .buf );
220
+ }
221
+
212
222
strbuf_release (& buf );
213
223
214
224
return 0 ;
@@ -297,6 +307,7 @@ static int run_specific_rebase(struct rebase_options *opts)
297
307
"--rerere-autoupdate" : "--no-rerere-autoupdate" );
298
308
add_var (& script_snippet , "keep_empty" , opts -> keep_empty ? "yes" : "" );
299
309
add_var (& script_snippet , "autosquash" , opts -> autosquash ? "t" : "" );
310
+ add_var (& script_snippet , "gpg_sign_opt" , opts -> gpg_sign_opt );
300
311
301
312
switch (opts -> type ) {
302
313
case REBASE_AM :
@@ -462,6 +473,13 @@ static int rebase_config(const char *var, const char *value, void *data)
462
473
return 0 ;
463
474
}
464
475
476
+ if (!strcmp (var , "commit.gpgsign" )) {
477
+ free (opts -> gpg_sign_opt );
478
+ opts -> gpg_sign_opt = git_config_bool (var , value ) ?
479
+ xstrdup ("-S" ) : NULL ;
480
+ return 0 ;
481
+ }
482
+
465
483
return git_default_config (var , value , data );
466
484
}
467
485
@@ -555,6 +573,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
555
573
int committer_date_is_author_date = 0 ;
556
574
int ignore_date = 0 ;
557
575
int ignore_whitespace = 0 ;
576
+ const char * gpg_sign = NULL ;
558
577
struct option builtin_rebase_options [] = {
559
578
OPT_STRING (0 , "onto" , & options .onto_name ,
560
579
N_ ("revision" ),
@@ -619,6 +638,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
619
638
OPT_BOOL (0 , "autosquash" , & options .autosquash ,
620
639
N_ ("move commits that begin with "
621
640
"squash!/fixup! under -i" )),
641
+ { OPTION_STRING , 'S' , "gpg-sign" , & gpg_sign , N_ ("key-id" ),
642
+ N_ ("GPG-sign commits" ),
643
+ PARSE_OPT_OPTARG , NULL , (intptr_t ) "" },
622
644
OPT_END (),
623
645
};
624
646
@@ -821,6 +843,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
821
843
if (options .keep_empty )
822
844
imply_interactive (& options , "--keep-empty" );
823
845
846
+ if (gpg_sign ) {
847
+ free (options .gpg_sign_opt );
848
+ options .gpg_sign_opt = xstrfmt ("-S%s" , gpg_sign );
849
+ }
850
+
824
851
switch (options .type ) {
825
852
case REBASE_MERGE :
826
853
case REBASE_INTERACTIVE :
@@ -1046,5 +1073,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1046
1073
cleanup :
1047
1074
strbuf_release (& revisions );
1048
1075
free (options .head_name );
1076
+ free (options .gpg_sign_opt );
1049
1077
return ret ;
1050
1078
}
0 commit comments