summaryrefslogtreecommitdiff
path: root/t/t8012-blame-colors.sh
diff options
context:
space:
mode:
authorLibravatar Stefan Beller <sbeller@google.com>2018-04-23 17:08:59 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-04-24 11:03:15 +0900
commit25d5f52901f0d56b2e3df06b53062ee599b0403b (patch)
tree8fff108b599529db6a5c0572cacc0f61c52b2bb7 /t/t8012-blame-colors.sh
parentbuiltin/blame: dim uninteresting metadata lines (diff)
downloadtgif-25d5f52901f0d56b2e3df06b53062ee599b0403b.tar.xz
builtin/blame: highlight recently changed lines
Choose a different color for dates and imitate a 'temperature cool down' depending upon age. Originally I had planned to have the temperature cool down dependent on the age of the project or file for example, as that might scale better, but that can be added on top of this commit, e.g. instead of giving a date, you could imagine giving a percentage that would be the linearly interpolated between now and the beginning of the file. Similarly to the previous patch, this offers the command line option '--color-by-age' to enable this mode and the config option 'color.blame.highlightrecent' to select colors. A later patch will offer a config option to select the default mode. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t8012-blame-colors.sh')
-rwxr-xr-xt/t8012-blame-colors.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/t/t8012-blame-colors.sh b/t/t8012-blame-colors.sh
index 98a22a3c8d..ae9aa79d4e 100755
--- a/t/t8012-blame-colors.sh
+++ b/t/t8012-blame-colors.sh
@@ -16,4 +16,29 @@ test_expect_success 'colored blame colors contiguous lines' '
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 &&
+ test_decode_color <actual.raw >actual &&
+ grep "<BLUE>" <actual >colored &&
+ test_line_count = 10 colored
+'
+
+test_expect_success 'blame color by age: new code is different' '
+ cat >>hello.c <<-EOF &&
+ void qfunc();
+ EOF
+ git add hello.c &&
+ GIT_AUTHOR_DATE="" git commit -m "new commit" &&
+
+ git -c color.blame.highlightRecent="yellow,1 month ago, cyan" blame --color-by-age hello.c >actual.raw &&
+ test_decode_color <actual.raw >actual &&
+
+ grep "<YELLOW>" <actual >colored &&
+ test_line_count = 10 colored &&
+
+ grep "<CYAN>" <actual >colored &&
+ test_line_count = 1 colored &&
+ grep qfunc colored
+'
+
test_done