coccicheck: use --all-includes by default
[gitweb.git] / mailmap.c
index 9e9589730fa44c94d122dfdb50172baf95e2578d..b5c521fdea8b0bfc577795b172010dfc2b8bf8ff 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
@@ -162,11 +162,10 @@ static void read_mailmap_line(struct string_list *map, char *buffer,
                        char *cp;
 
                        free(*repo_abbrev);
-                       *repo_abbrev = xmalloc(len);
 
                        for (cp = buffer + abblen; isspace(*cp); cp++)
                                ; /* nothing */
-                       strcpy(*repo_abbrev, cp);
+                       *repo_abbrev = xstrdup(cp);
                }
                return;
        }
@@ -190,8 +189,7 @@ static int read_mailmap_file(struct string_list *map, const char *filename,
        if (!f) {
                if (errno == ENOENT)
                        return 0;
-               return error("unable to open mailmap at %s: %s",
-                            filename, strerror(errno));
+               return error_errno("unable to open mailmap at %s", filename);
        }
 
        while (fgets(buffer, sizeof(buffer), f) != NULL)
@@ -251,7 +249,8 @@ int read_mailmap(struct string_list *map, char **repo_abbrev)
                git_mailmap_blob = "HEAD:.mailmap";
 
        err |= read_mailmap_file(map, ".mailmap", repo_abbrev);
-       err |= read_mailmap_blob(map, git_mailmap_blob, repo_abbrev);
+       if (startup_info->have_repository)
+               err |= read_mailmap_blob(map, git_mailmap_blob, repo_abbrev);
        err |= read_mailmap_file(map, git_mailmap_file, repo_abbrev);
        return err;
 }