]> granicus.if.org Git - git/commitdiff
ident: reject bogus email addresses with IDENT_STRICT
authorJeff King <peff@peff.net>
Thu, 24 May 2012 23:32:37 +0000 (19:32 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 25 May 2012 03:50:05 +0000 (20:50 -0700)
If we come up with a hostname like "foo.(none)" because the
user's machine is not fully qualified, we should reject this
in strict mode (e.g., when we are making a commit object),
just as we reject an empty gecos username.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ident.c

diff --git a/ident.c b/ident.c
index c42258f4ea530a303aaaa27b077af4bc8109dd92..98852c7cc901550ccdd6363cf805845304e8ff28 100644 (file)
--- a/ident.c
+++ b/ident.c
@@ -288,6 +288,12 @@ const char *fmt_ident(const char *name, const char *email,
                name = pw->pw_name;
        }
 
+       if (strict && email == git_default_email.buf &&
+           strstr(email, "(none)")) {
+               fputs(env_hint, stderr);
+               die("unable to auto-detect email address (got '%s')", email);
+       }
+
        if (want_date) {
                if (date_str && date_str[0]) {
                        if (parse_date(date_str, date, sizeof(date)) < 0)