]> git.ipfire.org Git - thirdparty/git.git/commit - revision.c
"log --author=me --grep=it" should find intersection, not union
authorJunio C Hamano <gitster@pobox.com>
Mon, 18 Jan 2010 04:09:06 +0000 (20:09 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 Jan 2010 03:28:13 +0000 (19:28 -0800)
commit80235ba79ef43349f455cce869397b3e726f4058
tree3ec0247fba884fe708ec771833a981cb4ebf61ea
parentff6d26a0e1d8fad775010fa3b689c0c027da8bb0
"log --author=me --grep=it" should find intersection, not union

Historically, any grep filter in "git log" family of commands were taken
as restricting to commits with any of the words in the commit log message.
However, the user almost always want to find commits "done by this person
on that topic".  With "--all-match" option, a series of grep patterns can
be turned into a requirement that all of them must produce a match, but
that makes it impossible to ask for "done by me, on either this or that"
with:

log --author=me --committer=him --grep=this --grep=that

because it will require both "this" and "that" to appear.

Change the "header" parser of grep library to treat the headers specially,
and parse it as:

(all-match-OR (HEADER-AUTHOR me)
      (HEADER-COMMITTER him)
      (OR
       (PATTERN this)
(PATTERN that) ) )

Even though the "log" command line parser doesn't give direct access to
the extended grep syntax to group terms with parentheses, this change will
cover the majority of the case the users would want.

This incidentally revealed that one test in t7002 was bogus.  It ran:

log --author=Thor --grep=Thu --format='%s'

and expected (wrongly) "Thu" to match "Thursday" in the author/committer
date, but that would never match, as the timestamp in raw commit buffer
does not have the name of the day-of-the-week.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-grep.c
builtin-rev-list.c
grep.c
grep.h
revision.c
t/t7002-grep.sh