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>
This commit is contained in:
Nicolas Vigier 2014-01-24 00:50:58 +00:00 коммит произвёл Junio C Hamano
Родитель bd3e186d81
Коммит 3253553e12
5 изменённых файлов: 26 добавлений и 2 удалений

Просмотреть файл

@ -8,7 +8,8 @@ git-cherry-pick - Apply the changes introduced by some existing commits
SYNOPSIS
--------
[verse]
'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>...
'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff]
[-S[<keyid>]] <commit>...
'git cherry-pick' --continue
'git cherry-pick' --quit
'git cherry-pick' --abort
@ -100,6 +101,10 @@ effect to your index in a row.
--signoff::
Add Signed-off-by line at the end of the commit message.
-S[<keyid>]::
--gpg-sign[=<keyid>]::
GPG-sign commits.
--ff::
If the current HEAD is the same as the parent of the
cherry-pick'ed commit, then a fast forward to this commit will

Просмотреть файл

@ -8,7 +8,7 @@ git-revert - Revert some existing commits
SYNOPSIS
--------
[verse]
'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] <commit>...
'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>...
'git revert' --continue
'git revert' --quit
'git revert' --abort
@ -80,6 +80,10 @@ more details.
This is useful when reverting more than one commits'
effect to your index in a row.
-S[<keyid>]::
--gpg-sign[=<keyid>]::
GPG-sign commits.
-s::
--signoff::
Add Signed-off-by line at the end of the commit message.

Просмотреть файл

@ -89,6 +89,8 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
OPT_STRING(0, "strategy", &opts->strategy, N_("strategy"), N_("merge strategy")),
OPT_CALLBACK('X', "strategy-option", &opts, N_("option"),
N_("option for merge strategy"), option_parse_x),
{ OPTION_STRING, 'S', "gpg-sign", &opts->gpg_sign, N_("key id"),
N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
OPT_END(),
OPT_END(),
OPT_END(),

Просмотреть файл

@ -392,11 +392,18 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
{
struct argv_array array;
int rc;
char *gpg_sign;
argv_array_init(&array);
argv_array_push(&array, "commit");
argv_array_push(&array, "-n");
if (opts->gpg_sign) {
gpg_sign = xmalloc(3 + strlen(opts->gpg_sign));
sprintf(gpg_sign, "-S%s", opts->gpg_sign);
argv_array_push(&array, gpg_sign);
free(gpg_sign);
}
if (opts->signoff)
argv_array_push(&array, "-s");
if (!opts->edit) {
@ -808,6 +815,8 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
opts->mainline = git_config_int(key, value);
else if (!strcmp(key, "options.strategy"))
git_config_string(&opts->strategy, key, value);
else if (!strcmp(key, "options.gpg-sign"))
git_config_string(&opts->gpg_sign, key, value);
else if (!strcmp(key, "options.strategy-option")) {
ALLOC_GROW(opts->xopts, opts->xopts_nr + 1, opts->xopts_alloc);
opts->xopts[opts->xopts_nr++] = xstrdup(value);
@ -981,6 +990,8 @@ static void save_opts(struct replay_opts *opts)
}
if (opts->strategy)
git_config_set_in_file(opts_file, "options.strategy", opts->strategy);
if (opts->gpg_sign)
git_config_set_in_file(opts_file, "options.gpg-sign", opts->gpg_sign);
if (opts->xopts) {
int i;
for (i = 0; i < opts->xopts_nr; i++)

Просмотреть файл

@ -37,6 +37,8 @@ struct replay_opts {
int mainline;
const char *gpg_sign;
/* Merge strategy */
const char *strategy;
const char **xopts;