]> git.ipfire.org Git - thirdparty/git.git/blame - grep.h
fast-import: introduce "feature notes" command
[thirdparty/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;
5183bf67 35 unsigned ignore_case:1;
d7eb527d 36 unsigned word_regexp:1;
83b5d2f5
JH
37};
38
39enum grep_expr_node {
40 GREP_NODE_ATOM,
41 GREP_NODE_NOT,
42 GREP_NODE_AND,
43 GREP_NODE_OR,
44};
45
46struct grep_expr {
47 enum grep_expr_node node;
0ab7befa 48 unsigned hit;
83b5d2f5
JH
49 union {
50 struct grep_pat *atom;
51 struct grep_expr *unary;
52 struct {
53 struct grep_expr *left;
54 struct grep_expr *right;
55 } binary;
56 } u;
57};
58
59struct grep_opt {
60 struct grep_pat *pattern_list;
61 struct grep_pat **pattern_tail;
80235ba7
JH
62 struct grep_pat *header_list;
63 struct grep_pat **header_tail;
83b5d2f5 64 struct grep_expr *pattern_expression;
493b7a08 65 const char *prefix;
83b5d2f5
JH
66 int prefix_length;
67 regex_t regexp;
3e230fa1
RS
68 int linenum;
69 int invert;
5183bf67 70 int ignore_case;
3e230fa1
RS
71 int status_only;
72 int name_only;
73 int unmatch_name_only;
74 int count;
75 int word_regexp;
76 int fixed;
77 int all_match;
83b5d2f5
JH
78#define GREP_BINARY_DEFAULT 0
79#define GREP_BINARY_NOMATCH 1
80#define GREP_BINARY_TEXT 2
3e230fa1
RS
81 int binary;
82 int extended;
83 int relative;
84 int pathname;
85 int null_following_name;
7e8f59d5 86 int color;
a91f453f 87 int max_depth;
2944e4e6 88 int funcname;
7e8f59d5 89 char color_match[COLOR_MAXLEN];
83b5d2f5
JH
90 int regflags;
91 unsigned pre_context;
92 unsigned post_context;
5dd06d38 93 unsigned last_shown;
046802d0 94 int show_hunk_mark;
60ecac98 95 void *priv;
5b594f45
FK
96
97 void (*output)(struct grep_opt *opt, const void *data, size_t size);
98 void *output_priv;
83b5d2f5
JH
99};
100
101extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
a4d7d2c6 102extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
83b5d2f5 103extern void compile_grep_patterns(struct grep_opt *opt);
b48fb5b6 104extern void free_grep_patterns(struct grep_opt *opt);
83b5d2f5
JH
105extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
106
5b594f45
FK
107extern struct grep_opt *grep_opt_dup(const struct grep_opt *opt);
108extern int grep_threads_ok(const struct grep_opt *opt);
109
83b5d2f5 110#endif