test/send-email: --[no-]xmailer tests
[gitweb.git] / pretty.c
index 14357e233f3174963add310a29bb35c3de229121..31fc76b2fde8297298a7d9ffd38ea7f00eede2fa 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -24,6 +24,11 @@ static size_t commit_formats_len;
 static size_t commit_formats_alloc;
 static struct cmt_fmt_map *find_commit_format(const char *sought);
 
+int commit_format_is_empty(enum cmit_fmt fmt)
+{
+       return fmt == CMIT_FMT_USERFORMAT && !*user_format;
+}
+
 static void save_user_format(struct rev_info *rev, const char *cp, int is_tformat)
 {
        free(user_format);
@@ -146,7 +151,7 @@ void get_commit_format(const char *arg, struct rev_info *rev)
        struct cmt_fmt_map *commit_format;
 
        rev->use_terminator = 0;
-       if (!arg || !*arg) {
+       if (!arg) {
                rev->commit_format = CMIT_FMT_DEFAULT;
                return;
        }
@@ -155,7 +160,7 @@ void get_commit_format(const char *arg, struct rev_info *rev)
                return;
        }
 
-       if (strchr(arg, '%')) {
+       if (!*arg || strchr(arg, '%')) {
                save_user_format(rev, arg, 1);
                return;
        }
@@ -1376,7 +1381,7 @@ static size_t format_and_pad_commit(struct strbuf *sb, /* in UTF-8 */
                case trunc_none:
                        break;
                }
-               strbuf_addstr(sb, local_sb.buf);
+               strbuf_addbuf(sb, &local_sb);
        } else {
                int sb_len = sb->len, offset = 0;
                if (c->flush_type == flush_left)
@@ -1554,12 +1559,7 @@ static void pp_header(struct pretty_print_context *pp,
                }
 
                if (!parents_shown) {
-                       struct commit_list *parent;
-                       int num;
-                       for (parent = commit->parents, num = 0;
-                            parent;
-                            parent = parent->next, num++)
-                               ;
+                       unsigned num = commit_list_count(commit->parents);
                        /* with enough slop */
                        strbuf_grow(sb, num * 50 + 20);
                        add_merge_info(pp, sb, commit);