summaryrefslogtreecommitdiffabout
path: root/git.h
Unidiff
Diffstat (limited to 'git.h') (more/less context) (show whitespace changes)
-rw-r--r--git.h68
1 files changed, 67 insertions, 1 deletions
diff --git a/git.h b/git.h
index 922a167..b1e4828 100644
--- a/git.h
+++ b/git.h
@@ -10,49 +10,49 @@
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
53extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); 53extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2)));
54 54
55 55
56static inline char* xstrdup(const char *str) 56static inline char* xstrdup(const char *str)
57{ 57{
58 char *ret = strdup(str); 58 char *ret = strdup(str);
@@ -135,48 +135,114 @@ extern int sha1_object_info(const unsigned char *, char *, unsigned long *);
135extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size); 135extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size);
136 136
137extern int get_sha1(const char *str, unsigned char *sha1); 137extern int get_sha1(const char *str, unsigned char *sha1);
138extern int get_sha1_hex(const char *hex, unsigned char *sha1); 138extern 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
141static inline int is_null_sha1(const unsigned char *sha1) 141static 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}
145static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2) 145static 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}
149static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src) 149static 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}
153static inline void hashclr(unsigned char *hash) 153static 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
163enum 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
174enum grep_context {
175 GREP_CONTEXT_HEAD,
176 GREP_CONTEXT_BODY,
177};
178
179struct 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
188enum grep_expr_node {
189 GREP_NODE_ATOM,
190 GREP_NODE_NOT,
191 GREP_NODE_AND,
192 GREP_NODE_OR,
193};
194
195struct 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
223extern void compile_grep_patterns(struct grep_opt *opt);
224extern 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
165struct object_list { 231struct object_list {
166 struct object *item; 232 struct object *item;
167 struct object_list *next; 233 struct object_list *next;
168}; 234};
169 235
170struct object_refs { 236struct 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
176struct object_array { 242struct 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;