]> git.ipfire.org Git - thirdparty/git.git/commitdiff
ident: make xgetpwuid_self() a static local helper
authorJeff King <peff@peff.net>
Thu, 10 Dec 2015 21:33:05 +0000 (16:33 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 10 Dec 2015 23:38:59 +0000 (15:38 -0800)
This function is defined in wrapper.c, but nobody besides
ident.c uses it. And nobody is likely to in the future,
either, as anything that cares about the user's name should
be going through the ident code.

Moving it here is a cleanup of the global namespace, but it
will also enable further cleanups inside ident.c.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-compat-util.h
ident.c
wrapper.c

index 4fe10cc146b5493fad0b073c6410395cd6c7172f..0feeae298340afbe22276ce595de4a6cba397926 100644 (file)
@@ -923,9 +923,6 @@ int access_or_die(const char *path, int mode, unsigned flag);
 /* Warn on an inaccessible file that ought to be accessible */
 void warn_on_inaccessible(const char *path);
 
-/* Get the passwd entry for the UID of the current process. */
-struct passwd *xgetpwuid_self(void);
-
 #ifdef GMTIME_UNRELIABLE_ERRORS
 struct tm *git_gmtime(const time_t *);
 struct tm *git_gmtime_r(const time_t *, struct tm *);
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;
index 0e22d4381438b2c262e1cd5ee0cc4effc2fb3c3d..dae5675a960b636337dc7890fcfbcc559aa98567 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -601,18 +601,6 @@ int access_or_die(const char *path, int mode, unsigned flag)
        return ret;
 }
 
-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;
-}
-
 char *xgetcwd(void)
 {
        struct strbuf sb = STRBUF_INIT;