git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Taylor Braun-Jones <taylor@braun-jones.org>,
	Duy Nguyen <pclouds@gmail.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: [PATCH 1/3] ident: make xgetpwuid_self() a static local helper
Date: Thu, 10 Dec 2015 16:33:05 -0500	[thread overview]
Message-ID: <20151210213304.GA8374@sigill.intra.peff.net> (raw)
In-Reply-To: <20151210213228.GB29055@sigill.intra.peff.net>

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>
---
 git-compat-util.h |  3 ---
 ident.c           | 12 ++++++++++++
 wrapper.c         | 12 ------------
 3 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index 8e39867..2da0a75 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -929,9 +929,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 5ff1aad..d7c70e2 100644
--- 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;
diff --git a/wrapper.c b/wrapper.c
index 6fcaa4d..c95e290 100644
--- 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;
-- 
2.6.3.636.g1460207

  reply	other threads:[~2015-12-10 21:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-02 20:10 git-clone fails when current user is not in /etc/passwd Taylor Braun-Jones
2015-12-09 15:23 ` Taylor Braun-Jones
2015-12-09 16:08 ` Duy Nguyen
2015-12-09 18:24   ` Duy Nguyen
2015-12-09 22:35     ` Taylor Braun-Jones
2015-12-10 18:33       ` Taylor Braun-Jones
2015-12-10 18:34       ` Jeff King
2015-12-10 19:57         ` Junio C Hamano
2015-12-10 20:40           ` Jeff King
2015-12-10 21:32             ` [PATCH 0/3] " Jeff King
2015-12-10 21:33               ` Jeff King [this message]
2015-12-10 23:39                 ` [PATCH 1/3] ident: make xgetpwuid_self() a static local helper Junio C Hamano
2015-12-10 21:35               ` [PATCH 2/3] ident: keep a flag for bogus default_email Jeff King
2015-12-10 22:54                 ` Jeff King
2015-12-10 21:41               ` [PATCH 3/3] ident: loosen getpwuid error in non-strict mode Jeff King
2015-12-14 15:07                 ` Jeff King
2015-12-10 23:44               ` [PATCH 0/3] git-clone fails when current user is not in /etc/passwd Junio C Hamano
2015-12-11  2:20               ` Taylor Braun-Jones
2015-12-10 18:43     ` Junio C Hamano
2015-12-10 18:52       ` Taylor Braun-Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151210213304.GA8374@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    --cc=taylor@braun-jones.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).