summaryrefslogtreecommitdiff
path: root/builtin/blame.c
diff options
context:
space:
mode:
authorLibravatar Stefan Beller <sbeller@google.com>2018-04-23 17:09:00 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-04-24 11:03:17 +0900
commit0dc95a4d8a71bcb0c9d0163716bd99c2d785bd10 (patch)
treeeec6accb6f09b4efde6a51a78f79991b8f8e50bf /builtin/blame.c
parentbuiltin/blame: highlight recently changed lines (diff)
downloadtgif-0dc95a4d8a71bcb0c9d0163716bd99c2d785bd10.tar.xz
builtin/blame: add new coloring scheme config
Add a config option that allows selecting the default color scheme for blame. The command line still takes precedence over the configuration. It is to be seen, how color.ui will integrate with blame coloring. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/blame.c')
-rw-r--r--builtin/blame.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index 35104e4160..f95aac7468 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -49,6 +49,7 @@ static int abbrev = -1;
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;
@@ -702,6 +703,20 @@ static int git_blame_config(const char *var, const char *value, void *cb)
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)
@@ -1037,6 +1052,9 @@ parse_done:
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 &&