grep: print context hunk marks between files
[git/git.git] / grep.h
CommitLineData
83b5d2f5
JH
1#ifndef GREP_H
2#define GREP_H
7e8f59d5 3#include "color.h"
83b5d2f5
JH
4
5enum grep_pat_token {
6 GREP_PATTERN,
480c1ca6
JH
7 GREP_PATTERN_HEAD,
8 GREP_PATTERN_BODY,
83b5d2f5
JH
9 GREP_AND,
10 GREP_OPEN_PAREN,
11 GREP_CLOSE_PAREN,
12 GREP_NOT,
13 GREP_OR,
14};
15
480c1ca6
JH
16enum grep_context {
17 GREP_CONTEXT_HEAD,
18 GREP_CONTEXT_BODY,
19};
20
a4d7d2c6
JH
21enum grep_header_field {
22 GREP_HEADER_AUTHOR = 0,
23 GREP_HEADER_COMMITTER,
24};
25
83b5d2f5
JH
26struct grep_pat {
27 struct grep_pat *next;
28 const char *origin;
29 int no;
30 enum grep_pat_token token;
31 const char *pattern;
a4d7d2c6 32 enum grep_header_field field;
83b5d2f5 33 regex_t regexp;
c822255c 34 unsigned fixed:1;
d7eb527d 35 unsigned word_regexp:1;
83b5d2f5
JH
36};
37
38enum grep_expr_node {
39 GREP_NODE_ATOM,
40 GREP_NODE_NOT,
41 GREP_NODE_AND,
42 GREP_NODE_OR,
43};
44
45struct grep_expr {
46 enum grep_expr_node node;
0ab7befa 47 unsigned hit;
83b5d2f5
JH
48 union {
49 struct grep_pat *atom;
50 struct grep_expr *unary;
51 struct {
52 struct grep_expr *left;
53 struct grep_expr *right;
54 } binary;
55 } u;
56};
57
58struct grep_opt {
59 struct grep_pat *pattern_list;
60 struct grep_pat **pattern_tail;
61 struct grep_expr *pattern_expression;
62 int prefix_length;
63 regex_t regexp;
3e230fa1
RS
64 int linenum;
65 int invert;
66 int status_only;
67 int name_only;
68 int unmatch_name_only;
69 int count;
70 int word_regexp;
71 int fixed;
72 int all_match;
83b5d2f5
JH
73#define GREP_BINARY_DEFAULT 0
74#define GREP_BINARY_NOMATCH 1
75#define GREP_BINARY_TEXT 2
3e230fa1
RS
76 int binary;
77 int extended;
78 int relative;
79 int pathname;
80 int null_following_name;
7e8f59d5
RS
81 int color;
82 char color_match[COLOR_MAXLEN];
a94982ef 83 const char *color_external;
83b5d2f5
JH
84 int regflags;
85 unsigned pre_context;
86 unsigned post_context;
5dd06d38 87 unsigned last_shown;
046802d0 88 int show_hunk_mark;
83b5d2f5
JH
89};
90
91extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
a4d7d2c6 92extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
83b5d2f5 93extern void compile_grep_patterns(struct grep_opt *opt);
b48fb5b6 94extern void free_grep_patterns(struct grep_opt *opt);
83b5d2f5
JH
95extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
96
97#endif