{"thread":{"id":"36745","subject":"commit: support commit.verbose and --no-verbose","startedAt":"2014-05-23T21:22:22Z","lastAt":"2014-05-27T18:10:52Z","messageCount":4,"participants":["Caleb Thompson","Jeremiah Mahler","Duy Nguyen","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"242614","messageId":"20140523212222.GA10412@sirius.local","threadId":"36745","inReplyTo":null,"subject":"commit: support commit.verbose and --no-verbose","fromName":"Caleb Thompson","fromEmail":"cjaysson@gmail.com","sentAt":"2014-05-23T21:22:22Z","receivedAt":"2014-05-23T21:22:22Z","isPatch":false,"sender":{"key":"cjaysson@gmail.com","avatar":"https://gravatar.com/avatar/d0b3e333979bf3b7932399a11e5c3e523c501a64e6f419a4fe51f6cae0572259?d=mp&s=160"},"body":"This patch allows people to set `commit.verbose` to implicitly send `--verbose`\nto `git commit`. It also introduces `--no-verbose` to override the configuration\nsetting.\n\nCaleb Thompson\n\nFrom aa2a5d48e6cd53082613f53990bc9d0fa60809f4 Mon Sep 17 00:00:00 2001\nFrom: Caleb Thompson <caleb@calebthompson.io>\nDate: Fri, 23 May 2014 11:47:44 -0500\nSubject: [PATCH] commit: support commit.verbose and --no-verbose\n\nAdd a new configuration variable commit.verbose to implicitly pass\n`--verbose` to `git-commit`. Add `--no-verbose` to commit to negate that\nsetting.\n\nSigned-off-by: Caleb Thompson <caleb@calebthompson.io>\n---\n Documentation/config.txt               |  5 +++++\n Documentation/git-commit.txt           |  9 ++++++++-\n builtin/commit.c                       |  6 +++++-\n contrib/completion/git-completion.bash |  1 +\n t/t7507-commit-verbose.sh              | 21 +++++++++++++++++++++\n 5 files changed, 40 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 1932e9b..a245928 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1009,6 +1009,11 @@ commit.template::\n \t\"`~/`\" is expanded to the value of `$HOME` and \"`~user/`\" to the\n \tspecified user's home directory.\n \n+commit.verbose::\n+\tA boolean to enable/disable inclusion of diff information in the\n+\tcommit message template when using an editor to prepare the commit\n+\tmessage.  Defaults to false.\n+\n credential.helper::\n \tSpecify an external helper to be called when a username or\n \tpassword credential is needed; the helper may consult external\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 0bbc8f5..0e1f930 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -282,7 +282,14 @@ configuration variable documented in linkgit:git-config[1].\n \tShow unified diff between the HEAD commit and what\n \twould be committed at the bottom of the commit message\n \ttemplate.  Note that this diff output doesn't have its\n-\tlines prefixed with '#'.\n+\tlines prefixed with '#'.  The `commit.verbose` configuration\n+\tvariable can be set to true to implicitly send this option.\n+\n+-V::\n+--no-verbose::\n+\tDo not show the unified diff  at the bottom of the commit message\n+\ttemplate.  This is the default behavior, but can be used to override\n+\tthe`commit.verbose` configuration variable.\n \n -q::\n --quiet::\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 9cfef6c..7978d7f 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1417,6 +1417,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.verbose\")) {\n+\t\tverbose = git_config_bool(k, v);\n+\t\treturn 0;\n+\t}\n \n \tstatus = git_gpg_config(k, v, NULL);\n \tif (status)\n@@ -1484,7 +1488,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \tstatic struct wt_status s;\n \tstatic struct option builtin_commit_options[] = {\n \t\tOPT__QUIET(&quiet, N_(\"suppress summary after successful commit\")),\n-\t\tOPT__VERBOSE(&verbose, N_(\"show diff in commit message template\")),\n+\t\tOPT_BOOL('v', \"verbose\", &verbose, N_(\"show diff in commit message template\")),\n \n \t\tOPT_GROUP(N_(\"Commit message options\")),\n \t\tOPT_FILENAME('F', \"file\", &logfile, N_(\"read message from file\")),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 2c59a76..b8f4b94 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1976,6 +1976,7 @@ _git_config ()\n \t\tcolor.ui\n \t\tcommit.status\n \t\tcommit.template\n+\t\tcommit.verbose\n \t\tcore.abbrev\n \t\tcore.askpass\n \t\tcore.attributesfile\ndiff --git a/t/t7507-commit-verbose.sh b/t/t7507-commit-verbose.sh\nindex 2ddf28c..53f68ff 100755\n--- a/t/t7507-commit-verbose.sh\n+++ b/t/t7507-commit-verbose.sh\n@@ -10,6 +10,12 @@ EOF\n chmod +x check-for-diff\n test_set_editor \"$PWD/check-for-diff\"\n \n+cat >check-for-no-diff <<EOF\n+#!$SHELL_PATH\n+exec grep -v '^diff --git' \"\\$1\"\n+EOF\n+chmod +x check-for-no-diff\n+\n cat >message <<'EOF'\n subject\n \n@@ -48,6 +54,21 @@ test_expect_success 'verbose diff is stripped out (mnemonicprefix)' '\n \tcheck_message message\n '\n \n+test_expect_success 'commit shows verbose diff with set commit.verbose' '\n+\techo morecontent >file &&\n+\tgit add file &&\n+\tgit config commit.verbose true &&\n+\tcheck_message message\n+'\n+\n+test_expect_success 'commit does not show verbose diff with --no-verbose' '\n+\techo morecontent >file &&\n+\tgit add file &&\n+\tgit config commit.verbose true &&\n+\ttest_set_editor \"$PWD/check-for-no-diff\" &&\n+\tgit commit --amend --no-verbose\n+'\n+\n cat >diff <<'EOF'\n This is an example commit message that contains a diff.\n \n-- \n1.9.3\n\n"},{"id":"242637","messageId":"20140524075219.GA17093@hudson.localdomain","threadId":"36745","inReplyTo":"20140523212222.GA10412@sirius.local","subject":"Re: commit: support commit.verbose and --no-verbose","fromName":"Jeremiah Mahler","fromEmail":"jmmahler@gmail.com","sentAt":"2014-05-24T07:52:19Z","receivedAt":"2014-05-24T07:52:19Z","isPatch":false,"sender":{"key":"jmmahler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/154028?v=4"},"body":"\nOn Fri, May 23, 2014 at 04:22:22PM -0500, Caleb Thompson wrote:\n> This patch allows people to set `commit.verbose` to implicitly send `--verbose`\n...\n>  \n> +cat >check-for-no-diff <<EOF\n> +#!$SHELL_PATH\n> +exec grep -v '^diff --git' \"\\$1\"\n> +EOF\n> +chmod +x check-for-no-diff\n> +\n\nFor new tests, commands like this should be placed inside a\ntest_expect_success structure.  However, I can see why you did it this\nway since the code just above it does it this way.\nPerhaps others will have some recommendations.\n\nAlso, <<\\-EOF is used instead of <<EOF to remove the tabs.\n\ntest_expect_success 'commit verbose setup' '\n\tcat >check-for-no-diff <<\\-EOF &&\n\t#!SHELL_PATH\n\texec grep -v '^diff --git' \"\\$1\"\n\tEOF\n\tchmod +x check-for-no-diff\n'\n\n>  \n> +test_expect_success 'commit shows verbose diff with set commit.verbose' '\n> +\techo morecontent >file &&\n> +\tgit add file &&\n> +\tgit config commit.verbose true &&\n> +\tcheck_message message\n> +'\n\n'test_config' should be used to set config variables since it\nalso takes care of un-setting them when the test is complete.\n\ntest_expect_success 'commit shows verbose diff with set commit.verbose' '\n\techo morecontent >file &&\n\tgit add file &&\n\ttest_config commit.verbose true &&\n\tcheck_message message\n'\n\n-- \nJeremiah Mahler\njmmahler@gmail.com\nhttp://github.com/jmahler\n"},{"id":"242639","messageId":"CACsJy8C6Ff-wUvwhrT0y6F2rnqwaYByxxFF_8A7rvKTdZn199g@mail.gmail.com","threadId":"36745","inReplyTo":"20140523212222.GA10412@sirius.local","subject":"Re: commit: support commit.verbose and --no-verbose","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-05-24T09:25:35Z","receivedAt":"2014-05-24T09:25:35Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, May 24, 2014 at 4:22 AM, Caleb Thompson <cjaysson@gmail.com> wrote:\n> This patch allows people to set `commit.verbose` to implicitly send `--verbose`\n> to `git commit`. It also introduces `--no-verbose` to override the configuration\n> setting.\n\nThe code change looks fine to me (no opinion if we should do this though).\n\n> --- a/Documentation/git-commit.txt\n> +++ b/Documentation/git-commit.txt\n> @@ -282,7 +282,14 @@ configuration variable documented in linkgit:git-config[1].\n>         Show unified diff between the HEAD commit and what\n>         would be committed at the bottom of the commit message\n>         template.  Note that this diff output doesn't have its\n> -       lines prefixed with '#'.\n> +       lines prefixed with '#'.  The `commit.verbose` configuration\n> +       variable can be set to true to implicitly send this option.\n> +\n> +-V::\n\nNo, I don't think -V is the negative form of -v if you use OPT_BOOL().\n\n> +--no-verbose::\n> +       Do not show the unified diff  at the bottom of the commit message\n> +       template.  This is the default behavior, but can be used to override\n> +       the`commit.verbose` configuration variable.\n-- \nDuy\n"},{"id":"242757","messageId":"xmqq4n0bgkib.fsf@gitster.dls.corp.google.com","threadId":"36745","inReplyTo":"20140524075219.GA17093@hudson.localdomain","subject":"Re: commit: support commit.verbose and --no-verbose","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-05-27T18:10:52Z","receivedAt":"2014-05-27T18:10:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeremiah Mahler <jmmahler@gmail.com> writes:\n\n> On Fri, May 23, 2014 at 04:22:22PM -0500, Caleb Thompson wrote:\n>> This patch allows people to set `commit.verbose` to implicitly send `--verbose`\n> ...\n>>  \n>> +cat >check-for-no-diff <<EOF\n>> +#!$SHELL_PATH\n>> +exec grep -v '^diff --git' \"\\$1\"\n>> +EOF\n>> +chmod +x check-for-no-diff\n>> +\n>\n> For new tests, commands like this should be placed inside a\n> test_expect_success structure.  However, I can see why you did it this\n> way since the code just above it does it this way.\n> Perhaps others will have some recommendations.\n>\n> Also, <<\\-EOF is used instead of <<EOF to remove the tabs.\n>\n> test_expect_success 'commit verbose setup' '\n> \tcat >check-for-no-diff <<\\-EOF &&\n> \t#!SHELL_PATH\n> \texec grep -v '^diff --git' \"\\$1\"\n> \tEOF\n> \tchmod +x check-for-no-diff\n> '\n\nAlso tests use write_script these days to do this kind of thing.\n"}]}