Merge branch 'jk/color-parse'
authorJunio C Hamano <gitster@pobox.com>
Thu, 22 Jan 2009 00:50:34 +0000 (16:50 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Jan 2009 00:50:34 +0000 (16:50 -0800)
* jk/color-parse:
Optimize color_parse_mem
expand --pretty=format color options
color: make it easier for non-config to parse color specs

1  2 
pretty.c
diff --combined pretty.c
index 421d9c5bca2224777808ccc06fe4912ba8793229,b1b86202e1fcf854c64f268b950d2c2f9d956d16..cc460b56970c3869e67feb816f76f4804e37e7ce
+++ b/pretty.c
@@@ -6,6 -6,7 +6,7 @@@
  #include "string-list.h"
  #include "mailmap.h"
  #include "log-tree.h"
+ #include "color.h"
  
  static char *user_format;
  
@@@ -486,8 -487,8 +487,8 @@@ static void parse_commit_header(struct 
        context->commit_header_parsed = 1;
  }
  
 -static const char *format_subject(struct strbuf *sb, const char *msg,
 -                                const char *line_separator)
 +const char *format_subject(struct strbuf *sb, const char *msg,
 +                         const char *line_separator)
  {
        int first = 1;
  
@@@ -554,6 -555,17 +555,17 @@@ static size_t format_commit_item(struc
        /* these are independent of the commit */
        switch (placeholder[0]) {
        case 'C':
+               if (placeholder[1] == '(') {
+                       const char *end = strchr(placeholder + 2, ')');
+                       char color[COLOR_MAXLEN];
+                       if (!end)
+                               return 0;
+                       color_parse_mem(placeholder + 2,
+                                       end - (placeholder + 2),
+                                       "--pretty format", color);
+                       strbuf_addstr(sb, color);
+                       return end - placeholder + 1;
+               }
                if (!prefixcmp(placeholder + 1, "red")) {
                        strbuf_addstr(sb, "\033[31m");
                        return 4;