Skip to content

Commit d3c06c1

Browse files
rednebgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 734c778 commit d3c06c1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ident.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,10 @@ const char *fmt_ident(const char *name, const char *email,
352352
int using_default = 0;
353353
if (!name) {
354354
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+
}
357359
name = ident_default_name();
358360
using_default = 1;
359361
if (strict && default_name_is_bogus) {
@@ -375,8 +377,10 @@ const char *fmt_ident(const char *name, const char *email,
375377

376378
if (!email) {
377379
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+
}
380384
email = ident_default_email();
381385
if (strict && default_email_is_bogus) {
382386
fputs(env_hint, stderr);

0 commit comments

Comments
 (0)