]> git.ipfire.org Git - thirdparty/git.git/commit - Documentation/config/color.txt
pretty: colorize pattern matches in commit messages
authorHamza Mahfooz <someguy@effective-light.com>
Thu, 7 Oct 2021 20:31:47 +0000 (16:31 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 Oct 2021 21:19:14 +0000 (14:19 -0700)
commit6a5c337922a5221d1f6d025d84e18b526df9944c
tree79a681ce03ce5028777414f382e36c99393e3093
parent3f566c4e695a6df8237c34b7c1f34f0832b7e575
pretty: colorize pattern matches in commit messages

The "git log" command limits its output to the commits that contain strings
matched by a pattern when the "--grep=<pattern>" option is used, but unlike
output from "git grep -e <pattern>", the matches are not highlighted,
making them harder to spot.

Teach the pretty-printer code to highlight matches from the
"--grep=<pattern>", "--author=<pattern>" and "--committer=<pattern>"
options (to view the last one, you may have to ask for --pretty=fuller).

Also, it must be noted that we are effectively greping the content twice
(because it would be a hassle to rework the existing matching code to do
a /g match and then pass it all down to the coloring code), however it only
slows down "git log --author=^H" on this repository by around 1-2%
(compared to v2.33.0), so it should be a small enough slow down to justify
the addition of the feature.

Signed-off-by: Hamza Mahfooz <someguy@effective-light.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/color.txt
pretty.c
t/t4202-log.sh