Skip to content

Commit 38cfe91

Browse files
pcloudsgitster
authored andcommitted
revision: make --grep search in notes too if shown
Notes are shown after commit body. From user perspective it looks pretty much like commit body and they may assume --grep would search in that part too. Make it so. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent baa6378 commit 38cfe91

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Documentation/rev-list-options.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ endif::git-rev-list[]
6666
more than one `--grep=<pattern>`, commits whose message
6767
matches any of the given patterns are chosen (but see
6868
`--all-match`).
69+
+
70+
When `--show-notes` is in effect, the message from the notes as
71+
if it is part of the log message.
6972

7073
--all-match::
7174
Limit the commits output to ones that match all given --grep,

revision.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,6 +2231,14 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
22312231
if (buf.len)
22322232
strbuf_addstr(&buf, commit->buffer);
22332233

2234+
/* Append "fake" message parts as needed */
2235+
if (opt->show_notes) {
2236+
if (!buf.len)
2237+
strbuf_addstr(&buf, commit->buffer);
2238+
format_display_notes(commit->object.sha1, &buf,
2239+
get_log_output_encoding(), 0);
2240+
}
2241+
22342242
/* Find either in the commit object, or in the temporary */
22352243
if (buf.len)
22362244
retval = grep_buffer(&opt->grep_filter, buf.buf, buf.len);

0 commit comments

Comments
 (0)