Merge branch 'nd/log-graph-configurable-colors'
authorJunio C Hamano <gitster@pobox.com>
Thu, 2 Feb 2017 21:36:58 +0000 (13:36 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Feb 2017 21:36:58 +0000 (13:36 -0800)
Some people feel the default set of colors used by "git log --graph"
rather limiting. A mechanism to customize the set of colors has
been introduced.

* nd/log-graph-configurable-colors:
document behavior of empty color name
color_parse_mem: allow empty color spec
log --graph: customize the graph lines with config log.graphColors
color.c: trim leading spaces in color_parse_mem()
color.c: fix color_parse_mem() with value_len == 0

1  2 
Documentation/config.txt
color.c
graph.c
t/t4202-log.sh
Simple merge
diff --cc color.c
Simple merge
diff --cc graph.c
index d4e8519c904df6e18869de527f7fe6d57adf2a26,00aeee36d8a048d56ab686b136cc68bc111f9929..0649007704ac635af163a4e1016121744a951d1c
+++ b/graph.c
@@@ -2,7 -2,9 +2,8 @@@
  #include "commit.h"
  #include "color.h"
  #include "graph.h"
 -#include "diff.h"
  #include "revision.h"
+ #include "argv-array.h"
  
  /* Internal API */
  
diff --cc t/t4202-log.sh
index 1ccbd5948a735f692469e181933c97e8632404b4,1edbb1e7f1d51778193dbeb071fdc94d85e283a5..08ea725de3307c886d8f341b49c61c0d3436f91c
@@@ -338,27 -313,28 +338,49 @@@ test_expect_success 'log --graph with m
        test_cmp expect actual
  '
  
 +cat > expect <<\EOF
 +| | | *   Merge branch 'side'
 +| | | |\
 +| | | | * side-2
 +| | | | * side-1
 +| | | * | Second
 +| | | * | sixth
 +| | | * | fifth
 +| | | * | fourth
 +| | | |/
 +| | | * third
 +| | | * second
 +| | | * initial
 +EOF
 +
 +test_expect_success 'log --graph --line-prefix="| | | " with merge' '
 +      git log --line-prefix="| | | " --graph --date-order --pretty=tformat:%s |
 +              sed "s/ *\$//" >actual &&
 +      test_cmp expect actual
 +'
 +
+ cat > expect.colors <<\EOF
+ *   Merge branch 'side'
+ <BLUE>|<RESET><CYAN>\<RESET>
+ <BLUE>|<RESET> * side-2
+ <BLUE>|<RESET> * side-1
+ * <CYAN>|<RESET> Second
+ * <CYAN>|<RESET> sixth
+ * <CYAN>|<RESET> fifth
+ * <CYAN>|<RESET> fourth
+ <CYAN>|<RESET><CYAN>/<RESET>
+ * third
+ * second
+ * initial
+ EOF
+ test_expect_success 'log --graph with merge with log.graphColors' '
+       test_config log.graphColors " blue,invalid-color, cyan, red  , " &&
+       git log --color=always --graph --date-order --pretty=tformat:%s |
+               test_decode_color | sed "s/ *\$//" >actual &&
+       test_cmp expect.colors actual
+ '
  test_expect_success 'log --raw --graph -m with merge' '
        git log --raw --graph --oneline -m master | head -n 500 >actual &&
        grep "initial" actual