author | Lars Hjemli <hjemli@gmail.com> | 2006-12-28 01:45:28 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2006-12-28 01:45:28 (UTC) |
commit | 732d68d240b95dc428c92fc94bce9adb8912094e (patch) (unidiff) | |
tree | 24c6ab907c2a8574da12e426144706ad63780868 /git.h | |
parent | e39d738c39d37cdef115c145027f3eec85a62272 (diff) | |
download | cgit-732d68d240b95dc428c92fc94bce9adb8912094e.zip cgit-732d68d240b95dc428c92fc94bce9adb8912094e.tar.gz cgit-732d68d240b95dc428c92fc94bce9adb8912094e.tar.bz2 |
Add basic log filtering
This enables case-insensitive grep on logentris using the new search box
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | git.h | 68 |
1 files changed, 67 insertions, 1 deletions
@@ -1,414 +1,480 @@ | |||
1 | #ifndef GIT_H | 1 | #ifndef GIT_H |
2 | #define GIT_H | 2 | #define GIT_H |
3 | 3 | ||
4 | 4 | ||
5 | /* | 5 | /* |
6 | * from git:git-compat-util.h | 6 | * from git:git-compat-util.h |
7 | */ | 7 | */ |
8 | 8 | ||
9 | 9 | ||
10 | #ifndef FLEX_ARRAY | 10 | #ifndef FLEX_ARRAY |
11 | #if defined(__GNUC__) && (__GNUC__ < 3) | 11 | #if defined(__GNUC__) && (__GNUC__ < 3) |
12 | #define FLEX_ARRAY 0 | 12 | #define FLEX_ARRAY 0 |
13 | #else | 13 | #else |
14 | #define FLEX_ARRAY /* empty */ | 14 | #define FLEX_ARRAY /* empty */ |
15 | #endif | 15 | #endif |
16 | #endif | 16 | #endif |
17 | 17 | ||
18 | 18 | ||
19 | #include <unistd.h> | 19 | #include <unistd.h> |
20 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include <sys/stat.h> | 21 | #include <sys/stat.h> |
22 | #include <fcntl.h> | 22 | #include <fcntl.h> |
23 | #include <stddef.h> | 23 | #include <stddef.h> |
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | #include <stdarg.h> | 25 | #include <stdarg.h> |
26 | #include <string.h> | 26 | #include <string.h> |
27 | #include <errno.h> | 27 | #include <errno.h> |
28 | #include <limits.h> | 28 | #include <limits.h> |
29 | #include <sys/param.h> | 29 | #include <sys/param.h> |
30 | #include <netinet/in.h> | 30 | #include <netinet/in.h> |
31 | #include <sys/types.h> | 31 | #include <sys/types.h> |
32 | #include <dirent.h> | 32 | #include <dirent.h> |
33 | #include <time.h> | 33 | #include <time.h> |
34 | 34 | #include <regex.h> | |
35 | 35 | ||
36 | /* On most systems <limits.h> would have given us this, but | 36 | /* On most systems <limits.h> would have given us this, but |
37 | * not on some systems (e.g. GNU/Hurd). | 37 | * not on some systems (e.g. GNU/Hurd). |
38 | */ | 38 | */ |
39 | #ifndef PATH_MAX | 39 | #ifndef PATH_MAX |
40 | #define PATH_MAX 4096 | 40 | #define PATH_MAX 4096 |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #ifdef __GNUC__ | 43 | #ifdef __GNUC__ |
44 | #define NORETURN __attribute__((__noreturn__)) | 44 | #define NORETURN __attribute__((__noreturn__)) |
45 | #else | 45 | #else |
46 | #define NORETURN | 46 | #define NORETURN |
47 | #ifndef __attribute__ | 47 | #ifndef __attribute__ |
48 | #define __attribute__(x) | 48 | #define __attribute__(x) |
49 | #endif | 49 | #endif |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | 52 | ||
53 | extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); | 53 | extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); |
54 | 54 | ||
55 | 55 | ||
56 | static inline char* xstrdup(const char *str) | 56 | static inline char* xstrdup(const char *str) |
57 | { | 57 | { |
58 | char *ret = strdup(str); | 58 | char *ret = strdup(str); |
59 | if (!ret) | 59 | if (!ret) |
60 | die("Out of memory, strdup failed"); | 60 | die("Out of memory, strdup failed"); |
61 | return ret; | 61 | return ret; |
62 | } | 62 | } |
63 | 63 | ||
64 | static inline void *xmalloc(size_t size) | 64 | static inline void *xmalloc(size_t size) |
65 | { | 65 | { |
66 | void *ret = malloc(size); | 66 | void *ret = malloc(size); |
67 | if (!ret && !size) | 67 | if (!ret && !size) |
68 | ret = malloc(1); | 68 | ret = malloc(1); |
69 | if (!ret) | 69 | if (!ret) |
70 | die("Out of memory, malloc failed"); | 70 | die("Out of memory, malloc failed"); |
71 | #ifdef XMALLOC_POISON | 71 | #ifdef XMALLOC_POISON |
72 | memset(ret, 0xA5, size); | 72 | memset(ret, 0xA5, size); |
73 | #endif | 73 | #endif |
74 | return ret; | 74 | return ret; |
75 | } | 75 | } |
76 | 76 | ||
77 | static inline void *xrealloc(void *ptr, size_t size) | 77 | static inline void *xrealloc(void *ptr, size_t size) |
78 | { | 78 | { |
79 | void *ret = realloc(ptr, size); | 79 | void *ret = realloc(ptr, size); |
80 | if (!ret && !size) | 80 | if (!ret && !size) |
81 | ret = realloc(ptr, 1); | 81 | ret = realloc(ptr, 1); |
82 | if (!ret) | 82 | if (!ret) |
83 | die("Out of memory, realloc failed"); | 83 | die("Out of memory, realloc failed"); |
84 | return ret; | 84 | return ret; |
85 | } | 85 | } |
86 | 86 | ||
87 | static inline void *xcalloc(size_t nmemb, size_t size) | 87 | static inline void *xcalloc(size_t nmemb, size_t size) |
88 | { | 88 | { |
89 | void *ret = calloc(nmemb, size); | 89 | void *ret = calloc(nmemb, size); |
90 | if (!ret && (!nmemb || !size)) | 90 | if (!ret && (!nmemb || !size)) |
91 | ret = calloc(1, 1); | 91 | ret = calloc(1, 1); |
92 | if (!ret) | 92 | if (!ret) |
93 | die("Out of memory, calloc failed"); | 93 | die("Out of memory, calloc failed"); |
94 | return ret; | 94 | return ret; |
95 | } | 95 | } |
96 | 96 | ||
97 | static inline ssize_t xread(int fd, void *buf, size_t len) | 97 | static inline ssize_t xread(int fd, void *buf, size_t len) |
98 | { | 98 | { |
99 | ssize_t nr; | 99 | ssize_t nr; |
100 | while (1) { | 100 | while (1) { |
101 | nr = read(fd, buf, len); | 101 | nr = read(fd, buf, len); |
102 | if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) | 102 | if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) |
103 | continue; | 103 | continue; |
104 | return nr; | 104 | return nr; |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | static inline ssize_t xwrite(int fd, const void *buf, size_t len) | 108 | static inline ssize_t xwrite(int fd, const void *buf, size_t len) |
109 | { | 109 | { |
110 | ssize_t nr; | 110 | ssize_t nr; |
111 | while (1) { | 111 | while (1) { |
112 | nr = write(fd, buf, len); | 112 | nr = write(fd, buf, len); |
113 | if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) | 113 | if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) |
114 | continue; | 114 | continue; |
115 | return nr; | 115 | return nr; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
120 | 120 | ||
121 | 121 | ||
122 | /* | 122 | /* |
123 | * from git:cache.h | 123 | * from git:cache.h |
124 | */ | 124 | */ |
125 | 125 | ||
126 | 126 | ||
127 | /* Convert to/from hex/sha1 representation */ | 127 | /* Convert to/from hex/sha1 representation */ |
128 | #define MINIMUM_ABBREV 4 | 128 | #define MINIMUM_ABBREV 4 |
129 | #define DEFAULT_ABBREV 7 | 129 | #define DEFAULT_ABBREV 7 |
130 | 130 | ||
131 | extern const unsigned char null_sha1[20]; | 131 | extern const unsigned char null_sha1[20]; |
132 | 132 | ||
133 | extern int sha1_object_info(const unsigned char *, char *, unsigned long *); | 133 | extern int sha1_object_info(const unsigned char *, char *, unsigned long *); |
134 | 134 | ||
135 | extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size); | 135 | extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size); |
136 | 136 | ||
137 | extern int get_sha1(const char *str, unsigned char *sha1); | 137 | extern int get_sha1(const char *str, unsigned char *sha1); |
138 | extern int get_sha1_hex(const char *hex, unsigned char *sha1); | 138 | extern int get_sha1_hex(const char *hex, unsigned char *sha1); |
139 | extern char *sha1_to_hex(const unsigned char *sha1);/* static buffer result! */ | 139 | extern char *sha1_to_hex(const unsigned char *sha1);/* static buffer result! */ |
140 | 140 | ||
141 | static inline int is_null_sha1(const unsigned char *sha1) | 141 | static inline int is_null_sha1(const unsigned char *sha1) |
142 | { | 142 | { |
143 | return !memcmp(sha1, null_sha1, 20); | 143 | return !memcmp(sha1, null_sha1, 20); |
144 | } | 144 | } |
145 | static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2) | 145 | static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2) |
146 | { | 146 | { |
147 | return memcmp(sha1, sha2, 20); | 147 | return memcmp(sha1, sha2, 20); |
148 | } | 148 | } |
149 | static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src) | 149 | static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src) |
150 | { | 150 | { |
151 | memcpy(sha_dst, sha_src, 20); | 151 | memcpy(sha_dst, sha_src, 20); |
152 | } | 152 | } |
153 | static inline void hashclr(unsigned char *hash) | 153 | static inline void hashclr(unsigned char *hash) |
154 | { | 154 | { |
155 | memset(hash, 0, 20); | 155 | memset(hash, 0, 20); |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | /* | ||
160 | * from git:grep.h | ||
161 | */ | ||
162 | |||
163 | enum grep_pat_token { | ||
164 | GREP_PATTERN, | ||
165 | GREP_PATTERN_HEAD, | ||
166 | GREP_PATTERN_BODY, | ||
167 | GREP_AND, | ||
168 | GREP_OPEN_PAREN, | ||
169 | GREP_CLOSE_PAREN, | ||
170 | GREP_NOT, | ||
171 | GREP_OR, | ||
172 | }; | ||
173 | |||
174 | enum grep_context { | ||
175 | GREP_CONTEXT_HEAD, | ||
176 | GREP_CONTEXT_BODY, | ||
177 | }; | ||
178 | |||
179 | struct grep_pat { | ||
180 | struct grep_pat *next; | ||
181 | const char *origin; | ||
182 | int no; | ||
183 | enum grep_pat_token token; | ||
184 | const char *pattern; | ||
185 | regex_t regexp; | ||
186 | }; | ||
187 | |||
188 | enum grep_expr_node { | ||
189 | GREP_NODE_ATOM, | ||
190 | GREP_NODE_NOT, | ||
191 | GREP_NODE_AND, | ||
192 | GREP_NODE_OR, | ||
193 | }; | ||
194 | |||
195 | struct grep_opt { | ||
196 | struct grep_pat *pattern_list; | ||
197 | struct grep_pat **pattern_tail; | ||
198 | struct grep_expr *pattern_expression; | ||
199 | int prefix_length; | ||
200 | regex_t regexp; | ||
201 | unsigned linenum:1; | ||
202 | unsigned invert:1; | ||
203 | unsigned status_only:1; | ||
204 | unsigned name_only:1; | ||
205 | unsigned unmatch_name_only:1; | ||
206 | unsigned count:1; | ||
207 | unsigned word_regexp:1; | ||
208 | unsigned fixed:1; | ||
209 | unsigned all_match:1; | ||
210 | #define GREP_BINARY_DEFAULT 0 | ||
211 | #define GREP_BINARY_NOMATCH 1 | ||
212 | #define GREP_BINARY_TEXT 2 | ||
213 | unsigned binary:2; | ||
214 | unsigned extended:1; | ||
215 | unsigned relative:1; | ||
216 | unsigned pathname:1; | ||
217 | int regflags; | ||
218 | unsigned pre_context; | ||
219 | unsigned post_context; | ||
220 | }; | ||
221 | |||
222 | |||
223 | extern void compile_grep_patterns(struct grep_opt *opt); | ||
224 | extern void free_grep_patterns(struct grep_opt *opt); | ||
159 | 225 | ||
160 | 226 | ||
161 | /* | 227 | /* |
162 | * from git:object.h | 228 | * from git:object.h |
163 | */ | 229 | */ |
164 | 230 | ||
165 | struct object_list { | 231 | struct object_list { |
166 | struct object *item; | 232 | struct object *item; |
167 | struct object_list *next; | 233 | struct object_list *next; |
168 | }; | 234 | }; |
169 | 235 | ||
170 | struct object_refs { | 236 | struct object_refs { |
171 | unsigned count; | 237 | unsigned count; |
172 | struct object *base; | 238 | struct object *base; |
173 | struct object *ref[FLEX_ARRAY]; /* more */ | 239 | struct object *ref[FLEX_ARRAY]; /* more */ |
174 | }; | 240 | }; |
175 | 241 | ||
176 | struct object_array { | 242 | struct object_array { |
177 | unsigned int nr; | 243 | unsigned int nr; |
178 | unsigned int alloc; | 244 | unsigned int alloc; |
179 | struct object_array_entry { | 245 | struct object_array_entry { |
180 | struct object *item; | 246 | struct object *item; |
181 | const char *name; | 247 | const char *name; |
182 | } *objects; | 248 | } *objects; |
183 | }; | 249 | }; |
184 | 250 | ||
185 | #define TYPE_BITS 3 | 251 | #define TYPE_BITS 3 |
186 | #define FLAG_BITS 27 | 252 | #define FLAG_BITS 27 |
187 | 253 | ||
188 | /* | 254 | /* |
189 | * The object type is stored in 3 bits. | 255 | * The object type is stored in 3 bits. |
190 | */ | 256 | */ |
191 | struct object { | 257 | struct object { |
192 | unsigned parsed : 1; | 258 | unsigned parsed : 1; |
193 | unsigned used : 1; | 259 | unsigned used : 1; |
194 | unsigned type : TYPE_BITS; | 260 | unsigned type : TYPE_BITS; |
195 | unsigned flags : FLAG_BITS; | 261 | unsigned flags : FLAG_BITS; |
196 | unsigned char sha1[20]; | 262 | unsigned char sha1[20]; |
197 | }; | 263 | }; |
198 | 264 | ||
199 | 265 | ||
200 | /* | 266 | /* |
201 | * from git:tree.h | 267 | * from git:tree.h |
202 | */ | 268 | */ |
203 | 269 | ||
204 | struct tree { | 270 | struct tree { |
205 | struct object object; | 271 | struct object object; |
206 | void *buffer; | 272 | void *buffer; |
207 | unsigned long size; | 273 | unsigned long size; |
208 | }; | 274 | }; |
209 | 275 | ||
210 | 276 | ||
211 | struct tree *lookup_tree(const unsigned char *sha1); | 277 | struct tree *lookup_tree(const unsigned char *sha1); |
212 | int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size); | 278 | int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size); |
213 | int parse_tree(struct tree *tree); | 279 | int parse_tree(struct tree *tree); |
214 | struct tree *parse_tree_indirect(const unsigned char *sha1); | 280 | struct tree *parse_tree_indirect(const unsigned char *sha1); |
215 | 281 | ||
216 | typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const char *, unsigned int, int); | 282 | typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const char *, unsigned int, int); |
217 | 283 | ||
218 | extern int read_tree_recursive(struct tree *tree, | 284 | extern int read_tree_recursive(struct tree *tree, |
219 | const char *base, int baselen, | 285 | const char *base, int baselen, |
220 | int stage, const char **match, | 286 | int stage, const char **match, |
221 | read_tree_fn_t fn); | 287 | read_tree_fn_t fn); |
222 | 288 | ||
223 | extern int read_tree(struct tree *tree, int stage, const char **paths); | 289 | extern int read_tree(struct tree *tree, int stage, const char **paths); |
224 | 290 | ||
225 | 291 | ||
226 | /* from git:commit.h */ | 292 | /* from git:commit.h */ |
227 | 293 | ||
228 | struct commit_list { | 294 | struct commit_list { |
229 | struct commit *item; | 295 | struct commit *item; |
230 | struct commit_list *next; | 296 | struct commit_list *next; |
231 | }; | 297 | }; |
232 | 298 | ||
233 | struct commit { | 299 | struct commit { |
234 | struct object object; | 300 | struct object object; |
235 | void *util; | 301 | void *util; |
236 | unsigned long date; | 302 | unsigned long date; |
237 | struct commit_list *parents; | 303 | struct commit_list *parents; |
238 | struct tree *tree; | 304 | struct tree *tree; |
239 | char *buffer; | 305 | char *buffer; |
240 | }; | 306 | }; |
241 | 307 | ||
242 | 308 | ||
243 | struct commit *lookup_commit(const unsigned char *sha1); | 309 | struct commit *lookup_commit(const unsigned char *sha1); |
244 | struct commit *lookup_commit_reference(const unsigned char *sha1); | 310 | struct commit *lookup_commit_reference(const unsigned char *sha1); |
245 | struct commit *lookup_commit_reference_gently(const unsigned char *sha1, | 311 | struct commit *lookup_commit_reference_gently(const unsigned char *sha1, |
246 | int quiet); | 312 | int quiet); |
247 | 313 | ||
248 | int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size); | 314 | int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size); |
249 | int parse_commit(struct commit *item); | 315 | int parse_commit(struct commit *item); |
250 | 316 | ||
251 | struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p); | 317 | struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p); |
252 | struct commit_list * insert_by_date(struct commit *item, struct commit_list **list); | 318 | struct commit_list * insert_by_date(struct commit *item, struct commit_list **list); |
253 | 319 | ||
254 | void free_commit_list(struct commit_list *list); | 320 | void free_commit_list(struct commit_list *list); |
255 | 321 | ||
256 | void sort_by_date(struct commit_list **list); | 322 | void sort_by_date(struct commit_list **list); |
257 | 323 | ||
258 | /* Commit formats */ | 324 | /* Commit formats */ |
259 | enum cmit_fmt { | 325 | enum cmit_fmt { |
260 | CMIT_FMT_RAW, | 326 | CMIT_FMT_RAW, |
261 | CMIT_FMT_MEDIUM, | 327 | CMIT_FMT_MEDIUM, |
262 | CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM, | 328 | CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM, |
263 | CMIT_FMT_SHORT, | 329 | CMIT_FMT_SHORT, |
264 | CMIT_FMT_FULL, | 330 | CMIT_FMT_FULL, |
265 | CMIT_FMT_FULLER, | 331 | CMIT_FMT_FULLER, |
266 | CMIT_FMT_ONELINE, | 332 | CMIT_FMT_ONELINE, |
267 | CMIT_FMT_EMAIL, | 333 | CMIT_FMT_EMAIL, |
268 | 334 | ||
269 | CMIT_FMT_UNSPECIFIED, | 335 | CMIT_FMT_UNSPECIFIED, |
270 | }; | 336 | }; |
271 | 337 | ||
272 | extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev, const char *subject, const char *after_subject, int relative_date); | 338 | extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev, const char *subject, const char *after_subject, int relative_date); |
273 | 339 | ||
274 | 340 | ||
275 | typedef void (*topo_sort_set_fn_t)(struct commit*, void *data); | 341 | typedef void (*topo_sort_set_fn_t)(struct commit*, void *data); |
276 | typedef void* (*topo_sort_get_fn_t)(struct commit*); | 342 | typedef void* (*topo_sort_get_fn_t)(struct commit*); |
277 | 343 | ||
278 | 344 | ||
279 | 345 | ||
280 | /* | 346 | /* |
281 | * from git:diffcore.h | 347 | * from git:diffcore.h |
282 | */ | 348 | */ |
283 | 349 | ||
284 | struct diff_filespec { | 350 | struct diff_filespec { |
285 | unsigned char sha1[20]; | 351 | unsigned char sha1[20]; |
286 | char *path; | 352 | char *path; |
287 | void *data; | 353 | void *data; |
288 | void *cnt_data; | 354 | void *cnt_data; |
289 | unsigned long size; | 355 | unsigned long size; |
290 | int xfrm_flags; /* for use by the xfrm */ | 356 | int xfrm_flags; /* for use by the xfrm */ |
291 | unsigned short mode; /* file mode */ | 357 | unsigned short mode; /* file mode */ |
292 | unsigned sha1_valid : 1; /* if true, use sha1 and trust mode; | 358 | unsigned sha1_valid : 1; /* if true, use sha1 and trust mode; |
293 | * if false, use the name and read from | 359 | * if false, use the name and read from |
294 | * the filesystem. | 360 | * the filesystem. |
295 | */ | 361 | */ |
296 | #define DIFF_FILE_VALID(spec) (((spec)->mode) != 0) | 362 | #define DIFF_FILE_VALID(spec) (((spec)->mode) != 0) |
297 | unsigned should_free : 1; /* data should be free()'ed */ | 363 | unsigned should_free : 1; /* data should be free()'ed */ |
298 | unsigned should_munmap : 1; /* data should be munmap()'ed */ | 364 | unsigned should_munmap : 1; /* data should be munmap()'ed */ |
299 | }; | 365 | }; |
300 | 366 | ||
301 | struct diff_filepair { | 367 | struct diff_filepair { |
302 | struct diff_filespec *one; | 368 | struct diff_filespec *one; |
303 | struct diff_filespec *two; | 369 | struct diff_filespec *two; |
304 | unsigned short int score; | 370 | unsigned short int score; |
305 | char status; /* M C R N D U (see Documentation/diff-format.txt) */ | 371 | char status; /* M C R N D U (see Documentation/diff-format.txt) */ |
306 | unsigned source_stays : 1; /* all of R/C are copies */ | 372 | unsigned source_stays : 1; /* all of R/C are copies */ |
307 | unsigned broken_pair : 1; | 373 | unsigned broken_pair : 1; |
308 | unsigned renamed_pair : 1; | 374 | unsigned renamed_pair : 1; |
309 | }; | 375 | }; |
310 | 376 | ||
311 | #define DIFF_PAIR_UNMERGED(p) \ | 377 | #define DIFF_PAIR_UNMERGED(p) \ |
312 | (!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two)) | 378 | (!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two)) |
313 | 379 | ||
314 | #define DIFF_PAIR_RENAME(p) ((p)->renamed_pair) | 380 | #define DIFF_PAIR_RENAME(p) ((p)->renamed_pair) |
315 | 381 | ||
316 | #define DIFF_PAIR_BROKEN(p) \ | 382 | #define DIFF_PAIR_BROKEN(p) \ |
317 | ( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \ | 383 | ( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \ |
318 | ((p)->broken_pair != 0) ) | 384 | ((p)->broken_pair != 0) ) |
319 | 385 | ||
320 | #define DIFF_PAIR_TYPE_CHANGED(p) \ | 386 | #define DIFF_PAIR_TYPE_CHANGED(p) \ |
321 | ((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode)) | 387 | ((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode)) |
322 | 388 | ||
323 | #define DIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode) | 389 | #define DIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode) |
324 | 390 | ||
325 | extern void diff_free_filepair(struct diff_filepair *); | 391 | extern void diff_free_filepair(struct diff_filepair *); |
326 | 392 | ||
327 | extern int diff_unmodified_pair(struct diff_filepair *); | 393 | extern int diff_unmodified_pair(struct diff_filepair *); |
328 | 394 | ||
329 | struct diff_queue_struct { | 395 | struct diff_queue_struct { |
330 | struct diff_filepair **queue; | 396 | struct diff_filepair **queue; |
331 | int alloc; | 397 | int alloc; |
332 | int nr; | 398 | int nr; |
333 | }; | 399 | }; |
334 | 400 | ||
335 | 401 | ||
336 | /* | 402 | /* |
337 | * from git:diff.h | 403 | * from git:diff.h |
338 | */ | 404 | */ |
339 | 405 | ||
340 | 406 | ||
341 | struct rev_info; | 407 | struct rev_info; |
342 | struct diff_options; | 408 | struct diff_options; |
343 | struct diff_queue_struct; | 409 | struct diff_queue_struct; |
344 | 410 | ||
345 | typedef void (*change_fn_t)(struct diff_options *options, | 411 | typedef void (*change_fn_t)(struct diff_options *options, |
346 | unsigned old_mode, unsigned new_mode, | 412 | unsigned old_mode, unsigned new_mode, |
347 | const unsigned char *old_sha1, | 413 | const unsigned char *old_sha1, |
348 | const unsigned char *new_sha1, | 414 | const unsigned char *new_sha1, |
349 | const char *base, const char *path); | 415 | const char *base, const char *path); |
350 | 416 | ||
351 | typedef void (*add_remove_fn_t)(struct diff_options *options, | 417 | typedef void (*add_remove_fn_t)(struct diff_options *options, |
352 | int addremove, unsigned mode, | 418 | int addremove, unsigned mode, |
353 | const unsigned char *sha1, | 419 | const unsigned char *sha1, |
354 | const char *base, const char *path); | 420 | const char *base, const char *path); |
355 | 421 | ||
356 | typedef void (*diff_format_fn_t)(struct diff_queue_struct *q, | 422 | typedef void (*diff_format_fn_t)(struct diff_queue_struct *q, |
357 | struct diff_options *options, void *data); | 423 | struct diff_options *options, void *data); |
358 | 424 | ||
359 | #define DIFF_FORMAT_RAW 0x0001 | 425 | #define DIFF_FORMAT_RAW 0x0001 |
360 | #define DIFF_FORMAT_DIFFSTAT0x0002 | 426 | #define DIFF_FORMAT_DIFFSTAT0x0002 |
361 | #define DIFF_FORMAT_NUMSTAT0x0004 | 427 | #define DIFF_FORMAT_NUMSTAT0x0004 |
362 | #define DIFF_FORMAT_SUMMARY0x0008 | 428 | #define DIFF_FORMAT_SUMMARY0x0008 |
363 | #define DIFF_FORMAT_PATCH0x0010 | 429 | #define DIFF_FORMAT_PATCH0x0010 |
364 | 430 | ||
365 | /* These override all above */ | 431 | /* These override all above */ |
366 | #define DIFF_FORMAT_NAME0x0100 | 432 | #define DIFF_FORMAT_NAME0x0100 |
367 | #define DIFF_FORMAT_NAME_STATUS0x0200 | 433 | #define DIFF_FORMAT_NAME_STATUS0x0200 |
368 | #define DIFF_FORMAT_CHECKDIFF0x0400 | 434 | #define DIFF_FORMAT_CHECKDIFF0x0400 |
369 | 435 | ||
370 | /* Same as output_format = 0 but we know that -s flag was given | 436 | /* Same as output_format = 0 but we know that -s flag was given |
371 | * and we should not give default value to output_format. | 437 | * and we should not give default value to output_format. |
372 | */ | 438 | */ |
373 | #define DIFF_FORMAT_NO_OUTPUT0x0800 | 439 | #define DIFF_FORMAT_NO_OUTPUT0x0800 |
374 | 440 | ||
375 | #define DIFF_FORMAT_CALLBACK0x1000 | 441 | #define DIFF_FORMAT_CALLBACK0x1000 |
376 | 442 | ||
377 | struct diff_options { | 443 | struct diff_options { |
378 | const char *filter; | 444 | const char *filter; |
379 | const char *orderfile; | 445 | const char *orderfile; |
380 | const char *pickaxe; | 446 | const char *pickaxe; |
381 | const char *single_follow; | 447 | const char *single_follow; |
382 | unsigned recursive:1, | 448 | unsigned recursive:1, |
383 | tree_in_recursive:1, | 449 | tree_in_recursive:1, |
384 | binary:1, | 450 | binary:1, |
385 | text:1, | 451 | text:1, |
386 | full_index:1, | 452 | full_index:1, |
387 | silent_on_remove:1, | 453 | silent_on_remove:1, |
388 | find_copies_harder:1, | 454 | find_copies_harder:1, |
389 | color_diff:1, | 455 | color_diff:1, |
390 | color_diff_words:1; | 456 | color_diff_words:1; |
391 | int context; | 457 | int context; |
392 | int break_opt; | 458 | int break_opt; |
393 | int detect_rename; | 459 | int detect_rename; |
394 | int line_termination; | 460 | int line_termination; |
395 | int output_format; | 461 | int output_format; |
396 | int pickaxe_opts; | 462 | int pickaxe_opts; |
397 | int rename_score; | 463 | int rename_score; |
398 | int reverse_diff; | 464 | int reverse_diff; |
399 | int rename_limit; | 465 | int rename_limit; |
400 | int setup; | 466 | int setup; |
401 | int abbrev; | 467 | int abbrev; |
402 | const char *msg_sep; | 468 | const char *msg_sep; |
403 | const char *stat_sep; | 469 | const char *stat_sep; |
404 | long xdl_opts; | 470 | long xdl_opts; |
405 | 471 | ||
406 | int stat_width; | 472 | int stat_width; |
407 | int stat_name_width; | 473 | int stat_name_width; |
408 | 474 | ||
409 | int nr_paths; | 475 | int nr_paths; |
410 | const char **paths; | 476 | const char **paths; |
411 | int *pathlens; | 477 | int *pathlens; |
412 | change_fn_t change; | 478 | change_fn_t change; |
413 | add_remove_fn_t add_remove; | 479 | add_remove_fn_t add_remove; |
414 | diff_format_fn_t format_callback; | 480 | diff_format_fn_t format_callback; |