ident: make xgetpwuid_self() a static local helper
[gitweb.git] / ident.c
diff --git a/ident.c b/ident.c
index 5ff1aadaaaa999df3bfecb07f84f259469b3a54d..d7c70e28d2087f9fa2a6d9f5ef9fed3bc4c01a45 100644 (file)
--- a/ident.c
+++ b/ident.c
@@ -23,6 +23,18 @@ static int author_ident_explicitly_given;
 #define get_gecos(struct_passwd) ((struct_passwd)->pw_gecos)
 #endif
 
+static 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;
+}
+
 static void copy_gecos(const struct passwd *w, struct strbuf *name)
 {
        char *src;