revision: make --grep search in notes too if shown
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 29 Sep 2012 04:41:29 +0000 (11:41 +0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 29 Sep 2012 19:15:05 +0000 (12:15 -0700)
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>
Documentation/rev-list-options.txt
revision.c
index ca221060df0772d5cbbce64eb6269cbe9c1c4fc5..ee497430cb0f8dc0859b90b8773e6b8e28d5e361 100644 (file)
@@ -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,
index 9f5e9df93cc58c72180473474321754e5a4606f5..a09e60bedbbbf2c6bdeeacc3d1032bcc1be9cb55 100644 (file)
@@ -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);