summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Gieschke <rafael@gieschke.de>2011-05-19 11:37:55 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-20 01:35:58 (GMT)
commit590e081dea7c064056941bfae28b25ce956585f5 (patch)
tree8c3f7e984296967cf55af6fe6db6d345e9e42e4c
parentc0336ff27a9a4bf9db87d65c5dec1ebf7dd9f8c6 (diff)
downloadgit-590e081dea7c064056941bfae28b25ce956585f5.zip
git-590e081dea7c064056941bfae28b25ce956585f5.tar.gz
git-590e081dea7c064056941bfae28b25ce956585f5.tar.bz2
ident: add NO_GECOS_IN_PWENT for systems without pw_gecos in struct passwd
Allow NO_GECOS_IN_PWENT to be defined in the Makefile for platforms that lack the pw_gecos field in their "struct passwd", in which case the uppercased user name is used instead via the standard '&' replacement mechanism. Signed-off-by: Rafael Gieschke <rafael@gieschke.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--Makefile3
-rw-r--r--ident.c8
2 files changed, 10 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 02d6ea3..90283ab 100644
--- a/Makefile
+++ b/Makefile
@@ -59,6 +59,9 @@ all::
#
# Define NO_MKSTEMPS if you don't have mkstemps in the C library.
#
+# Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
+# in the C library.
+#
# Define NO_LIBGEN_H if you don't have libgen.h.
#
# Define NEEDS_LIBGEN if your libgen needs -lgen when linking
diff --git a/ident.c b/ident.c
index 4232084..770b9e0 100644
--- a/ident.c
+++ b/ident.c
@@ -9,6 +9,12 @@
static char git_default_date[50];
+#ifdef NO_GECOS_IN_PWENT
+#define get_gecos(ignored) "&"
+#else
+#define get_gecos(struct_passwd) ((struct_passwd)->pw_gecos)
+#endif
+
static void copy_gecos(const struct passwd *w, char *name, size_t sz)
{
char *src, *dst;
@@ -20,7 +26,7 @@ static void copy_gecos(const struct passwd *w, char *name, size_t sz)
* with commas. Also & stands for capitalized form of the login name.
*/
- for (len = 0, dst = name, src = w->pw_gecos; len < sz; src++) {
+ for (len = 0, dst = name, src = get_gecos(w); len < sz; src++) {
int ch = *src;
if (ch != '&') {
*dst++ = ch;