Use nice names in conflict markers during cherry-pick/revert.
[gitweb.git] / ident.c
diff --git a/ident.c b/ident.c
index e415fd35889b3c5547878221c4a113351715d8bc..6ad8fedd60ba1461d77dc2b1d66e52cf56158c6f 100644 (file)
--- a/ident.c
+++ b/ident.c
@@ -7,9 +7,6 @@
  */
 #include "cache.h"
 
-#include <pwd.h>
-#include <netdb.h>
-
 static char git_default_date[50];
 
 static void copy_gecos(struct passwd *w, char *name, int sz)
@@ -221,3 +218,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));
+       }
+}