static void setup_ident(void) { struct passwd *pw = NULL; /* Get the name ("gecos") */ if (!git_default_name[0]) { pw = getpwuid(getuid()); if (!pw) die("You don't exist. Go away!"); copy_gecos(pw, git_default_name, sizeof(git_default_name)); } if (!git_default_email[0]) { const char *email = getenv("EMAIL"); if (email && email[0]) { strlcpy(git_default_email, email, sizeof(git_default_email)); user_ident_explicitly_given |= IDENT_MAIL_GIVEN; } else { if (!pw) pw = getpwuid(getuid()); if (!pw) die("You don't exist. Go away!"); copy_email(pw); } } /* And set the default date */ if (!git_default_date[0]) datestamp(git_default_date, sizeof(git_default_date)); }
const char *ident_default_name(void) { if (!git_default_name.len) { copy_gecos(xgetpwuid_self(&default_name_is_bogus), &git_default_name); strbuf_trim(&git_default_name); } return git_default_name.buf; }