diff --git a/compat/mingw.c b/compat/mingw.c index 4e1003442d..152915fd21 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -620,3 +620,17 @@ int mingw_vsnprintf(char *buf, size_t size, const char *fmt, va_list args) } while (len < 0); return len; } + +struct passwd *mingw_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; +} diff --git a/git-compat-util.h b/git-compat-util.h index 66c4fb37a5..79ce4e0c2f 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -527,6 +527,16 @@ int git_fstat(int fd, struct stat *buf); int mingw_vsnprintf(char *buf, size_t size, const char *fmt, va_list args); #define vsnprintf mingw_vsnprintf +struct passwd { + char *pw_name; + char *pw_gecos; + char *pw_dir; +}; +struct passwd *mingw_getpwuid(int uid); +#define getpwuid mingw_getpwuid +static inline int getuid() { return 1; } +static inline struct passwd *getpwnam(const char *name) { return NULL; } + #endif /* __MINGW32__ */ #endif