Prefer EMAIL to username@hostname.
The environment variable $EMAIL gives a better default of user's preferred e-mail address than the hardcoded "username@hostname", as it is understood by many existing programs. We still honor GIT_*_EMAIL environment variables and user.email configuration variable give them higher precedence, so that the user can override $EMAIL or "username@hostname", as they are likely to be more specific to the context of working on a particular project. Signed-off-by: Matt Kraai <kraai@ftbfs.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
20ccef4968
commit
46f74f007b
9
ident.c
9
ident.c
@ -83,12 +83,19 @@ static void setup_ident(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!git_default_email[0]) {
|
if (!git_default_email[0]) {
|
||||||
|
const char *email = getenv("EMAIL");
|
||||||
|
|
||||||
|
if (email && email[0])
|
||||||
|
strlcpy(git_default_email, email,
|
||||||
|
sizeof(git_default_email));
|
||||||
|
else {
|
||||||
if (!pw)
|
if (!pw)
|
||||||
pw = getpwuid(getuid());
|
pw = getpwuid(getuid());
|
||||||
if (!pw)
|
if (!pw)
|
||||||
die("You don't exist. Go away!");
|
die("You don't exist. Go away!");
|
||||||
copy_email(pw);
|
copy_email(pw);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* And set the default date */
|
/* And set the default date */
|
||||||
if (!git_default_date[0])
|
if (!git_default_date[0])
|
||||||
@ -197,8 +204,6 @@ const char *fmt_ident(const char *name, const char *email,
|
|||||||
name = git_default_name;
|
name = git_default_name;
|
||||||
if (!email)
|
if (!email)
|
||||||
email = git_default_email;
|
email = git_default_email;
|
||||||
if (!email)
|
|
||||||
email = getenv("EMAIL");
|
|
||||||
|
|
||||||
if (!*name) {
|
if (!*name) {
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
Loading…
Reference in New Issue
Block a user