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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Sep 29, 2012 at 11:41 UTC
38cfe915bfc3ea0dbcbedaa82c44460a2ada2f42
2 files changed
+11
Documentation/rev-list-options.txt
+3
@@ -66,6 +66,9 @@ endif::git-rev-list[]
66
more than one `--grep=<pattern>`, commits whose message
67
matches any of the given patterns are chosen (but see
68
`--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.
72
73
--all-match::
74
Limit the commits output to ones that match all given --grep,
revision.c
+8
@@ -2231,6 +2231,14 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
2231
if (buf.len)
2232
strbuf_addstr(&buf, commit->buffer);
2233
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
+
2242
/* Find either in the commit object, or in the temporary */
2243
if (buf.len)
2244
retval = grep_buffer(&opt->grep_filter, buf.buf, buf.len);