# [PATCH] add a commit.verbose config variable

3 messages from 2016-03-09 to 2016-03-09. Participants: Pranit Bauva, Matthieu Moy.
Thread: https://gitlist.dev/t/41654

## Pranit Bauva, 2016-03-09 18:49

Subject: [PATCH] add a commit.verbose config variable
Message-ID: <010201535cb62b56-9aa72755-b730-478c-9244-41a1ee69e231-000000@eu-west-1.amazonses.com>
URL: https://gitlist.dev/e/010201535cb62b56-9aa72755-b730-478c-9244-41a1ee69e231-000000%40eu-west-1.amazonses.com

```
Since many people always run the command with this option, and would
prefer not to use the argument again and again but instead specify it in
the configuration file.

Also add a override-verbose option in git-commit if no verbose is required
when the commit.verbose is true in the configuration file.

Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
---
 Documentation/config.txt     | 4 ++++
 Documentation/git-commit.txt | 7 ++++++-
 builtin/commit.c             | 7 +++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 01cca0a..cf2f48b 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1110,6 +1110,10 @@ commit.template::
 	"`~/`" is expanded to the value of `$HOME` and "`~user/`" to the
 	specified user's home directory.
 
+commit.verbose::
+	A boolean to specify whether to always include the verbose option
+	with `git commit`. See linkgit:git-commit[1]
+
 credential.helper::
 	Specify an external helper to be called when a username or
 	password credential is needed; the helper may consult external
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 9ec6b3c..0972b45 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -290,12 +290,17 @@ configuration variable documented in linkgit:git-config[1].
 	what changes the commit has.
 	Note that this diff output doesn't have its
 	lines prefixed with '#'. This diff will not be a part
-	of the commit message.
+	of the commit message. To activate this option permanently, the
+	configuration variable `commit.verbose` can be set to true.
 +
 If specified twice, show in addition the unified diff between
 what would be committed and the worktree files, i.e. the unstaged
 changes to tracked files.
 
+--override-verbose::
+	Disable verbose for the commit if you have activated it
+	permanently in the configuration variable `commit.verbose`.
+
 -q::
 --quiet::
 	Suppress commit summary message.
diff --git a/builtin/commit.c b/builtin/commit.c
index b3bd2d4..0577968 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -114,6 +114,7 @@ static char *fixup_message, *squash_message;
 static int all, also, interactive, patch_interactive, only, amend, signoff;
 static int edit_flag = -1; /* unspecified */
 static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
+static int override_verbose;
 static int no_post_rewrite, allow_empty_message;
 static char *untracked_files_arg, *force_date, *ignore_submodule_arg;
 static char *sign_commit;
@@ -1590,6 +1591,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		OPT_BOOL('e', "edit", &edit_flag, N_("force edit of commit")),
 		OPT_STRING(0, "cleanup", &cleanup_arg, N_("default"), N_("how to strip spaces and #comments from message")),
 		OPT_BOOL(0, "status", &include_status, N_("include status in commit message template")),
+		OPT_BOOL(0, "override-verbose", &override_verbose, N_("override the verbose setting in configuration file")),
 		{ OPTION_STRING, 'S', "gpg-sign", &sign_commit, N_("key-id"),
 		  N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
 		/* end commit message options */
@@ -1654,6 +1656,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	argc = parse_and_validate_options(argc, argv, builtin_commit_options,
 					  builtin_commit_usage,
 					  prefix, current_head, &s);
+
+	if( !override_verbose )
+		if( !verbose )
+			git_config_get_bool("commit.verbose", &verbose);
+
 	if (dry_run)
 		return dry_run_commit(argc, argv, prefix, current_head, &s);
 	index_file = prepare_index(argc, argv, prefix, current_head, 0);

--
https://github.com/git/git/pull/204

```

## Pranit Bauva, 2016-03-09 20:32

Subject: Re: [PATCH] add a commit.verbose config variable
Message-ID: <CAFZEwPM6XLkp07ekBfDaAPcJLvKxRNCW=deFy+GasWYeqcjk-A@mail.gmail.com>
URL: https://gitlist.dev/e/CAFZEwPM6XLkp07ekBfDaAPcJLvKxRNCW%3DdeFy%2BGasWYeqcjk-A%40mail.gmail.com
In-Reply-To: <010201535cb62b56-9aa72755-b730-478c-9244-41a1ee69e231-000000@eu-west-1.amazonses.com>

```
A previous version of this patch can be found at
http://news.gmane.org/gmane.comp.version-control.git/287540 .

The changes in the patch are :-
 - Fix typo "git config" to "git commit"
 - Use a better commit message
 - Drop a paragraph in commit message so as to not misguide readers
 - Consider additional tests as suggested by Eric Sunshine
 - Add an option "override-verbose" to git commit to override the
"always true" setting if set in the configuration file

It took me quite some time to send this patch. I was trying to write
tests for this and send the patch together but I could not find the
test examples that could be used from the existing code base. If
someone has an idea in mind then I could probably write the tests.
Though I have tested this personally for all the cases but I think it
would be preferable to automate the job.

Regards,
Pranit Bauva
IIT Kharagpur

```

## Matthieu Moy, 2016-03-09 21:21

Subject: Re: [PATCH] add a commit.verbose config variable
Message-ID: <vpqlh5r9wjx.fsf@anie.imag.fr>
URL: https://gitlist.dev/e/vpqlh5r9wjx.fsf%40anie.imag.fr
In-Reply-To: <010201535cb62b56-9aa72755-b730-478c-9244-41a1ee69e231-000000@eu-west-1.amazonses.com>

```
Hi,

This is v2, right? Then call it [PATCH v2] in the title, and summarize
the diff wrt v1. As much as possible, Cc people who participated in the
review of v1.

Pranit Bauva <pranit.bauva@gmail.com> writes:

> Since many people always run the command with this option, and would
> prefer not to use the argument again and again but instead specify it in
> the configuration file.

"Since ... and ..." calls for a verb to end the sentence (already noted
by Eric with v1).

> +commit.verbose::
> +	A boolean to specify whether to always include the verbose option
> +	with `git commit`. See linkgit:git-commit[1]

Either say "See linkgit:git-commit[1]" between parenthesis, or add a
period (.) at the end of the sentence.

> +--override-verbose::
> +	Disable verbose for the commit if you have activated it
> +	permanently in the configuration variable `commit.verbose`.

The convention is to call this --no-verbose. --override-verbose is not a
good name for such option.

Look how other similar cases are managed (e.g. status.short,
status.branch, am.threeway)

> @@ -1654,6 +1656,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
>  	argc = parse_and_validate_options(argc, argv, builtin_commit_options,
>  					  builtin_commit_usage,
>  					  prefix, current_head, &s);
> +
> +	if( !override_verbose )
> +		if( !verbose )

Style: spaces between if and (, but not inside ( ).

> +			git_config_get_bool("commit.verbose", &verbose);

This is a strange way to write the "cli takes precedence over config".
The usual way is to read from least precedence to highest precedence,
i.e. git_config_get_bool before calling parse_option.

You dropped the "RFC" tag from the subject line, but your patch still
lacks a test. It cannot be called final without.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```
