cherry-pick, revert: add the --gpg-sign option

Signed-off-by: Nicolas Vigier <boklm@mars-attacks.org> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nicolas Vigier committed Jan 24, 2014 at 00:50 UTC 3253553e12d40da3bca818528f49a63c95f43aa3
5 files changed +26 -2
Documentation/git-cherry-pick.txt
+6 -1
@@ -8,7 +8,8 @@ git-cherry-pick - Apply the changes introduced by some existing commits
8 SYNOPSIS
9 --------
10 [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>...
13 'git cherry-pick' --continue
14 'git cherry-pick' --quit
15 'git cherry-pick' --abort
@@ -100,6 +101,10 @@ effect to your index in a row.
101 --signoff::
102 Add Signed-off-by line at the end of the commit message.
103
104 +-S[<keyid>]::
105 +--gpg-sign[=<keyid>]::
106 + GPG-sign commits.
107 +
108 --ff::
109 If the current HEAD is the same as the parent of the
110 cherry-pick'ed commit, then a fast forward to this commit will
Documentation/git-revert.txt
+5 -1
@@ -8,7 +8,7 @@ git-revert - Revert some existing commits
8 SYNOPSIS
9 --------
10 [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>...
12 'git revert' --continue
13 'git revert' --quit
14 'git revert' --abort
@@ -80,6 +80,10 @@ more details.
80 This is useful when reverting more than one commits'
81 effect to your index in a row.
82
83 +-S[<keyid>]::
84 +--gpg-sign[=<keyid>]::
85 + GPG-sign commits.
86 +
87 -s::
88 --signoff::
89 Add Signed-off-by line at the end of the commit message.
builtin/revert.c
+2
@@ -89,6 +89,8 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
89 OPT_STRING(0, "strategy", &opts->strategy, N_("strategy"), N_("merge strategy")),
90 OPT_CALLBACK('X', "strategy-option", &opts, N_("option"),
91 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) "" },
94 OPT_END(),
95 OPT_END(),
96 OPT_END(),
sequencer.c
+11
@@ -392,11 +392,18 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
392 {
393 struct argv_array array;
394 int rc;
395 + char *gpg_sign;
396
397 argv_array_init(&array);
398 argv_array_push(&array, "commit");
399 argv_array_push(&array, "-n");
400
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 + }
407 if (opts->signoff)
408 argv_array_push(&array, "-s");
409 if (!opts->edit) {
@@ -808,6 +815,8 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
815 opts->mainline = git_config_int(key, value);
816 else if (!strcmp(key, "options.strategy"))
817 git_config_string(&opts->strategy, key, value);
818 + else if (!strcmp(key, "options.gpg-sign"))
819 + git_config_string(&opts->gpg_sign, key, value);
820 else if (!strcmp(key, "options.strategy-option")) {
821 ALLOC_GROW(opts->xopts, opts->xopts_nr + 1, opts->xopts_alloc);
822 opts->xopts[opts->xopts_nr++] = xstrdup(value);
@@ -981,6 +990,8 @@ static void save_opts(struct replay_opts *opts)
990 }
991 if (opts->strategy)
992 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);
995 if (opts->xopts) {
996 int i;
997 for (i = 0; i < opts->xopts_nr; i++)
sequencer.h
+2
@@ -37,6 +37,8 @@ struct replay_opts {
37
38 int mainline;
39
40 + const char *gpg_sign;
41 +
42 /* Merge strategy */
43 const char *strategy;
44 const char **xopts;