All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Marios Titas <redneb@gmx.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] ident: make the useConfigOnly error messages more informative
Date: Fri, 01 Apr 2016 15:04:24 -0700	[thread overview]
Message-ID: <xmqqmvpdgf4n.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160330232552.GA31861@zeno> (Marios Titas's message of "Thu, 31 Mar 2016 02:25:52 +0300")

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.

-- >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);
-- 
2.8.0-246-g1783343

  reply	other threads:[~2016-04-01 22:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-30 19:29 [PATCH 1/2] ident: check for useConfigOnly before auto-detection of name/email Marios Titas
2016-03-30 19:29 ` [PATCH 2/2] ident: make the useConfigOnly error messages more informative Marios Titas
2016-03-30 22:27   ` Junio C Hamano
2016-03-30 23:25     ` Marios Titas
2016-04-01 22:04       ` Junio C Hamano [this message]
2016-04-12 23:19         ` Junio C Hamano
2016-03-31 14:40 ` [PATCH 1/2] ident: check for useConfigOnly before auto-detection of name/email Jeff King
2016-03-31 15:01   ` Marios Titas
2016-03-31 16:31     ` Jeff King
2016-04-01 22:00     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqmvpdgf4n.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=redneb@gmx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.