summaryrefslogtreecommitdiff
path: root/t/t8012-blame-colors.sh
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2018-04-24 00:08:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-24 02:03:15 (GMT)
commit25d5f52901f0d56b2e3df06b53062ee599b0403b (patch)
tree8fff108b599529db6a5c0572cacc0f61c52b2bb7 /t/t8012-blame-colors.sh
parentcdc2d5f11f1ab931d2f39fefc6197ea1cab220a6 (diff)
downloadgit-25d5f52901f0d56b2e3df06b53062ee599b0403b.zip
git-25d5f52901f0d56b2e3df06b53062ee599b0403b.tar.gz
git-25d5f52901f0d56b2e3df06b53062ee599b0403b.tar.bz2
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 98a22a3..ae9aa79 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