X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=ident.c;h=9b2a852cb00327a607946caa864fcf31184da28e;hb=511707d42b3b3e57d9623493092590546ffeae80;hp=88e7f74e888f1c7b13182bf07afee01408e8e525;hpb=a2d7c6c62080b542007f9787342aa1e57b95f50c;p=git.git diff --git a/ident.c b/ident.c index 88e7f74e8..9b2a852cb 100644 --- a/ident.c +++ b/ident.c @@ -83,11 +83,18 @@ static void setup_ident(void) } if (!git_default_email[0]) { - if (!pw) - pw = getpwuid(getuid()); - if (!pw) - die("You don't exist. Go away!"); - copy_email(pw); + const char *email = getenv("EMAIL"); + + if (email && email[0]) + strlcpy(git_default_email, email, + sizeof(git_default_email)); + else { + if (!pw) + pw = getpwuid(getuid()); + if (!pw) + die("You don't exist. Go away!"); + copy_email(pw); + } } /* And set the default date */ @@ -178,11 +185,11 @@ static const char *env_hint = "\n" "Run\n" "\n" -" git config user.email \"you@email.com\"\n" -" git config user.name \"Your Name\"\n" +" git config --global user.email \"you@email.com\"\n" +" git config --global user.name \"Your Name\"\n" "\n" -"To set the identity in this repository.\n" -"Add --global to set your account\'s default\n" +"to set your account\'s default identity.\n" +"Omit --global to set the identity only in this repository.\n" "\n"; const char *fmt_ident(const char *name, const char *email,