am -i, git-svn: use "git var GIT_PAGER"
[gitweb.git] / pretty.c
index c57cef47c93912a709fc67fe98cdcff15ed34dc6..587101f846b945d7de219f468699e75565a7e9c0 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -86,6 +86,18 @@ int non_ascii(int ch)
        return !isascii(ch) || ch == '\033';
 }
 
+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;
+}
+
 static int is_rfc2047_special(char ch)
 {
        return (non_ascii(ch) || (ch == '=') || (ch == '?') || (ch == '_'));
@@ -284,7 +296,7 @@ static char *replace_encoding_header(char *buf, const char *encoding)
 static char *logmsg_reencode(const struct commit *commit,
                             const char *output_encoding)
 {
-       static const char *utf8 = "utf-8";
+       static const char *utf8 = "UTF-8";
        const char *use_encoding;
        char *encoding;
        char *out;
@@ -502,6 +514,7 @@ static int istitlechar(char c)
 static void format_sanitized_subject(struct strbuf *sb, const char *msg)
 {
        size_t trimlen;
+       size_t start_len = sb->len;
        int space = 2;
 
        for (; *msg && *msg != '\n'; msg++) {
@@ -519,8 +532,9 @@ static void format_sanitized_subject(struct strbuf *sb, const char *msg)
 
        /* trim any trailing '.' or '-' characters */
        trimlen = 0;
-       while (sb->buf[sb->len - 1 - trimlen] == '.'
-               || sb->buf[sb->len - 1 - trimlen] == '-')
+       while (sb->len - trimlen > start_len &&
+               (sb->buf[sb->len - 1 - trimlen] == '.'
+               || sb->buf[sb->len - 1 - trimlen] == '-'))
                trimlen++;
        strbuf_remove(sb, sb->len - trimlen, trimlen);
 }
@@ -569,7 +583,7 @@ static void format_decoration(struct strbuf *sb, const struct commit *commit)
        struct name_decoration *d;
        const char *prefix = " (";
 
-       load_ref_decorations();
+       load_ref_decorations(DECORATE_SHORT_REFS);
        d = lookup_decoration(&name_decoration, &commit->object);
        while (d) {
                strbuf_addstr(sb, prefix);
@@ -726,7 +740,7 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
 }
 
 void format_commit_message(const struct commit *commit,
-                          const void *format, struct strbuf *sb,
+                          const char *format, struct strbuf *sb,
                           enum date_mode dmode)
 {
        struct format_commit_context context;
@@ -879,7 +893,7 @@ char *reencode_commit_message(const struct commit *commit, const char **encoding
                    ? git_log_output_encoding
                    : git_commit_encoding);
        if (!encoding)
-               encoding = "utf-8";
+               encoding = "UTF-8";
        if (encoding_p)
                *encoding_p = encoding;
        return logmsg_reencode(commit, encoding);