Skip to content

Commit e850194

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bc49712 commit e850194

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

git-compat-util.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -923,9 +923,6 @@ int access_or_die(const char *path, int mode, unsigned flag);
923923
/* Warn on an inaccessible file that ought to be accessible */
924924
void warn_on_inaccessible(const char *path);
925925

926-
/* Get the passwd entry for the UID of the current process. */
927-
struct passwd *xgetpwuid_self(void);
928-
929926
#ifdef GMTIME_UNRELIABLE_ERRORS
930927
struct tm *git_gmtime(const time_t *);
931928
struct tm *git_gmtime_r(const time_t *, struct tm *);

ident.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ static int author_ident_explicitly_given;
2323
#define get_gecos(struct_passwd) ((struct_passwd)->pw_gecos)
2424
#endif
2525

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+
2638
static void copy_gecos(const struct passwd *w, struct strbuf *name)
2739
{
2840
char *src;

wrapper.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -601,18 +601,6 @@ int access_or_die(const char *path, int mode, unsigned flag)
601601
return ret;
602602
}
603603

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-
616604
char *xgetcwd(void)
617605
{
618606
struct strbuf sb = STRBUF_INIT;

0 commit comments

Comments
 (0)