{"thread":{"id":"39718","subject":"[PATCH] commit: add commit.signoff config option","startedAt":"2015-06-25T07:32:38Z","lastAt":"2015-06-25T14:55:25Z","messageCount":3,"participants":["Caio Marcelo de Oliveira Filho","Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"264808","messageId":"1435217558-5866-1-git-send-email-cmarcelo@gmail.com","threadId":"39718","inReplyTo":null,"subject":"[PATCH] commit: add commit.signoff config option","fromName":"Caio Marcelo de Oliveira Filho","fromEmail":"cmarcelo@gmail.com","sentAt":"2015-06-25T07:32:38Z","receivedAt":"2015-06-25T07:32:38Z","isPatch":true,"sender":{"key":"cmarcelo@gmail.com","avatar":null},"body":"In projects that use Signed-off-by, it's convenient to include that line\nin the commit by default. The commit.signoff config option allows to add\nthat line in all commits automatically.\n\nDocument that this config option can be overriden by using\n--no-signoff.\n\nSigned-off-by: Caio Marcelo de Oliveira Filho <cmarcelo@gmail.com>\n---\n Documentation/config.txt     |  6 ++++++\n Documentation/git-commit.txt |  5 +++++\n builtin/commit.c             |  4 ++++\n t/t7500-commit.sh            | 22 ++++++++++++++++++++++\n 4 files changed, 37 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 3e37b93..e019f62 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1089,6 +1089,12 @@ commit.gpgSign::\n \tconvenient to use an agent to avoid typing your GPG passphrase\n \tseveral times.\n \n+commit.signoff::\n+\n+\tA boolean to enable/disable whether Signed-off-by line by the\n+\tcommitter should be added to all commits at the end of the\n+\tcommit log messages.  Defaults to false.\n+\n commit.status::\n \tA boolean to enable/disable inclusion of status information in the\n \tcommit message template when using an editor to prepare the commit\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 904dafa..7546c7a 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -156,6 +156,11 @@ OPTIONS\n \tAdd Signed-off-by line by the committer at the end of the commit\n \tlog message.\n \n+--no-signoff::\n+\tCountermand `commit.signoff` configuration, preventing a\n+\tSigned-off-by line to be added at the end of the commit log\n+\tmessage.\n+\n -n::\n --no-verify::\n \tThis option bypasses the pre-commit and commit-msg hooks.\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 254477f..5cfbe57 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1505,6 +1505,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)\n \t\tsign_commit = git_config_bool(k, v) ? \"\" : NULL;\n \t\treturn 0;\n \t}\n+\tif (!strcmp(k, \"commit.signoff\")) {\n+\t\tsignoff = git_config_bool(k, v);\n+\t\treturn 0;\n+\t}\n \n \tstatus = git_gpg_config(k, v, NULL);\n \tif (status)\ndiff --git a/t/t7500-commit.sh b/t/t7500-commit.sh\nindex 116885a..fcb39b4 100755\n--- a/t/t7500-commit.sh\n+++ b/t/t7500-commit.sh\n@@ -179,6 +179,28 @@ test_expect_success '--signoff' '\n \ttest_cmp expect output\n '\n \n+test_expect_success 'commit.signoff config option' '\n+\tgit config commit.signoff true &&\n+\techo \"yet another content *narf*\" >> foo &&\n+\techo \"zort\" | git commit -F - foo &&\n+\tgit cat-file commit HEAD | sed \"1,/^\\$/d\" > output &&\n+\tgit config --unset commit.signoff &&\n+\ttest_cmp expect output\n+'\n+\n+cat > expect <<EOF\n+no signed off by here\n+EOF\n+\n+test_expect_success '--no-signoff' '\n+\tgit config commit.signoff true &&\n+\techo \"yet another content *narf*\" >> foo &&\n+\techo \"no signed off by here\" | git commit --no-signoff -F - foo &&\n+\tgit cat-file commit HEAD | sed \"1,/^\\$/d\" > output &&\n+\tgit config --unset commit.signoff &&\n+\ttest_cmp expect output\n+'\n+\n test_expect_success 'commit message from file (1)' '\n \tmkdir subdir &&\n \techo \"Log in top directory\" >log &&\n-- \n2.4.4.489.gc2a2b54.dirty\n"},{"id":"264812","messageId":"CAP8UFD1kbu4uB1Xaf_jWdQUBzkSJ-Z3_o3NT0Wb6GNyRG=jSLw@mail.gmail.com","threadId":"39718","inReplyTo":"1435217558-5866-1-git-send-email-cmarcelo@gmail.com","subject":"Re: [PATCH] commit: add commit.signoff config option","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-06-25T08:43:02Z","receivedAt":"2015-06-25T08:43:02Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Thu, Jun 25, 2015 at 9:32 AM, Caio Marcelo de Oliveira Filho\n<cmarcelo@gmail.com> wrote:\n> In projects that use Signed-off-by, it's convenient to include that line\n> in the commit by default. The commit.signoff config option allows to add\n> that line in all commits automatically.\n\nYou can use a commit template.\n\nOr you can use the \"commit-msg\" hook. For example with commands like:\n\ngrep \"^Signed-off-by:\" \"$1\" ||\necho \"Signed-off-by: $(git config user.name) <$(git config user.email)>\" >>\"$1\"\n\nIf you have more complex needs, there is also \"git interpret-trailers\"\n(see the examples in the man page).\n"},{"id":"264851","messageId":"CADstYCZ6aDN=CNsX_fEnJmB1xF4L_M=j=G2RuKyfK5wxNkH41g@mail.gmail.com","threadId":"39718","inReplyTo":"CAP8UFD1kbu4uB1Xaf_jWdQUBzkSJ-Z3_o3NT0Wb6GNyRG=jSLw@mail.gmail.com","subject":"Re: [PATCH] commit: add commit.signoff config option","fromName":"Caio Marcelo de Oliveira Filho","fromEmail":"cmarcelo@gmail.com","sentAt":"2015-06-25T14:55:25Z","receivedAt":"2015-06-25T14:55:25Z","isPatch":true,"sender":{"key":"cmarcelo@gmail.com","avatar":null},"body":"On Thu, Jun 25, 2015 at 5:43 AM, Christian Couder\n<christian.couder@gmail.com> wrote:\n> You can use a commit template.\n>\n> Or you can use the \"commit-msg\" hook. For example with commands like:\n>\n> grep \"^Signed-off-by:\" \"$1\" ||\n> echo \"Signed-off-by: $(git config user.name) <$(git config user.email)>\" >>\"$1\"\n>\n> If you have more complex needs, there is also \"git interpret-trailers\"\n> (see the examples in the man page).\n\nThanks for the references. I was initially using a commit template to solve\nthe problem. But I've considered that since we already handle\n\"Signed-off-by\" somewhat specially (e.g. \"commit -s\"), and how common this\ncase is, it was worth adding a config option.\n\n\n-- \nCaio Marcelo de Oliveira Filho\n"}]}