{"thread":{"id":"13187","subject":"[PATCH] Allow cherry-pick (and revert) to add signoff line","startedAt":"2008-04-20T18:03:05Z","lastAt":"2008-04-27T00:43:20Z","messageCount":7,"participants":["Dan McGee","Björn Steinbrink","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"74821","messageId":"1208714585-4053-1-git-send-email-dpmcgee@gmail.com","threadId":"13187","inReplyTo":null,"subject":"[PATCH] Allow cherry-pick (and revert) to add signoff line","fromName":"Dan McGee","fromEmail":"dpmcgee@gmail.com","sentAt":"2008-04-20T18:03:05Z","receivedAt":"2008-04-20T18:03:05Z","isPatch":true,"sender":{"key":"dpmcgee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/265817?v=4"},"body":"I often find myself pulling patches off of other peoples trees using\ncherry-pick, and following it with an immediate 'git commit --amend -s'\ncommand. Eliminate the need for a double commit by allowing signoff on a\ncherry-pick or revert.\n\nSigned-off-by: Dan McGee <dpmcgee@gmail.com>\n---\n\nThis is something I have done in my workflow for a long time, and it seems\nlike a weird omission to me. Signoffs can be done on git-am without having\na second commit, and I often have a workflow where I am picking patches from\nother users' topic branches and have reviewed the patch and would like to\nsignoff when I pull it into my tree.\n\nI'm not particularly happy about the 4 case if statement at the end, so I'd\nbe happy to clean that up if anyone has suggestions.\n\n builtin-revert.c |   11 ++++++++---\n 1 files changed, 8 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-revert.c b/builtin-revert.c\nindex 607a2f0..433d0dd 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: header\"),\n \t\tOPT_INTEGER('m', \"mainline\", &mainline, \"parent number\"),\n \t\tOPT_END(),\n \t};\n@@ -404,10 +405,14 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \t */\n \n \tif (!no_commit) {\n-\t\tif (edit)\n+\t\tif (edit && !signoff)\n \t\t\treturn execl_git_cmd(\"commit\", \"-n\", NULL);\n-\t\telse\n+\t\telse if (edit)\n+\t\t\treturn execl_git_cmd(\"commit\", \"-n\", \"-s\", NULL);\n+\t\telse if (!signoff)\n \t\t\treturn execl_git_cmd(\"commit\", \"-n\", \"-F\", defmsg, NULL);\n+\t\telse\n+\t\t\treturn execl_git_cmd(\"commit\", \"-n\", \"-s\", \"-F\", defmsg, NULL);\n \t}\n \tfree(reencoded_message);\n \n-- \n1.5.5\n"},{"id":"74822","messageId":"20080420182857.GA15277@atjola.homenet","threadId":"13187","inReplyTo":"1208714585-4053-1-git-send-email-dpmcgee@gmail.com","subject":"Re: [PATCH] Allow cherry-pick (and revert) to add signoff line","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-04-20T18:28:57Z","receivedAt":"2008-04-20T18:28:57Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.04.20 13:03:05 -0500, Dan McGee wrote:\n> I often find myself pulling patches off of other peoples trees using\n> cherry-pick, and following it with an immediate 'git commit --amend -s'\n> command. Eliminate the need for a double commit by allowing signoff on a\n> cherry-pick or revert.\n> \n> Signed-off-by: Dan McGee <dpmcgee@gmail.com>\n> ---\n> \n> This is something I have done in my workflow for a long time, and it seems\n> like a weird omission to me. Signoffs can be done on git-am without having\n> a second commit, and I often have a workflow where I am picking patches from\n> other users' topic branches and have reviewed the patch and would like to\n> signoff when I pull it into my tree.\n> \n> I'm not particularly happy about the 4 case if statement at the end, so I'd\n> be happy to clean that up if anyone has suggestions.\n> \n>  builtin-revert.c |   11 ++++++++---\n>  1 files changed, 8 insertions(+), 3 deletions(-)\n> \n> diff --git a/builtin-revert.c b/builtin-revert.c\n> index 607a2f0..433d0dd 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: header\"),\n>  \t\tOPT_INTEGER('m', \"mainline\", &mainline, \"parent number\"),\n>  \t\tOPT_END(),\n>  \t};\n> @@ -404,10 +405,14 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n>  \t */\n>  \n>  \tif (!no_commit) {\n> -\t\tif (edit)\n> +\t\tif (edit && !signoff)\n>  \t\t\treturn execl_git_cmd(\"commit\", \"-n\", NULL);\n> -\t\telse\n> +\t\telse if (edit)\n> +\t\t\treturn execl_git_cmd(\"commit\", \"-n\", \"-s\", NULL);\n> +\t\telse if (!signoff)\n>  \t\t\treturn execl_git_cmd(\"commit\", \"-n\", \"-F\", defmsg, NULL);\n> +\t\telse\n> +\t\t\treturn execl_git_cmd(\"commit\", \"-n\", \"-s\", \"-F\", defmsg, NULL);\n\nmaybe like this?\n\n\tif (!no_commit) {\n\t\tchar **argv[6] = { \"commit\", \"-n\" };\n\t\tint argc = 2;\n\t\tif (signoff)\n\t\t\targv[argc++] = \"-s\";\n\t\tif (!edit) {\n\t\t\targv[argc++] = \"-F\";\n\t\t\targv[argc++] = defmsg;\n\t\t}\n\t\targv[argc] = NULL;\n\t\texecv_git_command(argv);\n\t}\n\nIt duplicates what execl_git_cmd does, but other places already work\nsimilar (eg. cmd_describe, when --contains is given), and IMHO it's\nnicer than the if-else chain.\n\nBjörn\n"},{"id":"75031","messageId":"7vabjlupjc.fsf@gitster.siamese.dyndns.org","threadId":"13187","inReplyTo":"1208714585-4053-1-git-send-email-dpmcgee@gmail.com","subject":"Re: [PATCH] Allow cherry-pick (and revert) to add signoff line","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-04-23T05:08:07Z","receivedAt":"2008-04-23T05:08:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dan McGee <dpmcgee@gmail.com> writes:\n\n> I often find myself pulling patches off of other peoples trees using\n> cherry-pick, and following it with an immediate 'git commit --amend -s'\n> command. Eliminate the need for a double commit by allowing signoff on a\n> cherry-pick or revert.\n>\n> Signed-off-by: Dan McGee <dpmcgee@gmail.com>\n> ---\n>\n> This is something I have done in my workflow for a long time, and it seems\n> like a weird omission to me. Signoffs can be done on git-am without having\n> a second commit, and I often have a workflow where I am picking patches from\n> other users' topic branches and have reviewed the patch and would like to\n> signoff when I pull it into my tree.\n\nYeah, when your workflow is heavily rely on cherry-picking, I can see how\nthis would be handy.\n\nI see there was some improvement suggestion suggested on the list, so I\nwill wait until the dust settles and I see an appliable final submission.\n\nThanks.\n"},{"id":"75224","messageId":"1209221215-13476-1-git-send-email-dpmcgee@gmail.com","threadId":"13187","inReplyTo":"7vabjlupjc.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] Allow cherry-pick (and revert) to add signoff line","fromName":"Dan McGee","fromEmail":"dpmcgee@gmail.com","sentAt":"2008-04-26T14:46:55Z","receivedAt":"2008-04-26T14:46:55Z","isPatch":true,"sender":{"key":"dpmcgee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/265817?v=4"},"body":"I often find myself pulling patches off of other peoples trees using\ncherry-pick, and following it with an immediate 'git commit --amend -s'\ncommand. Eliminate the need for a double commit by allowing signoff on a\ncherry-pick or revert.\n\nSigned-off-by: Dan McGee <dpmcgee@gmail.com>\n---\n\nResubmit using execv_git_cmd() directly. This reduces some code duplication\nand allows for any other commit options to be propagated forth in the future.\n\n builtin-revert.c |   20 +++++++++++++++-----\n 1 files changed, 15 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin-revert.c b/builtin-revert.c\nindex 607a2f0..3f08cfe 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: header\"),\n \t\tOPT_INTEGER('m', \"mainline\", &mainline, \"parent number\"),\n \t\tOPT_END(),\n \t};\n@@ -404,10 +405,19 @@ 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\t/* 6 is max possible length of our args array including NULL */\n+\t\tconst char *args[6];\n+\t\tint i = 0;\n+\t\targs[i++] = \"commit\";\n+\t\targs[i++] = \"-n\";\n+\t\tif (signoff)\n+\t\t\targs[i++] = \"-s\";\n+\t\tif (!edit) {\n+\t\t\targs[i++] = \"-F\";\n+\t\t\targs[i++] = defmsg;\n+\t\t}\n+\t\targs[i] = NULL;\n+\t\treturn execv_git_cmd(args);\n \t}\n \tfree(reencoded_message);\n \n-- \n1.5.5.1\n"},{"id":"75235","messageId":"1209240868-30815-1-git-send-email-dpmcgee@gmail.com","threadId":"13187","inReplyTo":"1209221215-13476-1-git-send-email-dpmcgee@gmail.com","subject":"[PATCH resubmit] Allow cherry-pick (and revert) to add signoff line","fromName":"Dan McGee","fromEmail":"dpmcgee@gmail.com","sentAt":"2008-04-26T20:14:28Z","receivedAt":"2008-04-26T20:14:28Z","isPatch":true,"sender":{"key":"dpmcgee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/265817?v=4"},"body":"I often find myself pulling patches off of other peoples trees using\ncherry-pick, and following it with an immediate 'git commit --amend -s'\ncommand. Eliminate the need for a double commit by allowing signoff on a\ncherry-pick or revert.\n\nSigned-off-by: Dan McGee <dpmcgee@gmail.com>\n---\n\nDocumentation is a good thing too, so I've adjusted the patch to include it.\n\n Documentation/git-cherry-pick.txt |    5 ++++-\n Documentation/git-revert.txt      |    5 ++++-\n builtin-revert.c                  |   20 +++++++++++++++-----\n 3 files changed, 23 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt\nindex f0beb41..ca048f4 100644\n--- a/Documentation/git-cherry-pick.txt\n+++ b/Documentation/git-cherry-pick.txt\n@@ -7,7 +7,7 @@ git-cherry-pick - Apply the change introduced by an existing commit\n \n SYNOPSIS\n --------\n-'git-cherry-pick' [--edit] [-n] [-m parent-number] [-x] <commit>\n+'git-cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] <commit>\n \n DESCRIPTION\n -----------\n@@ -64,6 +64,9 @@ OPTIONS\n This is useful when cherry-picking more than one commits'\n effect to your working tree in a row.\n \n+-s|--signoff::\n+\tAdd Signed-off-by line at the end of the commit message.\n+\n \n Author\n ------\ndiff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt\nindex 93e20f7..13ceabb 100644\n--- a/Documentation/git-revert.txt\n+++ b/Documentation/git-revert.txt\n@@ -7,7 +7,7 @@ git-revert - Revert an existing commit\n \n SYNOPSIS\n --------\n-'git-revert' [--edit | --no-edit] [-n] [-m parent-number] <commit>\n+'git-revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>\n \n DESCRIPTION\n -----------\n@@ -51,6 +51,9 @@ OPTIONS\n This is useful when reverting more than one commits'\n effect to your working tree in a row.\n \n+-s|--signoff::\n+\tAdd Signed-off-by line at the end of the commit message.\n+\n \n Author\n ------\ndiff --git a/builtin-revert.c b/builtin-revert.c\nindex 607a2f0..3f08cfe 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: header\"),\n \t\tOPT_INTEGER('m', \"mainline\", &mainline, \"parent number\"),\n \t\tOPT_END(),\n \t};\n@@ -404,10 +405,19 @@ 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\t/* 6 is max possible length of our args array including NULL */\n+\t\tconst char *args[6];\n+\t\tint i = 0;\n+\t\targs[i++] = \"commit\";\n+\t\targs[i++] = \"-n\";\n+\t\tif (signoff)\n+\t\t\targs[i++] = \"-s\";\n+\t\tif (!edit) {\n+\t\t\targs[i++] = \"-F\";\n+\t\t\targs[i++] = defmsg;\n+\t\t}\n+\t\targs[i] = NULL;\n+\t\treturn execv_git_cmd(args);\n \t}\n \tfree(reencoded_message);\n \n-- \n1.5.5.1\n"},{"id":"75238","messageId":"7vbq3wmije.fsf@gitster.siamese.dyndns.org","threadId":"13187","inReplyTo":"1209240868-30815-1-git-send-email-dpmcgee@gmail.com","subject":"Re: [PATCH resubmit] Allow cherry-pick (and revert) to add signoff line","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-04-26T21:07:49Z","receivedAt":"2008-04-26T21:07:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dan McGee <dpmcgee@gmail.com> writes:\n\n> +-s|--signoff::\n> +\tAdd Signed-off-by line at the end of the commit message.\n> +\n\nGood.\n\n> +\t\tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by: header\"),\n\nNot so good ;-)\n\nWill apply with an obvious \"s/by: header/by:/\" and merge to 'next'.\n\nThanks.\n"},{"id":"75247","messageId":"1209257000-19292-1-git-send-email-dpmcgee@gmail.com","threadId":"13187","inReplyTo":"7vbq3wmije.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] Remove 'header' from --signoff option description","fromName":"Dan McGee","fromEmail":"dpmcgee@gmail.com","sentAt":"2008-04-27T00:43:20Z","receivedAt":"2008-04-27T00:43:20Z","isPatch":true,"sender":{"key":"dpmcgee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/265817?v=4"},"body":"Signed-off-by: Dan McGee <dpmcgee@gmail.com>\n---\n builtin-commit.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex b41d4a3..256181a 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -90,7 +90,7 @@ static struct option builtin_commit_options[] = {\n \tOPT_CALLBACK('m', \"message\", &message, \"MESSAGE\", \"specify commit message\", opt_parse_m),\n \tOPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit \"),\n \tOPT_STRING('C', \"reuse-message\", &use_message, \"COMMIT\", \"reuse message from specified commit\"),\n-\tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by: header\"),\n+\tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n \tOPT_STRING('t', \"template\", &template_file, \"FILE\", \"use specified template file\"),\n \tOPT_BOOLEAN('e', \"edit\", &edit_flag, \"force edit of commit\"),\n \n-- \n1.5.5.1\n"}]}