The build you are using chose '{git-default-pager}' as the default.
endif::git-default-pager[]
-Diagnostics
------------
-You don't exist. Go away!::
- The passwd(5) gecos field couldn't be read
-
SEE ALSO
--------
linkgit:git-commit-tree[1]
*/
int remove_or_warn(unsigned int mode, const char *path);
+/* Get the passwd entry for the UID of the current process. */
+struct passwd *xgetpwuid_self(void);
+
#endif
const char *ident_default_name(void)
{
- if (!git_default_name.len) {
- struct passwd *pw = getpwuid(getuid());
- if (!pw)
- die("You don't exist. Go away!");
- copy_gecos(pw, &git_default_name);
- }
+ if (!git_default_name.len)
+ copy_gecos(xgetpwuid_self(), &git_default_name);
return git_default_name.buf;
}
if (email && email[0]) {
strbuf_addstr(&git_default_email, email);
user_ident_explicitly_given |= IDENT_MAIL_GIVEN;
- } else {
- struct passwd *pw = getpwuid(getuid());
- if (!pw)
- die("You don't exist. Go away!");
- copy_email(pw, &git_default_email);
- }
+ } else
+ copy_email(xgetpwuid_self(), &git_default_email);
}
return git_default_email.buf;
}
fputs(env_hint, stderr);
die("empty ident %s <%s> not allowed", name, email);
}
- pw = getpwuid(getuid());
- if (!pw)
- die("You don't exist. Go away!");
+ pw = xgetpwuid_self();
name = pw->pw_name;
}
{
return S_ISGITLINK(mode) ? rmdir_or_warn(file) : unlink_or_warn(file);
}
+
+struct passwd *xgetpwuid_self(void)
+{
+ struct passwd *pw;
+
+ errno = 0;
+ pw = getpwuid(getuid());
+ if (!pw)
+ die(_("unable to look up current user in the passwd file: %s"),
+ errno ? strerror(errno) : _("no such user"));
+ return pw;
+}