{"thread":{"id":"13379","subject":"[PATCH] Add a --signoff option to cherry-pick/revert.","startedAt":"2008-05-05T00:25:09Z","lastAt":"2008-05-05T00:25:09Z","messageCount":1,"participants":["Florian Ragwitz"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"76057","messageId":"1209947109-13910-1-git-send-email-rafl@debian.org","threadId":"13379","inReplyTo":null,"subject":"[PATCH] Add a --signoff option to cherry-pick/revert.","fromName":"Florian Ragwitz","fromEmail":"rafl@debian.org","sentAt":"2008-05-05T00:25:09Z","receivedAt":"2008-05-05T00:25:09Z","isPatch":true,"sender":{"key":"rafl@debian.org","avatar":"https://gravatar.com/avatar/87c13cf03f1d0ddb4777379622dc2e0a5224bc0321ce9622cfb4daad92e268ee?d=mp&s=160"},"body":"Also modify documentation and tests to reflect this change.\n\nSigned-off-by: Florian Ragwitz <rafl@debian.org>\n---\n Documentation/git-cherry-pick.txt |    3 +++\n Documentation/git-revert.txt      |    3 +++\n builtin-revert.c                  |   25 ++++++++++++++++++++-----\n t/t3501-revert-cherry-pick.sh     |   19 +++++++++++++++++++\n 4 files changed, 45 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt\nindex f0beb41..ec8bd50 100644\n--- a/Documentation/git-cherry-pick.txt\n+++ b/Documentation/git-cherry-pick.txt\n@@ -39,6 +39,9 @@ OPTIONS\n \tdevelopment branch), adding this information can be\n \tuseful.\n \n+-s|--signoff::\n+\tAdd Signed-off-by line at the end of the commit message.\n+\n -r::\n \tIt used to be that the command defaulted to do `-x`\n \tdescribed above, and `-r` was to disable it.  Now the\ndiff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt\nindex 93e20f7..a35a376 100644\n--- a/Documentation/git-revert.txt\n+++ b/Documentation/git-revert.txt\n@@ -27,6 +27,9 @@ OPTIONS\n \tmessage prior to committing the revert. This is the default if\n \tyou run the command from a terminal.\n \n+-s|--signoff::\n+\tAdd Signed-off-by line at the end of the commit message.\n+\n -m parent-number|--mainline parent-number::\n \tUsually you cannot revert a merge because you do not know which\n \tside of the merge should be considered the mainline.  This\ndiff --git a/builtin-revert.c b/builtin-revert.c\nindex 607a2f0..ccf591c 100644\n--- a/builtin-revert.c\n+++ b/builtin-revert.c\n@@ -33,7 +33,7 @@ static const char * const cherry_pick_usage[] = {\n \tNULL\n };\n \n-static int edit, no_replay, no_commit, mainline;\n+static int edit, no_replay, no_commit, mainline, signoff;\n static enum { REVERT, CHERRY_PICK } action;\n static struct commit *commit;\n \n@@ -53,6 +53,7 @@ static void parse_args(int argc, const char **argv)\n \t\tOPT_BOOLEAN('e', \"edit\", &edit, \"edit the commit message\"),\n \t\tOPT_BOOLEAN('x', NULL, &no_replay, \"append commit name when cherry-picking\"),\n \t\tOPT_BOOLEAN('r', NULL, &noop, \"no-op (backward compatibility)\"),\n+\t\tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n \t\tOPT_INTEGER('m', \"mainline\", &mainline, \"parent number\"),\n \t\tOPT_END(),\n \t};\n@@ -404,10 +405,24 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \t */\n \n \tif (!no_commit) {\n-\t\tif (edit)\n-\t\t\treturn execl_git_cmd(\"commit\", \"-n\", NULL);\n-\t\telse\n-\t\t\treturn execl_git_cmd(\"commit\", \"-n\", \"-F\", defmsg, NULL);\n+\t\tconst char *args[6];\n+\t\tint i = 0;\n+\n+\t\targs[i++] = \"commit\";\n+\t\targs[i++] = \"-n\";\n+\n+\t\tif (!edit) {\n+\t\t\targs[i++] = \"-F\";\n+\t\t\targs[i++] = defmsg;\n+\t\t}\n+\n+\t\tif (signoff) {\n+\t\t\targs[i++] = \"-s\";\n+\t\t}\n+\n+\t\targs[i] = NULL;\n+\n+\t\treturn execv_git_cmd(args);\n \t}\n \tfree(reencoded_message);\n \ndiff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh\nindex 6da2128..2f74f74 100755\n--- a/t/t3501-revert-cherry-pick.sh\n+++ b/t/t3501-revert-cherry-pick.sh\n@@ -50,6 +50,25 @@ test_expect_success 'cherry-pick after renaming branch' '\n \n '\n \n+test_expect_success 'cherry-pick signoff' '\n+\n+\tgit checkout rename2 &&\n+\tgit cherry-pick -s added &&\n+\ttest -f opos &&\n+\tgit cat-file commit HEAD | sed \"1,/^$/d\" > output &&\n+\tgrep Signed-off-by output\n+'\n+\n+test_expect_success 'revert signoff' '\n+\n+\tgit checkout rename1 &&\n+\tgit revert -s added &&\n+\ttest -f spoo &&\n+\tgit cat-file commit HEAD | sed \"1,/^$/d\" > output &&\n+\tgrep Signed-off-by output\n+\n+'\n+\n test_expect_success 'revert after renaming branch' '\n \n \tgit checkout rename1 &&\n-- \n1.5.5.1\n"}]}