summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--git.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/git.h b/git.h
index b1e4828..991eaa5 100644
--- a/git.h
+++ b/git.h
@@ -95,64 +95,77 @@ static inline void *xcalloc(size_t nmemb, size_t size)
95} 95}
96 96
97static inline ssize_t xread(int fd, void *buf, size_t len) 97static 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
108static inline ssize_t xwrite(int fd, const void *buf, size_t len) 108static 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
127enum object_type {
128 OBJ_NONE = 0,
129 OBJ_COMMIT = 1,
130 OBJ_TREE = 2,
131 OBJ_BLOB = 3,
132 OBJ_TAG = 4,
133 /* 5 for future expansion */
134 OBJ_OFS_DELTA = 6,
135 OBJ_REF_DELTA = 7,
136 OBJ_BAD,
137};
138
139
127/* Convert to/from hex/sha1 representation */ 140/* Convert to/from hex/sha1 representation */
128#define MINIMUM_ABBREV 4 141#define MINIMUM_ABBREV 4
129#define DEFAULT_ABBREV 7 142#define DEFAULT_ABBREV 7
130 143
131extern const unsigned char null_sha1[20]; 144extern const unsigned char null_sha1[20];
132 145
133extern int sha1_object_info(const unsigned char *, char *, unsigned long *); 146extern int sha1_object_info(const unsigned char *, char *, unsigned long *);
134 147
135extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size); 148extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size);
136 149
137extern int get_sha1(const char *str, unsigned char *sha1); 150extern int get_sha1(const char *str, unsigned char *sha1);
138extern int get_sha1_hex(const char *hex, unsigned char *sha1); 151extern int get_sha1_hex(const char *hex, unsigned char *sha1);
139 extern char *sha1_to_hex(const unsigned char *sha1);/* static buffer result! */ 152 extern char *sha1_to_hex(const unsigned char *sha1);/* static buffer result! */
140 153
141static inline int is_null_sha1(const unsigned char *sha1) 154static inline int is_null_sha1(const unsigned char *sha1)
142{ 155{
143 return !memcmp(sha1, null_sha1, 20); 156 return !memcmp(sha1, null_sha1, 20);
144} 157}
145static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2) 158static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
146{ 159{
147 return memcmp(sha1, sha2, 20); 160 return memcmp(sha1, sha2, 20);
148} 161}
149static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src) 162static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
150{ 163{
151 memcpy(sha_dst, sha_src, 20); 164 memcpy(sha_dst, sha_src, 20);
152} 165}
153static inline void hashclr(unsigned char *hash) 166static inline void hashclr(unsigned char *hash)
154{ 167{
155 memset(hash, 0, 20); 168 memset(hash, 0, 20);
156} 169}
157 170
158 171
@@ -199,64 +212,66 @@ struct grep_opt {
199 int prefix_length; 212 int prefix_length;
200 regex_t regexp; 213 regex_t regexp;
201 unsigned linenum:1; 214 unsigned linenum:1;
202 unsigned invert:1; 215 unsigned invert:1;
203 unsigned status_only:1; 216 unsigned status_only:1;
204 unsigned name_only:1; 217 unsigned name_only:1;
205 unsigned unmatch_name_only:1; 218 unsigned unmatch_name_only:1;
206 unsigned count:1; 219 unsigned count:1;
207 unsigned word_regexp:1; 220 unsigned word_regexp:1;
208 unsigned fixed:1; 221 unsigned fixed:1;
209 unsigned all_match:1; 222 unsigned all_match:1;
210#define GREP_BINARY_DEFAULT 0 223#define GREP_BINARY_DEFAULT 0
211#define GREP_BINARY_NOMATCH 1 224#define GREP_BINARY_NOMATCH 1
212#define GREP_BINARY_TEXT 2 225#define GREP_BINARY_TEXT 2
213 unsigned binary:2; 226 unsigned binary:2;
214 unsigned extended:1; 227 unsigned extended:1;
215 unsigned relative:1; 228 unsigned relative:1;
216 unsigned pathname:1; 229 unsigned pathname:1;
217 int regflags; 230 int regflags;
218 unsigned pre_context; 231 unsigned pre_context;
219 unsigned post_context; 232 unsigned post_context;
220}; 233};
221 234
222 235
223extern void compile_grep_patterns(struct grep_opt *opt); 236extern void compile_grep_patterns(struct grep_opt *opt);
224extern void free_grep_patterns(struct grep_opt *opt); 237extern void free_grep_patterns(struct grep_opt *opt);
225 238
226 239
227/* 240/*
228 * from git:object.h 241 * from git:object.h
229 */ 242 */
230 243
244extern const char *type_names[9];
245
231struct object_list { 246struct object_list {
232 struct object *item; 247 struct object *item;
233 struct object_list *next; 248 struct object_list *next;
234}; 249};
235 250
236struct object_refs { 251struct object_refs {
237 unsigned count; 252 unsigned count;
238 struct object *base; 253 struct object *base;
239 struct object *ref[FLEX_ARRAY]; /* more */ 254 struct object *ref[FLEX_ARRAY]; /* more */
240}; 255};
241 256
242struct object_array { 257struct object_array {
243 unsigned int nr; 258 unsigned int nr;
244 unsigned int alloc; 259 unsigned int alloc;
245 struct object_array_entry { 260 struct object_array_entry {
246 struct object *item; 261 struct object *item;
247 const char *name; 262 const char *name;
248 } *objects; 263 } *objects;
249}; 264};
250 265
251#define TYPE_BITS 3 266#define TYPE_BITS 3
252#define FLAG_BITS 27 267#define FLAG_BITS 27
253 268
254/* 269/*
255 * The object type is stored in 3 bits. 270 * The object type is stored in 3 bits.
256 */ 271 */
257struct object { 272struct object {
258 unsigned parsed : 1; 273 unsigned parsed : 1;
259 unsigned used : 1; 274 unsigned used : 1;
260 unsigned type : TYPE_BITS; 275 unsigned type : TYPE_BITS;
261 unsigned flags : FLAG_BITS; 276 unsigned flags : FLAG_BITS;
262 unsigned char sha1[20]; 277 unsigned char sha1[20];
@@ -315,64 +330,83 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size);
315int parse_commit(struct commit *item); 330int parse_commit(struct commit *item);
316 331
317struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p); 332struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p);
318struct commit_list * insert_by_date(struct commit *item, struct commit_list **list); 333struct commit_list * insert_by_date(struct commit *item, struct commit_list **list);
319 334
320void free_commit_list(struct commit_list *list); 335void free_commit_list(struct commit_list *list);
321 336
322void sort_by_date(struct commit_list **list); 337void sort_by_date(struct commit_list **list);
323 338
324/* Commit formats */ 339/* Commit formats */
325enum cmit_fmt { 340enum cmit_fmt {
326 CMIT_FMT_RAW, 341 CMIT_FMT_RAW,
327 CMIT_FMT_MEDIUM, 342 CMIT_FMT_MEDIUM,
328 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM, 343 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,
329 CMIT_FMT_SHORT, 344 CMIT_FMT_SHORT,
330 CMIT_FMT_FULL, 345 CMIT_FMT_FULL,
331 CMIT_FMT_FULLER, 346 CMIT_FMT_FULLER,
332 CMIT_FMT_ONELINE, 347 CMIT_FMT_ONELINE,
333 CMIT_FMT_EMAIL, 348 CMIT_FMT_EMAIL,
334 349
335 CMIT_FMT_UNSPECIFIED, 350 CMIT_FMT_UNSPECIFIED,
336}; 351};
337 352
338extern 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); 353extern 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);
339 354
340 355
341typedef void (*topo_sort_set_fn_t)(struct commit*, void *data); 356typedef void (*topo_sort_set_fn_t)(struct commit*, void *data);
342typedef void* (*topo_sort_get_fn_t)(struct commit*); 357typedef void* (*topo_sort_get_fn_t)(struct commit*);
343 358
344 359
345 360
346/* 361/*
362 * from git:tag.h
363 */
364
365extern const char *tag_type;
366
367struct tag {
368 struct object object;
369 struct object *tagged;
370 char *tag;
371 char *signature; /* not actually implemented */
372};
373
374extern struct tag *lookup_tag(const unsigned char *sha1);
375extern int parse_tag_buffer(struct tag *item, void *data, unsigned long size);
376extern int parse_tag(struct tag *item);
377extern struct object *deref_tag(struct object *, const char *, int);
378
379
380/*
347 * from git:diffcore.h 381 * from git:diffcore.h
348 */ 382 */
349 383
350struct diff_filespec { 384struct diff_filespec {
351 unsigned char sha1[20]; 385 unsigned char sha1[20];
352 char *path; 386 char *path;
353 void *data; 387 void *data;
354 void *cnt_data; 388 void *cnt_data;
355 unsigned long size; 389 unsigned long size;
356 int xfrm_flags; /* for use by the xfrm */ 390 int xfrm_flags; /* for use by the xfrm */
357 unsigned short mode; /* file mode */ 391 unsigned short mode; /* file mode */
358 unsigned sha1_valid : 1; /* if true, use sha1 and trust mode; 392 unsigned sha1_valid : 1; /* if true, use sha1 and trust mode;
359 * if false, use the name and read from 393 * if false, use the name and read from
360 * the filesystem. 394 * the filesystem.
361 */ 395 */
362#define DIFF_FILE_VALID(spec) (((spec)->mode) != 0) 396#define DIFF_FILE_VALID(spec) (((spec)->mode) != 0)
363 unsigned should_free : 1; /* data should be free()'ed */ 397 unsigned should_free : 1; /* data should be free()'ed */
364 unsigned should_munmap : 1; /* data should be munmap()'ed */ 398 unsigned should_munmap : 1; /* data should be munmap()'ed */
365}; 399};
366 400
367struct diff_filepair { 401struct diff_filepair {
368 struct diff_filespec *one; 402 struct diff_filespec *one;
369 struct diff_filespec *two; 403 struct diff_filespec *two;
370 unsigned short int score; 404 unsigned short int score;
371 char status; /* M C R N D U (see Documentation/diff-format.txt) */ 405 char status; /* M C R N D U (see Documentation/diff-format.txt) */
372 unsigned source_stays : 1; /* all of R/C are copies */ 406 unsigned source_stays : 1; /* all of R/C are copies */
373 unsigned broken_pair : 1; 407 unsigned broken_pair : 1;
374 unsigned renamed_pair : 1; 408 unsigned renamed_pair : 1;
375}; 409};
376 410
377#define DIFF_PAIR_UNMERGED(p) \ 411#define DIFF_PAIR_UNMERGED(p) \
378 (!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two)) 412 (!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))