From: Junio C Hamano Date: Wed, 18 May 2016 21:40:05 +0000 (-0700) Subject: Merge branch 'da/user-useconfigonly' into HEAD X-Git-Tag: v2.8.3~21 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e9ef83a299096d38c557fe71c23a3f3e0b1d1a7f?ds=inline;hp=-c 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 --- e9ef83a299096d38c557fe71c23a3f3e0b1d1a7f diff --combined ident.c index 6e125821f0,c766127d75..4fd82d1043 --- a/ident.c +++ b/ident.c @@@ -79,7 -79,7 +79,7 @@@ static int add_mailname_host(struct str strerror(errno)); return -1; } - if (strbuf_getline(&mailnamebuf, mailname, '\n') == EOF) { + if (strbuf_getline(&mailnamebuf, mailname) == EOF) { if (ferror(mailname)) warning("cannot read /etc/mailname: %s", strerror(errno)); @@@ -351,15 -351,17 +351,17 @@@ const char *fmt_ident(const char *name if (want_name) { int using_default = 0; if (!name) { + if (strict && ident_use_config_only + && !(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) { fputs(env_hint, stderr); die("unable to auto-detect name (got '%s')", name); } - if (strict && ident_use_config_only - && !(ident_config_given & IDENT_NAME_GIVEN)) - die("user.useConfigOnly set but no name given"); } if (!*name) { struct passwd *pw; @@@ -374,14 -376,16 +376,16 @@@ } if (!email) { + if (strict && ident_use_config_only + && !(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); die("unable to auto-detect email address (got '%s')", email); } - if (strict && ident_use_config_only - && !(ident_config_given & IDENT_MAIL_GIVEN)) - die("user.useConfigOnly set but no mail given"); } strbuf_reset(&ident);