ident: make xgetpwuid_self() a static local helper
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>
Jeff King committed
Dec 10, 2015 at 16:33 UTC
e850194c83985396435b01b70d2db00b6d3af02e
3 files changed
+12
-15
git-compat-util.h
-3
@@ -923,9 +923,6 @@ int access_or_die(const char *path, int mode, unsigned flag);
923
/* Warn on an inaccessible file that ought to be accessible */
924
void warn_on_inaccessible(const char *path);
925
926
-/* Get the passwd entry for the UID of the current process. */
927
-struct passwd *xgetpwuid_self(void);
928
-
926
#ifdef GMTIME_UNRELIABLE_ERRORS
927
struct tm *git_gmtime(const time_t *);
928
struct tm *git_gmtime_r(const time_t *, struct tm *);
ident.c
+12
@@ -23,6 +23,18 @@ static int author_ident_explicitly_given;
23
#define get_gecos(struct_passwd) ((struct_passwd)->pw_gecos)
24
#endif
25
26
+static struct passwd *xgetpwuid_self(void)
27
+{
28
+ struct passwd *pw;
29
+
30
+ errno = 0;
31
+ pw = getpwuid(getuid());
32
+ if (!pw)
33
+ die(_("unable to look up current user in the passwd file: %s"),
34
+ errno ? strerror(errno) : _("no such user"));
35
+ return pw;
36
+}
37
+
38
static void copy_gecos(const struct passwd *w, struct strbuf *name)
39
{
40
char *src;
wrapper.c
-12
@@ -601,18 +601,6 @@ int access_or_die(const char *path, int mode, unsigned flag)
601
return ret;
602
}
603
604
-struct passwd *xgetpwuid_self(void)
605
-{
606
- struct passwd *pw;
607
-
608
- errno = 0;
609
- pw = getpwuid(getuid());
610
- if (!pw)
611
- die(_("unable to look up current user in the passwd file: %s"),
612
- errno ? strerror(errno) : _("no such user"));
613
- return pw;
614
-}
615
-
604
char *xgetcwd(void)
605
{
606
struct strbuf sb = STRBUF_INIT;