Skip to content

Commit 3253553

Browse files
boklmgitster
authored andcommitted
cherry-pick, revert: add the --gpg-sign option
Signed-off-by: Nicolas Vigier <[email protected]> Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bd3e186 commit 3253553

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

Documentation/git-cherry-pick.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ git-cherry-pick - Apply the changes introduced by some existing commits
88
SYNOPSIS
99
--------
1010
[verse]
11-
'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>...
11+
'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff]
12+
[-S[<keyid>]] <commit>...
1213
'git cherry-pick' --continue
1314
'git cherry-pick' --quit
1415
'git cherry-pick' --abort
@@ -100,6 +101,10 @@ effect to your index in a row.
100101
--signoff::
101102
Add Signed-off-by line at the end of the commit message.
102103

104+
-S[<keyid>]::
105+
--gpg-sign[=<keyid>]::
106+
GPG-sign commits.
107+
103108
--ff::
104109
If the current HEAD is the same as the parent of the
105110
cherry-pick'ed commit, then a fast forward to this commit will

Documentation/git-revert.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-revert - Revert some existing commits
88
SYNOPSIS
99
--------
1010
[verse]
11-
'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] <commit>...
11+
'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>...
1212
'git revert' --continue
1313
'git revert' --quit
1414
'git revert' --abort
@@ -80,6 +80,10 @@ more details.
8080
This is useful when reverting more than one commits'
8181
effect to your index in a row.
8282

83+
-S[<keyid>]::
84+
--gpg-sign[=<keyid>]::
85+
GPG-sign commits.
86+
8387
-s::
8488
--signoff::
8589
Add Signed-off-by line at the end of the commit message.

builtin/revert.c

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
8989
OPT_STRING(0, "strategy", &opts->strategy, N_("strategy"), N_("merge strategy")),
9090
OPT_CALLBACK('X', "strategy-option", &opts, N_("option"),
9191
N_("option for merge strategy"), option_parse_x),
92+
{ OPTION_STRING, 'S', "gpg-sign", &opts->gpg_sign, N_("key id"),
93+
N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
9294
OPT_END(),
9395
OPT_END(),
9496
OPT_END(),

sequencer.c

+11
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,18 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
392392
{
393393
struct argv_array array;
394394
int rc;
395+
char *gpg_sign;
395396

396397
argv_array_init(&array);
397398
argv_array_push(&array, "commit");
398399
argv_array_push(&array, "-n");
399400

401+
if (opts->gpg_sign) {
402+
gpg_sign = xmalloc(3 + strlen(opts->gpg_sign));
403+
sprintf(gpg_sign, "-S%s", opts->gpg_sign);
404+
argv_array_push(&array, gpg_sign);
405+
free(gpg_sign);
406+
}
400407
if (opts->signoff)
401408
argv_array_push(&array, "-s");
402409
if (!opts->edit) {
@@ -808,6 +815,8 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
808815
opts->mainline = git_config_int(key, value);
809816
else if (!strcmp(key, "options.strategy"))
810817
git_config_string(&opts->strategy, key, value);
818+
else if (!strcmp(key, "options.gpg-sign"))
819+
git_config_string(&opts->gpg_sign, key, value);
811820
else if (!strcmp(key, "options.strategy-option")) {
812821
ALLOC_GROW(opts->xopts, opts->xopts_nr + 1, opts->xopts_alloc);
813822
opts->xopts[opts->xopts_nr++] = xstrdup(value);
@@ -981,6 +990,8 @@ static void save_opts(struct replay_opts *opts)
981990
}
982991
if (opts->strategy)
983992
git_config_set_in_file(opts_file, "options.strategy", opts->strategy);
993+
if (opts->gpg_sign)
994+
git_config_set_in_file(opts_file, "options.gpg-sign", opts->gpg_sign);
984995
if (opts->xopts) {
985996
int i;
986997
for (i = 0; i < opts->xopts_nr; i++)

sequencer.h

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ struct replay_opts {
3737

3838
int mainline;
3939

40+
const char *gpg_sign;
41+
4042
/* Merge strategy */
4143
const char *strategy;
4244
const char **xopts;

0 commit comments

Comments
 (0)