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>

Marios Titas committed Mar 30, 2016 at 22:29 UTC d3c06c196964c02f7343b53301e0e85679fad51f
1 file changed +8 -4
ident.c
+8 -4
@@ -352,8 +352,10 @@ const char *fmt_ident(const char *name, const char *email,
352 int using_default = 0;
353 if (!name) {
354 if (strict && ident_use_config_only
355 - && !(ident_config_given & IDENT_NAME_GIVEN))
356 - die("user.useConfigOnly set but no name given");
355 + && !(ident_config_given & IDENT_NAME_GIVEN)) {
356 + fputs(env_hint, stderr);
357 + die("no name was given and auto-detection is disabled");
358 + }
359 name = ident_default_name();
360 using_default = 1;
361 if (strict && default_name_is_bogus) {
@@ -375,8 +377,10 @@ const char *fmt_ident(const char *name, const char *email,
377
378 if (!email) {
379 if (strict && ident_use_config_only
378 - && !(ident_config_given & IDENT_MAIL_GIVEN))
379 - die("user.useConfigOnly set but no mail given");
380 + && !(ident_config_given & IDENT_MAIL_GIVEN)) {
381 + fputs(env_hint, stderr);
382 + die("no email was given and auto-detection is disabled");
383 + }
384 email = ident_default_email();
385 if (strict && default_email_is_bogus) {
386 fputs(env_hint, stderr);