}
}
-static void show_decorations(struct commit *commit)
+void show_decorations(struct commit *commit)
{
const char *prefix;
struct name_decoration *decoration;
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)
{
struct strbuf msgbuf;
int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
const char *extra;
const char *subject = NULL, *extra_headers = opt->extra_headers;
+ int need_8bit_cte = 0;
opt->loginfo = NULL;
if (!opt->verbose_header) {
if (opt->mime_boundary) {
static char subject_buffer[1024];
static char buffer[1024];
+
+ need_8bit_cte = -1; /* never */
snprintf(subject_buffer, sizeof(subject_buffer) - 1,
"%s"
"MIME-Version: 1.0\n"
opt->diffopt.stat_sep = buffer;
}
} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
- fputs(diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT),
- stdout);
+ fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);
if (opt->commit_format != CMIT_FMT_ONELINE)
fputs("commit ", stdout);
if (commit->object.flags & BOUNDARY)
diff_unique_abbrev(parent->object.sha1,
abbrev_commit));
show_decorations(commit);
- printf("%s",
- diff_get_color(opt->diffopt.color_diff, DIFF_RESET));
+ printf("%s", diff_get_color_opt(&opt->diffopt, DIFF_RESET));
putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
if (opt->reflog_info) {
show_reflog_message(opt->reflog_info,
* And then the pretty-printed message itself
*/
strbuf_init(&msgbuf, 0);
+ if (need_8bit_cte >= 0)
+ need_8bit_cte = has_non_ascii(opt->add_signoff);
pretty_print_commit(opt->commit_format, commit, &msgbuf,
- abbrev, subject, extra_headers, opt->date_mode);
+ abbrev, subject, extra_headers, opt->date_mode,
+ need_8bit_cte);
if (opt->add_signoff)
append_signoff(&msgbuf, opt->add_signoff);