git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] ident: make the useConfigOnly error messages more informative

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 12, 2016, 23:19 UTC
Message-ID
<xmqq37qqo1od.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqmvpdgf4n.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> Marios Titas <redneb@gmx.com> writes:
>
>> Yeah, maybe informative is not the right word. What I meant is that it
>> directs the user to do the "git config user.name" thing, which is
>> likely the most appropriate course of action in this situation. In any
>> event, I think printing the env_hint message would be really helpful
>> in this case.
>
> OK, let's do this, then.
>
> Thanks.
A friendly ping asking for an Ack.
Show 50 quoted lines
> -- >8 --
> From: Marios Titas <redneb@gmx.com>
> Date: Wed, 30 Mar 2016 22:29:43 +0300
> Subject: [PATCH] ident: give "please tell me" message upon useConfigOnly error
>
> The env_hint message applies perfectly to the case when
> user.useConfigOnly is set and at least one of the user.name and the
> user.email are not provided.
>
> Additionally, use a less descriptive error message to discourage
> users from disabling user.useConfigOnly configuration variable to
> work around this error condition.  We want to encourage them to set
> user.name or user.email instead.
>
> Signed-off-by: Marios Titas <redneb@gmx.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  ident.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/ident.c b/ident.c
> index b2521ff..c766127 100644
> --- a/ident.c
> +++ b/ident.c
> @@ -352,8 +352,10 @@ const char *fmt_ident(const char *name, const char *email,
>  		int using_default = 0;
>  		if (!name) {
>  			if (strict && ident_use_config_only
> -			    && !(ident_config_given & IDENT_NAME_GIVEN))
> -				die("user.useConfigOnly set but no name given");
> +			    && !(ident_config_given & IDENT_NAME_GIVEN)) {
> +				fputs(env_hint, stderr);
> +				die("no name was given and auto-detection is disabled");
> +			}
>  			name = ident_default_name();
>  			using_default = 1;
>  			if (strict && default_name_is_bogus) {
> @@ -375,8 +377,10 @@ const char *fmt_ident(const char *name, const char *email,
>  
>  	if (!email) {
>  		if (strict && ident_use_config_only
> -		    && !(ident_config_given & IDENT_MAIL_GIVEN))
> -			die("user.useConfigOnly set but no mail given");
> +		    && !(ident_config_given & IDENT_MAIL_GIVEN)) {
> +			fputs(env_hint, stderr);
> +			die("no email was given and auto-detection is disabled");
> +		}
>  		email = ident_default_email();
>  		if (strict && default_email_is_bogus) {
>  			fputs(env_hint, stderr);
Previous: Junio C HamanoNext: Jeff King
Message 6 of 10 in “ident: check for useConfigOnly before auto-detection of name/email”
  1. 1/2 ident: check for useConfigOnly before auto-detection of name/emailMarios Titas, Mar 30, 2016
  2. 2/2 ident: make the useConfigOnly error messages more informativeMarios Titas, Mar 30, 2016
  3. Junio C HamanoMar 30, 2016
  4. Marios TitasMar 30, 2016
  5. Junio C HamanoApr 1, 2016
  6. Junio C HamanoApr 12, 2016
  7. Jeff KingMar 31, 2016
  8. Marios TitasMar 31, 2016
  9. Jeff KingMar 31, 2016
  10. Junio C HamanoApr 1, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.