+static void add_header_grep(struct rev_info *revs, const char *field, const char *pattern)
+{
+ char *pat;
+ int patlen, fldlen;
+
+ if (!revs->header_filter) {
+ struct grep_opt *opt = xcalloc(1, sizeof(*opt));
+ opt->status_only = 1;
+ opt->pattern_tail = &(opt->pattern_list);
+ opt->regflags = REG_NEWLINE;
+ revs->header_filter = opt;
+ }
+
+ fldlen = strlen(field);
+ patlen = strlen(pattern);
+ pat = xmalloc(patlen + fldlen + 3);
+ sprintf(pat, "^%s %s", field, pattern);
+ append_grep_pattern(revs->header_filter, pat,
+ "command line", 0, GREP_PATTERN);
+}
+
+static void add_message_grep(struct rev_info *revs, const char *pattern)
+{
+ if (!revs->message_filter) {
+ struct grep_opt *opt = xcalloc(1, sizeof(*opt));
+ opt->status_only = 1;
+ opt->pattern_tail = &(opt->pattern_list);
+ opt->regflags = REG_NEWLINE;
+ revs->message_filter = opt;
+ }
+ append_grep_pattern(revs->message_filter, pattern,
+ "command line", 0, GREP_PATTERN);
+}
+