Skip to content

Commit

Permalink
revision: make --grep search in notes too if shown
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Sep 29, 2012
1 parent baa6378 commit 38cfe91
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Documentation/rev-list-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ endif::git-rev-list[]
more than one `--grep=<pattern>`, 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,
Expand Down
8 changes: 8 additions & 0 deletions revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 38cfe91

Please sign in to comment.