7
8
#include "cache.h"
9
#include "config.h"
10
+#include "color.h"
11
#include "builtin.h"
12
#include "commit.h"
13
#include "diff.h"
47
static int abbrev = -1;
48
static int no_whole_file_rename;
49
static int show_progress;
50
+static char repeated_meta_color[COLOR_MAXLEN];
51
52
static struct date_mode blame_date_mode = { DATE_ISO8601 };
53
static size_t blame_date_width;
318
#define OUTPUT_PORCELAIN 010
319
#define OUTPUT_SHOW_NAME 020
320
#define OUTPUT_SHOW_NUMBER 040
319
-#define OUTPUT_SHOW_SCORE 0100
320
-#define OUTPUT_NO_AUTHOR 0200
321
+#define OUTPUT_SHOW_SCORE 0100
322
+#define OUTPUT_NO_AUTHOR 0200
323
#define OUTPUT_SHOW_EMAIL 0400
322
-#define OUTPUT_LINE_PORCELAIN 01000
324
+#define OUTPUT_LINE_PORCELAIN 01000
325
+#define OUTPUT_COLOR_LINE 02000
326
327
static void emit_porcelain_details(struct blame_origin *suspect, int repeat)
328
{
378
struct commit_info ci;
379
char hex[GIT_MAX_HEXSZ + 1];
380
int show_raw_time = !!(opt & OUTPUT_RAW_TIMESTAMP);
381
+ const char *color = NULL, *reset = NULL;
382
383
get_commit_info(suspect->commit, &ci, 1);
384
oid_to_hex_r(hex, &suspect->commit->object.oid);
388
char ch;
389
int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? GIT_SHA1_HEXSZ : abbrev;
390
391
+ if (opt & OUTPUT_COLOR_LINE) {
392
+ if (cnt > 0) {
393
+ color = repeated_meta_color;
394
+ reset = GIT_COLOR_RESET;
395
+ } else {
396
+ color = NULL;
397
+ reset = NULL;
398
+ }
399
+ }
400
+ if (color)
401
+ fputs(color, stdout);
402
+
403
if (suspect->commit->object.flags & UNINTERESTING) {
404
if (blank_boundary)
405
memset(hex, ' ', length);
449
printf(" %*d) ",
450
max_digits, ent->lno + 1 + cnt);
451
}
452
+ if (reset)
453
+ fputs(reset, stdout);
454
do {
455
ch = *cp++;
456
putchar(ch);
625
parse_date_format(value, &blame_date_mode);
626
return 0;
627
}
628
+ if (!strcmp(var, "color.blame.repeatedlines")) {
629
+ if (color_parse_mem(value, strlen(value), repeated_meta_color))
630
+ warning(_("invalid color '%s' in color.blame.repeatedLines"),
631
+ value);
632
+ return 0;
633
+ }
634
635
if (git_diff_heuristic_config(var, value, cb) < 0)
636
return -1;
705
OPT_BIT('s', NULL, &output_option, N_("Suppress author name and timestamp (Default: off)"), OUTPUT_NO_AUTHOR),
706
OPT_BIT('e', "show-email", &output_option, N_("Show author email instead of name (Default: off)"), OUTPUT_SHOW_EMAIL),
707
OPT_BIT('w', NULL, &xdl_opts, N_("Ignore whitespace differences"), XDF_IGNORE_WHITESPACE),
708
+ OPT_BIT(0, "color-lines", &output_option, N_("color redundant metadata from previous line differently"), OUTPUT_COLOR_LINE),
709
710
/*
711
* The following two options are parsed by parse_revision_opt()
965
966
blame_coalesce(&sb);
967
943
- if (!(output_option & OUTPUT_PORCELAIN))
968
+ if (!(output_option & OUTPUT_PORCELAIN)) {
969
find_alignment(&sb, &output_option);
970
+ if (!*repeated_meta_color &&
971
+ (output_option & OUTPUT_COLOR_LINE))
972
+ strcpy(repeated_meta_color, GIT_COLOR_CYAN);
973
+ }
974
+ if (output_option & OUTPUT_ANNOTATE_COMPAT)
975
+ output_option &= ~OUTPUT_COLOR_LINE;
976
977
output(&sb, output_option);
978
free((void *)sb.final_buf);