summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2012-09-29 04:41:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-09-29 18:41:14 (GMT)
commit72fd13f71c18b438ca3e482c126bcbcaa2dac650 (patch)
tree8b9d4b67161ee6eb9ef8a62b175278c69a6e8ba3 /revision.c
parentad4813b3c2513c5dc7e84305ab8a393b32124977 (diff)
downloadgit-72fd13f71c18b438ca3e482c126bcbcaa2dac650.zip
git-72fd13f71c18b438ca3e482c126bcbcaa2dac650.tar.gz
git-72fd13f71c18b438ca3e482c126bcbcaa2dac650.tar.bz2
revision: add --grep-reflog to filter commits by reflog messages
Similar to --author/--committer which filters commits by author and committer header fields. --grep-reflog adds a fake "reflog" header to commit and a grep filter to search on that line. All rules to --author/--committer apply except no timestamp stripping. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/revision.c b/revision.c
index ae12e11..109bec1 100644
--- a/revision.c
+++ b/revision.c
@@ -1595,6 +1595,9 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
} else if ((argcount = parse_long_opt("committer", argv, &optarg))) {
add_header_grep(revs, GREP_HEADER_COMMITTER, optarg);
return argcount;
+ } else if ((argcount = parse_long_opt("grep-reflog", argv, &optarg))) {
+ add_header_grep(revs, GREP_HEADER_REFLOG, optarg);
+ return argcount;
} else if ((argcount = parse_long_opt("grep", argv, &optarg))) {
add_message_grep(revs, optarg);
return argcount;
@@ -2210,10 +2213,23 @@ static int rewrite_parents(struct rev_info *revs, struct commit *commit)
static int commit_match(struct commit *commit, struct rev_info *opt)
{
+ int retval;
+ struct strbuf buf = STRBUF_INIT;
if (!opt->grep_filter.pattern_list && !opt->grep_filter.header_list)
return 1;
- return grep_buffer(&opt->grep_filter,
- commit->buffer, strlen(commit->buffer));
+ if (opt->reflog_info) {
+ strbuf_addstr(&buf, "reflog ");
+ get_reflog_message(&buf, opt->reflog_info);
+ strbuf_addch(&buf, '\n');
+ strbuf_addstr(&buf, commit->buffer);
+ }
+ if (buf.len)
+ retval = grep_buffer(&opt->grep_filter, buf.buf, buf.len);
+ else
+ retval = grep_buffer(&opt->grep_filter,
+ commit->buffer, strlen(commit->buffer));
+ strbuf_release(&buf);
+ return retval;
}
static inline int want_ancestry(struct rev_info *revs)