Extract Git::SVN from git-svn into its own .pm file.
[gitweb.git] / pretty.c
index 02a0a2bb43570fec656c4152454fa67743111a2c..8b1ea9ffad2a0b5c5cb5c15cc5057a8a7132da07 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -439,12 +439,14 @@ static char *get_header(const struct commit *commit, const char *key)
        int key_len = strlen(key);
        const char *line = commit->buffer;
 
-       for (;;) {
+       while (line) {
                const char *eol = strchr(line, '\n'), *next;
 
                if (line == eol)
                        return NULL;
                if (!eol) {
+                       warning("malformed commit (header is missing newline): %s",
+                               sha1_to_hex(commit->object.sha1));
                        eol = line + strlen(line);
                        next = NULL;
                } else
@@ -456,6 +458,7 @@ static char *get_header(const struct commit *commit, const char *key)
                }
                line = next;
        }
+       return NULL;
 }
 
 static char *replace_encoding_header(char *buf, const char *encoding)
@@ -547,8 +550,10 @@ static size_t format_person_part(struct strbuf *sb, char part,
        mail_end = s.mail_end;
 
        if (part == 'N' || part == 'E') { /* mailmap lookup */
-               strlcpy(person_name, name_start, name_end - name_start + 1);
-               strlcpy(person_mail, mail_start, mail_end - mail_start + 1);
+               snprintf(person_name, sizeof(person_name), "%.*s",
+                        (int)(name_end - name_start), name_start);
+               snprintf(person_mail, sizeof(person_mail), "%.*s",
+                        (int)(mail_end - mail_start), mail_start);
                mailmap_name(person_mail, sizeof(person_mail), person_name, sizeof(person_name));
                name_start = person_name;
                name_end = name_start + strlen(person_name);