one year old are kept white, and lines introduced within the last month are
colored red.
+blame.coloring::
+ This determines the coloring scheme to be applied to blame
+ output. It can be 'repeatedLines', 'highlightRecent',
+ or 'none' which is the default.
+
color.ui::
This variable determines the default value for variables such
as `color.diff` and `color.grep` that control the use of color
static int no_whole_file_rename;
static int show_progress;
static char repeated_meta_color[COLOR_MAXLEN];
+static int coloring_mode;
static struct date_mode blame_date_mode = { DATE_ISO8601 };
static size_t blame_date_width;
return 0;
}
+ if (!strcmp(var, "blame.coloring")) {
+ if (!strcmp(value, "repeatedLines")) {
+ coloring_mode |= OUTPUT_COLOR_LINE;
+ } else if (!strcmp(value, "highlightRecent")) {
+ coloring_mode |= OUTPUT_SHOW_AGE_WITH_COLOR;
+ } else if (!strcmp(value, "none")) {
+ coloring_mode &= ~(OUTPUT_COLOR_LINE |
+ OUTPUT_SHOW_AGE_WITH_COLOR);
+ } else {
+ warning(_("invalid value for blame.coloring"));
+ return 0;
+ }
+ }
+
if (git_diff_heuristic_config(var, value, cb) < 0)
return -1;
if (userdiff_config(var, value) < 0)
blame_coalesce(&sb);
+ if (!(output_option & (OUTPUT_COLOR_LINE | OUTPUT_SHOW_AGE_WITH_COLOR)))
+ output_option |= coloring_mode;
+
if (!(output_option & OUTPUT_PORCELAIN)) {
find_alignment(&sb, &output_option);
if (!*repeated_meta_color &&
test_expect_success 'colored blame colors contiguous lines' '
git -c color.blame.repeatedLines=yellow blame --color-lines --abbrev=12 hello.c >actual.raw &&
+ git -c color.blame.repeatedLines=yellow -c blame.coloring=repeatedLines blame --abbrev=12 hello.c >actual.raw.2 &&
+ test_cmp actual.raw actual.raw.2 &&
test_decode_color <actual.raw >actual &&
grep "<YELLOW>" <actual >darkened &&
grep "(F" darkened > F.expect &&
test_expect_success 'color by age consistently colors old code' '
git blame --color-by-age hello.c >actual.raw &&
+ git -c blame.coloring=highlightRecent blame hello.c >actual.raw.2 &&
+ test_cmp actual.raw actual.raw.2 &&
test_decode_color <actual.raw >actual &&
grep "<BLUE>" <actual >colored &&
test_line_count = 10 colored