diff options
author | Dan McGee <dpmcgee@gmail.com> | 2008-04-26 15:14:28 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-04-26 14:06:17 -0700 |
commit | cfd9c27708509457f572373bd8f4eb25dd4a6715 (patch) | |
tree | fa9cd1f17ec5b8085c82dfa463d02866d6d28032 /builtin-revert.c | |
parent | 36c79d2bf893b9957688a6c8c13cc0bf0589e596 (diff) | |
download | git-cfd9c27708509457f572373bd8f4eb25dd4a6715.tar.gz git-cfd9c27708509457f572373bd8f4eb25dd4a6715.tar.xz |
Allow cherry-pick (and revert) to add signoff line
I often find myself pulling patches off of other peoples trees using
cherry-pick, and following it with an immediate 'git commit --amend -s'
command. Eliminate the need for a double commit by allowing signoff on a
cherry-pick or revert.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-revert.c')
-rw-r--r-- | builtin-revert.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/builtin-revert.c b/builtin-revert.c index 607a2f033..2b57525d7 100644 --- a/builtin-revert.c +++ b/builtin-revert.c @@ -33,7 +33,7 @@ static const char * const cherry_pick_usage[] = { NULL }; -static int edit, no_replay, no_commit, mainline; +static int edit, no_replay, no_commit, mainline, signoff; static enum { REVERT, CHERRY_PICK } action; static struct commit *commit; @@ -53,6 +53,7 @@ static void parse_args(int argc, const char **argv) OPT_BOOLEAN('e', "edit", &edit, "edit the commit message"), OPT_BOOLEAN('x', NULL, &no_replay, "append commit name when cherry-picking"), OPT_BOOLEAN('r', NULL, &noop, "no-op (backward compatibility)"), + OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"), OPT_INTEGER('m', "mainline", &mainline, "parent number"), OPT_END(), }; @@ -404,10 +405,19 @@ static int revert_or_cherry_pick(int argc, const char **argv) */ if (!no_commit) { - if (edit) - return execl_git_cmd("commit", "-n", NULL); - else - return execl_git_cmd("commit", "-n", "-F", defmsg, NULL); + /* 6 is max possible length of our args array including NULL */ + const char *args[6]; + int i = 0; + args[i++] = "commit"; + args[i++] = "-n"; + if (signoff) + args[i++] = "-s"; + if (!edit) { + args[i++] = "-F"; + args[i++] = defmsg; + } + args[i] = NULL; + return execv_git_cmd(args); } free(reencoded_message); |