diff options
-rw-r--r-- | cache.h | 1 | ||||
-rw-r--r-- | ident.c | 15 | ||||
-rw-r--r-- | receive-pack.c | 2 |
3 files changed, 18 insertions, 0 deletions
@@ -309,6 +309,7 @@ void datestamp(char *buf, int bufsize); unsigned long approxidate(const char *); extern int setup_ident(void); +extern void ignore_missing_committer_name(); extern const char *git_author_info(int); extern const char *git_committer_info(int); @@ -221,3 +221,18 @@ const char *git_committer_info(int error_on_no_name) getenv("GIT_COMMITTER_DATE"), error_on_no_name); } + +void ignore_missing_committer_name() +{ + /* If we did not get a name from the user's gecos entry then + * git_default_name is empty; so instead load the username + * into it as a 'good enough for now' approximation of who + * this user is. + */ + if (!*git_default_name) { + struct passwd *pw = getpwuid(getuid()); + if (!pw) + die("You don't exist. Go away!"); + strlcpy(git_default_name, pw->pw_name, sizeof(git_default_name)); + } +} diff --git a/receive-pack.c b/receive-pack.c index e76d9aea31..5e5510bc3d 100644 --- a/receive-pack.c +++ b/receive-pack.c @@ -420,6 +420,8 @@ int main(int argc, char **argv) die("'%s': unable to chdir or not a git archive", dir); setup_ident(); + /* don't die if gecos is empty */ + ignore_missing_committer_name(); git_config(receive_pack_config); write_head_info(); |