{"thread":{"id":"42203","subject":"[PATCH] commit-tree: do not pay attention to commit.gpgsign","startedAt":"2016-05-02T21:59:49Z","lastAt":"2016-05-03T04:20:40Z","messageCount":2,"participants":["Junio C Hamano","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"285215","messageId":"xmqqk2jcqfxm.fsf@gitster.mtv.corp.google.com","threadId":"42203","inReplyTo":null,"subject":"[PATCH] commit-tree: do not pay attention to commit.gpgsign","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-02T21:59:49Z","receivedAt":"2016-05-02T21:59:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"ba3c69a9 (commit: teach --gpg-sign option, 2011-10-05) introduced a\n\"signed commit\" by teaching --[no-gpg-sign option and commit.gpgsign\nconfiguration variable to various commands that create commits.\n\nTeaching these to \"git commit\" and \"git merge\", both of which are\nend-user facing Porcelain commands, was perfectly fine.  Allowing\nthe plumbing \"git commit-tree\" to suddenly change the behaviour to\nsurprise the scripts by paying attention to commit.gpgsign was not.\n\nAmong the in-tree scripts, filter-branch, quiltimport, rebase and\nstash are the commands that run \"commit-tree\".  If any of these\nwants to allow users to always sign every single commit, they should\noffer their own configuration (e.g. \"filterBranch..gpgsign\") with an\noption to disable (e.g. \"git filter-branch --no-gpgsign\").\n\nIgnoring commit.gpgsign option _obviously_ breaks the backward\ncompatibility, and I seriously doubt anybody sane is depending on\nthis misfeature that commit-tree blindly follows commit.gpgsign in\nany third-party script that calls it, but following the \"be careful\nwhen removing (mis)features\" tradition, let's give these scripts an\nescape hatch.  Passing the new --use-commit-gpgsign-config option to\nmakes it pay attention to the commit.gpgsign configuration again.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n builtin/commit-tree.c | 15 ++++++++++++---\n 1 file changed, 12 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex 3feeffe..b023a6b 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -10,9 +10,10 @@\n #include \"utf8.h\"\n #include \"gpg-interface.h\"\n \n-static const char commit_tree_usage[] = \"git commit-tree [(-p <sha1>)...] [-S[<keyid>]] [-m <message>] [-F <file>] <sha1>\";\n+static const char commit_tree_usage[] = \"git commit-tree [(-p <sha1>)...] [-S[<keyid>]] [--use-commit-gpgsign-config] [-m <message>] [-F <file>] <sha1>\";\n \n static const char *sign_commit;\n+static const char *config_sign_commit;\n \n static void new_parent(struct commit *parent, struct commit_list **parents_p)\n {\n@@ -34,7 +35,7 @@ static int commit_tree_config(const char *var, const char *value, void *cb)\n \tif (status)\n \t\treturn status;\n \tif (!strcmp(var, \"commit.gpgsign\")) {\n-\t\tsign_commit = git_config_bool(var, value) ? \"\" : NULL;\n+\t\tconfig_sign_commit = git_config_bool(var, value) ? \"\" : NULL;\n \t\treturn 0;\n \t}\n \treturn git_default_config(var, value, cb);\n@@ -42,7 +43,7 @@ static int commit_tree_config(const char *var, const char *value, void *cb)\n \n int cmd_commit_tree(int argc, const char **argv, const char *prefix)\n {\n-\tint i, got_tree = 0;\n+\tint i, got_tree = 0, use_commit_gpgsign_config = 0;\n \tstruct commit_list *parents = NULL;\n \tunsigned char tree_sha1[20];\n \tunsigned char commit_sha1[20];\n@@ -84,6 +85,11 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)\n \t\t\tcontinue;\n \t\t}\n \n+\t\tif (!strcmp(arg, \"--use-commit-gpgsign-config\")) {\n+\t\t\tuse_commit_gpgsign_config = 1;\n+\t\t\tcontinue;\n+\t\t}\n+\n \t\tif (!strcmp(arg, \"-F\")) {\n \t\t\tint fd;\n \n@@ -121,6 +127,9 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)\n \t\t\tdie_errno(\"git commit-tree: failed to read\");\n \t}\n \n+\tif (!sign_commit && use_commit_gpgsign_config)\n+\t\tsign_commit = config_sign_commit;\n+\n \tif (commit_tree(buffer.buf, buffer.len, tree_sha1, parents,\n \t\t\tcommit_sha1, NULL, sign_commit)) {\n \t\tstrbuf_release(&buffer);\n"},{"id":"285242","messageId":"CAPig+cRHxtOxR09LR6jEDAk7kT3oJMzwLe=iyKqxcGhviVaMNQ@mail.gmail.com","threadId":"42203","inReplyTo":"xmqqk2jcqfxm.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] commit-tree: do not pay attention to commit.gpgsign","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-03T04:20:40Z","receivedAt":"2016-05-03T04:20:40Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, May 2, 2016 at 5:59 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> ba3c69a9 (commit: teach --gpg-sign option, 2011-10-05) introduced a\n> \"signed commit\" by teaching --[no-gpg-sign option and commit.gpgsign\n\ns/\\[no/[no]/\n\n(ditto in the \"simpler\" patch)\n\n> configuration variable to various commands that create commits.\n>\n> Teaching these to \"git commit\" and \"git merge\", both of which are\n> end-user facing Porcelain commands, was perfectly fine.  Allowing\n> the plumbing \"git commit-tree\" to suddenly change the behaviour to\n> surprise the scripts by paying attention to commit.gpgsign was not.\n>\n> Among the in-tree scripts, filter-branch, quiltimport, rebase and\n> stash are the commands that run \"commit-tree\".  If any of these\n> wants to allow users to always sign every single commit, they should\n> offer their own configuration (e.g. \"filterBranch..gpgsign\") with an\n> option to disable (e.g. \"git filter-branch --no-gpgsign\").\n>\n> Ignoring commit.gpgsign option _obviously_ breaks the backward\n> compatibility, and I seriously doubt anybody sane is depending on\n> this misfeature that commit-tree blindly follows commit.gpgsign in\n> any third-party script that calls it, but following the \"be careful\n> when removing (mis)features\" tradition, let's give these scripts an\n> escape hatch.  Passing the new --use-commit-gpgsign-config option to\n\ns/to$//\n\n> makes it pay attention to the commit.gpgsign configuration again.\n>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n"}]}