*dest_color = colorfield[i].col;
}
-static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int opt)
+static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent,
+ int opt, struct blame_entry *prev_ent)
{
int cnt;
const char *cp;
the_hash_algo->hexsz : (size_t) abbrev;
if (opt & OUTPUT_COLOR_LINE) {
- if (cnt > 0) {
+ if (cnt > 0 ||
+ (prev_ent &&
+ oideq(&suspect->commit->object.oid,
+ &prev_ent->suspect->commit->object.oid))) {
color = repeated_meta_color;
reset = GIT_COLOR_RESET;
} else {
static void output(struct blame_scoreboard *sb, int option)
{
- struct blame_entry *ent;
+ struct blame_entry *ent, *prev_ent = NULL;
if (option & OUTPUT_PORCELAIN) {
for (ent = sb->ent; ent; ent = ent->next) {
if (option & OUTPUT_PORCELAIN)
emit_porcelain(sb, ent, option);
else {
- emit_other(sb, ent, option);
+ emit_other(sb, ent, option, prev_ent);
+ prev_ent = ent;
}
}
}
test_line_count = 3 H.expect
'
+test_expect_success 'color lines becoming contiguous due to --ignore-rev' '
+ mv hello.c hello.orig &&
+ sed "s/ / /g" <hello.orig >hello.c &&
+ git add hello.c &&
+ git commit -m"tabs to spaces" &&
+ git -c color.blame.repeatedLines=yellow blame --color-lines --ignore-rev=HEAD hello.c >actual.raw &&
+ test_decode_color <actual.raw >actual &&
+ grep "<YELLOW>" <actual >darkened &&
+ grep "(F" darkened > F.expect &&
+ grep "(H" darkened > H.expect &&
+ test_line_count = 2 F.expect &&
+ test_line_count = 3 H.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 &&