Code

config.c:store_write_pair(): don't read the byte before a malloc'd buffer.
[git.git] / log-tree.c
index 8624d5a39ca3119fe7c4204a2c3b1f272a4b609d..9ebc24b68754a422a53270028b032395ad7c754a 100644 (file)
@@ -140,6 +140,18 @@ static unsigned int digits_in_number(unsigned int number)
        return result;
 }
 
+static int has_non_ascii(const char *s)
+{
+       int ch;
+       if (!s)
+               return 0;
+       while ((ch = *s++) != '\0') {
+               if (non_ascii(ch))
+                       return 1;
+       }
+       return 0;
+}
+
 void show_log(struct rev_info *opt, const char *sep)
 {
        char *msgbuf = NULL;
@@ -290,11 +302,15 @@ void show_log(struct rev_info *opt, const char *sep)
         */
        len = pretty_print_commit(opt->commit_format, commit, ~0u,
                                  &msgbuf, &msgbuf_len, abbrev, subject,
-                                 extra_headers, opt->date_mode);
+                                 extra_headers, opt->date_mode,
+                                 has_non_ascii(opt->add_signoff));
 
        if (opt->add_signoff)
                len = append_signoff(&msgbuf, &msgbuf_len, len,
                                     opt->add_signoff);
+       if (opt->show_log_size)
+               printf("log size %i\n", len);
+
        printf("%s%s%s", msgbuf, extra, sep);
        free(msgbuf);
 }
@@ -318,7 +334,8 @@ int log_tree_diff_flush(struct rev_info *opt)
                 * output for readability.
                 */
                show_log(opt, opt->diffopt.msg_sep);
-               if (opt->verbose_header &&
+               if ((opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) &&
+                   opt->verbose_header &&
                    opt->commit_format != CMIT_FMT_ONELINE) {
                        int pch = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
                        if ((pch & opt->diffopt.output_format) == pch)