rebase -m: do not trigger pre-commit verification
[gitweb.git] / log-tree.c
index 62edd344558049f05c33888de9d2fc2a854b51e9..dd94f393a06a0c8a7fc6420af0b9487df47ec4a4 100644 (file)
@@ -15,7 +15,7 @@ static void show_parents(struct commit *commit, int abbrev)
        }
 }
 
-static void show_decorations(struct commit *commit)
+void show_decorations(struct commit *commit)
 {
        const char *prefix;
        struct name_decoration *decoration;
@@ -125,6 +125,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)
 {
        struct strbuf msgbuf;
@@ -134,6 +146,7 @@ void show_log(struct rev_info *opt, const char *sep)
        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) {
@@ -202,6 +215,8 @@ void show_log(struct rev_info *opt, const char *sep)
                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"
@@ -233,8 +248,7 @@ void show_log(struct rev_info *opt, const char *sep)
                        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)
@@ -254,8 +268,7 @@ void show_log(struct rev_info *opt, const char *sep)
                               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,
@@ -272,8 +285,11 @@ void show_log(struct rev_info *opt, const char *sep)
         * 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);