]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Windows: A minimal implemention of getpwuid().
authorJohannes Sixt <johannes.sixt@telecom.at>
Sat, 1 Dec 2007 21:09:17 +0000 (22:09 +0100)
committerJohannes Sixt <johannes.sixt@telecom.at>
Mon, 23 Jun 2008 11:38:10 +0000 (13:38 +0200)
getpwuid() is implemented just enough that GIT does not issue errors.
Since the information that it returns is not very useful, users are
required to set up user.name and user.email configuration.

All uses of getpwuid() are like getpwuid(getuid()), hence, the return value
of getuid() is irrelevant and the uid parameter is not even looked at.

Side note: getpwnam() is only used to resolve '~' and '~username' paths,
which is an idiom not known on Windows, hence, we don't implement it.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
compat/mingw.c

index f869999a5d6ac7b2a7a78781c0c6e16d3446e98f..0e1ddbe4dff977c4141df925940c90bbbe7f7e24 100644 (file)
@@ -75,7 +75,15 @@ char *mingw_getcwd(char *pointer, int len)
 
 struct passwd *getpwuid(int uid)
 {
+       static char user_name[100];
        static struct passwd p;
+
+       DWORD len = sizeof(user_name);
+       if (!GetUserName(user_name, &len))
+               return NULL;
+       p.pw_name = user_name;
+       p.pw_gecos = "unknown";
+       p.pw_dir = NULL;
        return &p;
 }