From 38cfe915bfc3ea0dbcbedaa82c44460a2ada2f42 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 29 Sep 2012 11:41:29 +0700 Subject: [PATCH] revision: make --grep search in notes too if shown MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- Documentation/rev-list-options.txt | 3 +++ revision.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index ca221060df..ee497430cb 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -66,6 +66,9 @@ endif::git-rev-list[] more than one `--grep=`, commits whose message matches any of the given patterns are chosen (but see `--all-match`). ++ +When `--show-notes` is in effect, the message from the notes as +if it is part of the log message. --all-match:: Limit the commits output to ones that match all given --grep, diff --git a/revision.c b/revision.c index 9f5e9df93c..a09e60bedb 100644 --- a/revision.c +++ b/revision.c @@ -2231,6 +2231,14 @@ static int commit_match(struct commit *commit, struct rev_info *opt) if (buf.len) strbuf_addstr(&buf, commit->buffer); + /* Append "fake" message parts as needed */ + if (opt->show_notes) { + if (!buf.len) + strbuf_addstr(&buf, commit->buffer); + format_display_notes(commit->object.sha1, &buf, + get_log_output_encoding(), 0); + } + /* Find either in the commit object, or in the temporary */ if (buf.len) retval = grep_buffer(&opt->grep_filter, buf.buf, buf.len); -- 2.11.4.GIT