summaryrefslogtreecommitdiff
path: root/ident.c
diff options
context:
space:
mode:
authorMatt Kraai <kraai@ftbfs.org>2007-07-05 17:29:41 -0700
committerJunio C Hamano <gitster@pobox.com>2007-07-05 23:22:12 -0700
commit46f74f007b86452c4b4135f5145f94eefc994ea2 (patch)
tree0302c7ff8cbc976de6191a2dbf60b15731678794 /ident.c
parent20ccef49689b3f4dc7510c63d9867e1969eed1e3 (diff)
downloadgit-46f74f007b86452c4b4135f5145f94eefc994ea2.tar.gz
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>
Diffstat (limited to 'ident.c')
-rw-r--r--ident.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/ident.c b/ident.c
index 3d49608e6f..6612d17eba 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 */
@@ -197,8 +204,6 @@ const char *fmt_ident(const char *name, const char *email,
name = git_default_name;
if (!email)
email = git_default_email;
- if (!email)
- email = getenv("EMAIL");
if (!*name) {
struct passwd *pw;