Skip to content

Commit e9ef83a

Browse files
committed
Merge branch 'da/user-useconfigonly' into HEAD
The "user.useConfigOnly" configuration variable makes it an error if users do not explicitly set user.name and user.email. However, its check was not done early enough and allowed another error to trigger, reporting that the default value we guessed from the system setting was unusable. This was a suboptimal end-user experience as we want the users to set user.name/user.email without relying on the auto-detection at all. * da/user-useconfigonly: ident: give "please tell me" message upon useConfigOnly error ident: check for useConfigOnly before auto-detection of name/email
2 parents 787a490 + d3c06c1 commit e9ef83a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ident.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,17 @@ const char *fmt_ident(const char *name, const char *email,
351351
if (want_name) {
352352
int using_default = 0;
353353
if (!name) {
354+
if (strict && ident_use_config_only
355+
&& !(ident_config_given & IDENT_NAME_GIVEN)) {
356+
fputs(env_hint, stderr);
357+
die("no name was given and auto-detection is disabled");
358+
}
354359
name = ident_default_name();
355360
using_default = 1;
356361
if (strict && default_name_is_bogus) {
357362
fputs(env_hint, stderr);
358363
die("unable to auto-detect name (got '%s')", name);
359364
}
360-
if (strict && ident_use_config_only
361-
&& !(ident_config_given & IDENT_NAME_GIVEN))
362-
die("user.useConfigOnly set but no name given");
363365
}
364366
if (!*name) {
365367
struct passwd *pw;
@@ -374,14 +376,16 @@ const char *fmt_ident(const char *name, const char *email,
374376
}
375377

376378
if (!email) {
379+
if (strict && ident_use_config_only
380+
&& !(ident_config_given & IDENT_MAIL_GIVEN)) {
381+
fputs(env_hint, stderr);
382+
die("no email was given and auto-detection is disabled");
383+
}
377384
email = ident_default_email();
378385
if (strict && default_email_is_bogus) {
379386
fputs(env_hint, stderr);
380387
die("unable to auto-detect email address (got '%s')", email);
381388
}
382-
if (strict && ident_use_config_only
383-
&& !(ident_config_given & IDENT_MAIL_GIVEN))
384-
die("user.useConfigOnly set but no mail given");
385389
}
386390

387391
strbuf_reset(&ident);

0 commit comments

Comments
 (0)