summaryrefslogtreecommitdiffabout
path: root/git.h
Unidiff
Diffstat (limited to 'git.h') (more/less context) (ignore whitespace changes)
-rw-r--r--git.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/git.h b/git.h
index 991eaa5..eca48d5 100644
--- a/git.h
+++ b/git.h
@@ -1,664 +1,668 @@
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#include <regex.h> 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);
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
64static inline void *xmalloc(size_t size) 64static 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
77static inline void *xrealloc(void *ptr, size_t size) 77static 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
87static inline void *xcalloc(size_t nmemb, size_t size) 87static 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
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 { 127enum object_type {
128 OBJ_NONE = 0, 128 OBJ_NONE = 0,
129 OBJ_COMMIT = 1, 129 OBJ_COMMIT = 1,
130 OBJ_TREE = 2, 130 OBJ_TREE = 2,
131 OBJ_BLOB = 3, 131 OBJ_BLOB = 3,
132 OBJ_TAG = 4, 132 OBJ_TAG = 4,
133 /* 5 for future expansion */ 133 /* 5 for future expansion */
134 OBJ_OFS_DELTA = 6, 134 OBJ_OFS_DELTA = 6,
135 OBJ_REF_DELTA = 7, 135 OBJ_REF_DELTA = 7,
136 OBJ_BAD, 136 OBJ_BAD,
137}; 137};
138 138
139 139
140/* Convert to/from hex/sha1 representation */ 140/* Convert to/from hex/sha1 representation */
141#define MINIMUM_ABBREV 4 141#define MINIMUM_ABBREV 4
142#define DEFAULT_ABBREV 7 142#define DEFAULT_ABBREV 7
143 143
144extern const unsigned char null_sha1[20]; 144extern const unsigned char null_sha1[20];
145 145
146extern int sha1_object_info(const unsigned char *, char *, unsigned long *); 146extern int sha1_object_info(const unsigned char *, char *, unsigned long *);
147 147
148extern 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);
149 149
150extern int get_sha1(const char *str, unsigned char *sha1); 150extern int get_sha1(const char *str, unsigned char *sha1);
151extern int get_sha1_hex(const char *hex, unsigned char *sha1); 151extern int get_sha1_hex(const char *hex, unsigned char *sha1);
152 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! */
153 153
154static inline int is_null_sha1(const unsigned char *sha1) 154static inline int is_null_sha1(const unsigned char *sha1)
155{ 155{
156 return !memcmp(sha1, null_sha1, 20); 156 return !memcmp(sha1, null_sha1, 20);
157} 157}
158static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2) 158static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
159{ 159{
160 return memcmp(sha1, sha2, 20); 160 return memcmp(sha1, sha2, 20);
161} 161}
162static 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)
163{ 163{
164 memcpy(sha_dst, sha_src, 20); 164 memcpy(sha_dst, sha_src, 20);
165} 165}
166static inline void hashclr(unsigned char *hash) 166static inline void hashclr(unsigned char *hash)
167{ 167{
168 memset(hash, 0, 20); 168 memset(hash, 0, 20);
169} 169}
170 170
171 171
172/* 172/*
173 * from git:grep.h 173 * from git:grep.h
174 */ 174 */
175 175
176enum grep_pat_token { 176enum grep_pat_token {
177 GREP_PATTERN, 177 GREP_PATTERN,
178 GREP_PATTERN_HEAD, 178 GREP_PATTERN_HEAD,
179 GREP_PATTERN_BODY, 179 GREP_PATTERN_BODY,
180 GREP_AND, 180 GREP_AND,
181 GREP_OPEN_PAREN, 181 GREP_OPEN_PAREN,
182 GREP_CLOSE_PAREN, 182 GREP_CLOSE_PAREN,
183 GREP_NOT, 183 GREP_NOT,
184 GREP_OR, 184 GREP_OR,
185}; 185};
186 186
187enum grep_context { 187enum grep_context {
188 GREP_CONTEXT_HEAD, 188 GREP_CONTEXT_HEAD,
189 GREP_CONTEXT_BODY, 189 GREP_CONTEXT_BODY,
190}; 190};
191 191
192struct grep_pat { 192struct grep_pat {
193 struct grep_pat *next; 193 struct grep_pat *next;
194 const char *origin; 194 const char *origin;
195 int no; 195 int no;
196 enum grep_pat_token token; 196 enum grep_pat_token token;
197 const char *pattern; 197 const char *pattern;
198 regex_t regexp; 198 regex_t regexp;
199}; 199};
200 200
201enum grep_expr_node { 201enum grep_expr_node {
202 GREP_NODE_ATOM, 202 GREP_NODE_ATOM,
203 GREP_NODE_NOT, 203 GREP_NODE_NOT,
204 GREP_NODE_AND, 204 GREP_NODE_AND,
205 GREP_NODE_OR, 205 GREP_NODE_OR,
206}; 206};
207 207
208struct grep_opt { 208struct grep_opt {
209 struct grep_pat *pattern_list; 209 struct grep_pat *pattern_list;
210 struct grep_pat **pattern_tail; 210 struct grep_pat **pattern_tail;
211 struct grep_expr *pattern_expression; 211 struct grep_expr *pattern_expression;
212 int prefix_length; 212 int prefix_length;
213 regex_t regexp; 213 regex_t regexp;
214 unsigned linenum:1; 214 unsigned linenum:1;
215 unsigned invert:1; 215 unsigned invert:1;
216 unsigned status_only:1; 216 unsigned status_only:1;
217 unsigned name_only:1; 217 unsigned name_only:1;
218 unsigned unmatch_name_only:1; 218 unsigned unmatch_name_only:1;
219 unsigned count:1; 219 unsigned count:1;
220 unsigned word_regexp:1; 220 unsigned word_regexp:1;
221 unsigned fixed:1; 221 unsigned fixed:1;
222 unsigned all_match:1; 222 unsigned all_match:1;
223#define GREP_BINARY_DEFAULT 0 223#define GREP_BINARY_DEFAULT 0
224#define GREP_BINARY_NOMATCH 1 224#define GREP_BINARY_NOMATCH 1
225#define GREP_BINARY_TEXT 2 225#define GREP_BINARY_TEXT 2
226 unsigned binary:2; 226 unsigned binary:2;
227 unsigned extended:1; 227 unsigned extended:1;
228 unsigned relative:1; 228 unsigned relative:1;
229 unsigned pathname:1; 229 unsigned pathname:1;
230 int regflags; 230 int regflags;
231 unsigned pre_context; 231 unsigned pre_context;
232 unsigned post_context; 232 unsigned post_context;
233}; 233};
234 234
235 235
236extern void compile_grep_patterns(struct grep_opt *opt); 236extern void compile_grep_patterns(struct grep_opt *opt);
237extern void free_grep_patterns(struct grep_opt *opt); 237extern void free_grep_patterns(struct grep_opt *opt);
238 238
239 239
240/* 240/*
241 * from git:object.h 241 * from git:object.h
242 */ 242 */
243 243
244extern const char *type_names[9]; 244extern const char *type_names[9];
245 245
246struct object_list { 246struct object_list {
247 struct object *item; 247 struct object *item;
248 struct object_list *next; 248 struct object_list *next;
249}; 249};
250 250
251struct object_refs { 251struct object_refs {
252 unsigned count; 252 unsigned count;
253 struct object *base; 253 struct object *base;
254 struct object *ref[FLEX_ARRAY]; /* more */ 254 struct object *ref[FLEX_ARRAY]; /* more */
255}; 255};
256 256
257struct object_array { 257struct object_array {
258 unsigned int nr; 258 unsigned int nr;
259 unsigned int alloc; 259 unsigned int alloc;
260 struct object_array_entry { 260 struct object_array_entry {
261 struct object *item; 261 struct object *item;
262 const char *name; 262 const char *name;
263 } *objects; 263 } *objects;
264}; 264};
265 265
266#define TYPE_BITS 3 266#define TYPE_BITS 3
267#define FLAG_BITS 27 267#define FLAG_BITS 27
268 268
269/* 269/*
270 * The object type is stored in 3 bits. 270 * The object type is stored in 3 bits.
271 */ 271 */
272struct object { 272struct object {
273 unsigned parsed : 1; 273 unsigned parsed : 1;
274 unsigned used : 1; 274 unsigned used : 1;
275 unsigned type : TYPE_BITS; 275 unsigned type : TYPE_BITS;
276 unsigned flags : FLAG_BITS; 276 unsigned flags : FLAG_BITS;
277 unsigned char sha1[20]; 277 unsigned char sha1[20];
278}; 278};
279 279
280 280
281/** Returns the object, having parsed it to find out what it is. **/
282struct object *parse_object(const unsigned char *sha1);
283
284
281/* 285/*
282 * from git:tree.h 286 * from git:tree.h
283 */ 287 */
284 288
285struct tree { 289struct tree {
286 struct object object; 290 struct object object;
287 void *buffer; 291 void *buffer;
288 unsigned long size; 292 unsigned long size;
289}; 293};
290 294
291 295
292struct tree *lookup_tree(const unsigned char *sha1); 296struct tree *lookup_tree(const unsigned char *sha1);
293int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size); 297int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);
294int parse_tree(struct tree *tree); 298int parse_tree(struct tree *tree);
295struct tree *parse_tree_indirect(const unsigned char *sha1); 299struct tree *parse_tree_indirect(const unsigned char *sha1);
296 300
297typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const char *, unsigned int, int); 301typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const char *, unsigned int, int);
298 302
299extern int read_tree_recursive(struct tree *tree, 303extern int read_tree_recursive(struct tree *tree,
300 const char *base, int baselen, 304 const char *base, int baselen,
301 int stage, const char **match, 305 int stage, const char **match,
302 read_tree_fn_t fn); 306 read_tree_fn_t fn);
303 307
304extern int read_tree(struct tree *tree, int stage, const char **paths); 308extern int read_tree(struct tree *tree, int stage, const char **paths);
305 309
306 310
307/* from git:commit.h */ 311/* from git:commit.h */
308 312
309struct commit_list { 313struct commit_list {
310 struct commit *item; 314 struct commit *item;
311 struct commit_list *next; 315 struct commit_list *next;
312}; 316};
313 317
314struct commit { 318struct commit {
315 struct object object; 319 struct object object;
316 void *util; 320 void *util;
317 unsigned long date; 321 unsigned long date;
318 struct commit_list *parents; 322 struct commit_list *parents;
319 struct tree *tree; 323 struct tree *tree;
320 char *buffer; 324 char *buffer;
321}; 325};
322 326
323 327
324struct commit *lookup_commit(const unsigned char *sha1); 328struct commit *lookup_commit(const unsigned char *sha1);
325struct commit *lookup_commit_reference(const unsigned char *sha1); 329struct commit *lookup_commit_reference(const unsigned char *sha1);
326struct commit *lookup_commit_reference_gently(const unsigned char *sha1, 330struct commit *lookup_commit_reference_gently(const unsigned char *sha1,
327 int quiet); 331 int quiet);
328 332
329int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size); 333int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size);
330int parse_commit(struct commit *item); 334int parse_commit(struct commit *item);
331 335
332struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p); 336struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p);
333struct commit_list * insert_by_date(struct commit *item, struct commit_list **list); 337struct commit_list * insert_by_date(struct commit *item, struct commit_list **list);
334 338
335void free_commit_list(struct commit_list *list); 339void free_commit_list(struct commit_list *list);
336 340
337void sort_by_date(struct commit_list **list); 341void sort_by_date(struct commit_list **list);
338 342
339/* Commit formats */ 343/* Commit formats */
340enum cmit_fmt { 344enum cmit_fmt {
341 CMIT_FMT_RAW, 345 CMIT_FMT_RAW,
342 CMIT_FMT_MEDIUM, 346 CMIT_FMT_MEDIUM,
343 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM, 347 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,
344 CMIT_FMT_SHORT, 348 CMIT_FMT_SHORT,
345 CMIT_FMT_FULL, 349 CMIT_FMT_FULL,
346 CMIT_FMT_FULLER, 350 CMIT_FMT_FULLER,
347 CMIT_FMT_ONELINE, 351 CMIT_FMT_ONELINE,
348 CMIT_FMT_EMAIL, 352 CMIT_FMT_EMAIL,
349 353
350 CMIT_FMT_UNSPECIFIED, 354 CMIT_FMT_UNSPECIFIED,
351}; 355};
352 356
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); 357extern 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);
354 358
355 359
356typedef void (*topo_sort_set_fn_t)(struct commit*, void *data); 360typedef void (*topo_sort_set_fn_t)(struct commit*, void *data);
357typedef void* (*topo_sort_get_fn_t)(struct commit*); 361typedef void* (*topo_sort_get_fn_t)(struct commit*);
358 362
359 363
360 364
361/* 365/*
362 * from git:tag.h 366 * from git:tag.h
363 */ 367 */
364 368
365extern const char *tag_type; 369extern const char *tag_type;
366 370
367struct tag { 371struct tag {
368 struct object object; 372 struct object object;
369 struct object *tagged; 373 struct object *tagged;
370 char *tag; 374 char *tag;
371 char *signature; /* not actually implemented */ 375 char *signature; /* not actually implemented */
372}; 376};
373 377
374extern struct tag *lookup_tag(const unsigned char *sha1); 378extern struct tag *lookup_tag(const unsigned char *sha1);
375extern int parse_tag_buffer(struct tag *item, void *data, unsigned long size); 379extern int parse_tag_buffer(struct tag *item, void *data, unsigned long size);
376extern int parse_tag(struct tag *item); 380extern int parse_tag(struct tag *item);
377extern struct object *deref_tag(struct object *, const char *, int); 381extern struct object *deref_tag(struct object *, const char *, int);
378 382
379 383
380/* 384/*
381 * from git:diffcore.h 385 * from git:diffcore.h
382 */ 386 */
383 387
384struct diff_filespec { 388struct diff_filespec {
385 unsigned char sha1[20]; 389 unsigned char sha1[20];
386 char *path; 390 char *path;
387 void *data; 391 void *data;
388 void *cnt_data; 392 void *cnt_data;
389 unsigned long size; 393 unsigned long size;
390 int xfrm_flags; /* for use by the xfrm */ 394 int xfrm_flags; /* for use by the xfrm */
391 unsigned short mode; /* file mode */ 395 unsigned short mode; /* file mode */
392 unsigned sha1_valid : 1; /* if true, use sha1 and trust mode; 396 unsigned sha1_valid : 1; /* if true, use sha1 and trust mode;
393 * if false, use the name and read from 397 * if false, use the name and read from
394 * the filesystem. 398 * the filesystem.
395 */ 399 */
396#define DIFF_FILE_VALID(spec) (((spec)->mode) != 0) 400#define DIFF_FILE_VALID(spec) (((spec)->mode) != 0)
397 unsigned should_free : 1; /* data should be free()'ed */ 401 unsigned should_free : 1; /* data should be free()'ed */
398 unsigned should_munmap : 1; /* data should be munmap()'ed */ 402 unsigned should_munmap : 1; /* data should be munmap()'ed */
399}; 403};
400 404
401struct diff_filepair { 405struct diff_filepair {
402 struct diff_filespec *one; 406 struct diff_filespec *one;
403 struct diff_filespec *two; 407 struct diff_filespec *two;
404 unsigned short int score; 408 unsigned short int score;
405 char status; /* M C R N D U (see Documentation/diff-format.txt) */ 409 char status; /* M C R N D U (see Documentation/diff-format.txt) */
406 unsigned source_stays : 1; /* all of R/C are copies */ 410 unsigned source_stays : 1; /* all of R/C are copies */
407 unsigned broken_pair : 1; 411 unsigned broken_pair : 1;
408 unsigned renamed_pair : 1; 412 unsigned renamed_pair : 1;
409}; 413};
410 414
411#define DIFF_PAIR_UNMERGED(p) \ 415#define DIFF_PAIR_UNMERGED(p) \
412 (!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two)) 416 (!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
413 417
414#define DIFF_PAIR_RENAME(p) ((p)->renamed_pair) 418#define DIFF_PAIR_RENAME(p) ((p)->renamed_pair)
415 419
416#define DIFF_PAIR_BROKEN(p) \ 420#define DIFF_PAIR_BROKEN(p) \
417 ( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \ 421 ( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \
418 ((p)->broken_pair != 0) ) 422 ((p)->broken_pair != 0) )
419 423
420#define DIFF_PAIR_TYPE_CHANGED(p) \ 424#define DIFF_PAIR_TYPE_CHANGED(p) \
421 ((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode)) 425 ((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode))
422 426
423#define DIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode) 427#define DIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode)
424 428
425extern void diff_free_filepair(struct diff_filepair *); 429extern void diff_free_filepair(struct diff_filepair *);
426 430
427extern int diff_unmodified_pair(struct diff_filepair *); 431extern int diff_unmodified_pair(struct diff_filepair *);
428 432
429struct diff_queue_struct { 433struct diff_queue_struct {
430 struct diff_filepair **queue; 434 struct diff_filepair **queue;
431 int alloc; 435 int alloc;
432 int nr; 436 int nr;
433}; 437};
434 438
435 439
436/* 440/*
437 * from git:diff.h 441 * from git:diff.h
438 */ 442 */
439 443
440 444
441struct rev_info; 445struct rev_info;
442struct diff_options; 446struct diff_options;
443struct diff_queue_struct; 447struct diff_queue_struct;
444 448
445typedef void (*change_fn_t)(struct diff_options *options, 449typedef void (*change_fn_t)(struct diff_options *options,
446 unsigned old_mode, unsigned new_mode, 450 unsigned old_mode, unsigned new_mode,
447 const unsigned char *old_sha1, 451 const unsigned char *old_sha1,
448 const unsigned char *new_sha1, 452 const unsigned char *new_sha1,
449 const char *base, const char *path); 453 const char *base, const char *path);
450 454
451typedef void (*add_remove_fn_t)(struct diff_options *options, 455typedef void (*add_remove_fn_t)(struct diff_options *options,
452 int addremove, unsigned mode, 456 int addremove, unsigned mode,
453 const unsigned char *sha1, 457 const unsigned char *sha1,
454 const char *base, const char *path); 458 const char *base, const char *path);
455 459
456typedef void (*diff_format_fn_t)(struct diff_queue_struct *q, 460typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
457 struct diff_options *options, void *data); 461 struct diff_options *options, void *data);
458 462
459 #define DIFF_FORMAT_RAW 0x0001 463 #define DIFF_FORMAT_RAW 0x0001
460 #define DIFF_FORMAT_DIFFSTAT0x0002 464 #define DIFF_FORMAT_DIFFSTAT0x0002
461 #define DIFF_FORMAT_NUMSTAT0x0004 465 #define DIFF_FORMAT_NUMSTAT0x0004
462 #define DIFF_FORMAT_SUMMARY0x0008 466 #define DIFF_FORMAT_SUMMARY0x0008
463 #define DIFF_FORMAT_PATCH0x0010 467 #define DIFF_FORMAT_PATCH0x0010
464 468
465/* These override all above */ 469/* These override all above */
466 #define DIFF_FORMAT_NAME0x0100 470 #define DIFF_FORMAT_NAME0x0100
467 #define DIFF_FORMAT_NAME_STATUS0x0200 471 #define DIFF_FORMAT_NAME_STATUS0x0200
468 #define DIFF_FORMAT_CHECKDIFF0x0400 472 #define DIFF_FORMAT_CHECKDIFF0x0400
469 473
470/* Same as output_format = 0 but we know that -s flag was given 474/* Same as output_format = 0 but we know that -s flag was given
471 * and we should not give default value to output_format. 475 * and we should not give default value to output_format.
472 */ 476 */
473 #define DIFF_FORMAT_NO_OUTPUT0x0800 477 #define DIFF_FORMAT_NO_OUTPUT0x0800
474 478
475 #define DIFF_FORMAT_CALLBACK0x1000 479 #define DIFF_FORMAT_CALLBACK0x1000
476 480
477struct diff_options { 481struct diff_options {
478 const char *filter; 482 const char *filter;
479 const char *orderfile; 483 const char *orderfile;
480 const char *pickaxe; 484 const char *pickaxe;
481 const char *single_follow; 485 const char *single_follow;
482 unsigned recursive:1, 486 unsigned recursive:1,
483 tree_in_recursive:1, 487 tree_in_recursive:1,
484 binary:1, 488 binary:1,
485 text:1, 489 text:1,
486 full_index:1, 490 full_index:1,
487 silent_on_remove:1, 491 silent_on_remove:1,
488 find_copies_harder:1, 492 find_copies_harder:1,
489 color_diff:1, 493 color_diff:1,
490 color_diff_words:1; 494 color_diff_words:1;
491 int context; 495 int context;
492 int break_opt; 496 int break_opt;
493 int detect_rename; 497 int detect_rename;
494 int line_termination; 498 int line_termination;
495 int output_format; 499 int output_format;
496 int pickaxe_opts; 500 int pickaxe_opts;
497 int rename_score; 501 int rename_score;
498 int reverse_diff; 502 int reverse_diff;
499 int rename_limit; 503 int rename_limit;
500 int setup; 504 int setup;
501 int abbrev; 505 int abbrev;
502 const char *msg_sep; 506 const char *msg_sep;
503 const char *stat_sep; 507 const char *stat_sep;
504 long xdl_opts; 508 long xdl_opts;
505 509
506 int stat_width; 510 int stat_width;
507 int stat_name_width; 511 int stat_name_width;
508 512
509 int nr_paths; 513 int nr_paths;
510 const char **paths; 514 const char **paths;
511 int *pathlens; 515 int *pathlens;
512 change_fn_t change; 516 change_fn_t change;
513 add_remove_fn_t add_remove; 517 add_remove_fn_t add_remove;
514 diff_format_fn_t format_callback; 518 diff_format_fn_t format_callback;
515 void *format_callback_data; 519 void *format_callback_data;
516}; 520};
517 521
518enum color_diff { 522enum color_diff {
519 DIFF_RESET = 0, 523 DIFF_RESET = 0,
520 DIFF_PLAIN = 1, 524 DIFF_PLAIN = 1,
521 DIFF_METAINFO = 2, 525 DIFF_METAINFO = 2,
522 DIFF_FRAGINFO = 3, 526 DIFF_FRAGINFO = 3,
523 DIFF_FILE_OLD = 4, 527 DIFF_FILE_OLD = 4,
524 DIFF_FILE_NEW = 5, 528 DIFF_FILE_NEW = 5,
525 DIFF_COMMIT = 6, 529 DIFF_COMMIT = 6,
526 DIFF_WHITESPACE = 7, 530 DIFF_WHITESPACE = 7,
527}; 531};
528 532
529 533
530extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new, 534extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
531 const char *base, struct diff_options *opt); 535 const char *base, struct diff_options *opt);
532 536
533extern int diff_root_tree_sha1(const unsigned char *new, const char *base, 537extern int diff_root_tree_sha1(const unsigned char *new, const char *base,
534 struct diff_options *opt); 538 struct diff_options *opt);
535 539
536extern int git_diff_ui_config(const char *var, const char *value); 540extern int git_diff_ui_config(const char *var, const char *value);
537extern void diff_setup(struct diff_options *); 541extern void diff_setup(struct diff_options *);
538extern int diff_opt_parse(struct diff_options *, const char **, int); 542extern int diff_opt_parse(struct diff_options *, const char **, int);
539extern int diff_setup_done(struct diff_options *); 543extern int diff_setup_done(struct diff_options *);
540 544
541 545
542extern void diffcore_std(struct diff_options *); 546extern void diffcore_std(struct diff_options *);
543extern void diff_flush(struct diff_options*); 547extern void diff_flush(struct diff_options*);
544 548
545 549
546/* diff-raw status letters */ 550/* diff-raw status letters */
547 #define DIFF_STATUS_ADDED 'A' 551 #define DIFF_STATUS_ADDED 'A'
548 #define DIFF_STATUS_COPIED 'C' 552 #define DIFF_STATUS_COPIED 'C'
549 #define DIFF_STATUS_DELETED 'D' 553 #define DIFF_STATUS_DELETED 'D'
550 #define DIFF_STATUS_MODIFIED 'M' 554 #define DIFF_STATUS_MODIFIED 'M'
551 #define DIFF_STATUS_RENAMED 'R' 555 #define DIFF_STATUS_RENAMED 'R'
552 #define DIFF_STATUS_TYPE_CHANGED'T' 556 #define DIFF_STATUS_TYPE_CHANGED'T'
553 #define DIFF_STATUS_UNKNOWN 'X' 557 #define DIFF_STATUS_UNKNOWN 'X'
554 #define DIFF_STATUS_UNMERGED 'U' 558 #define DIFF_STATUS_UNMERGED 'U'
555 559
556 560
557 561
558/* 562/*
559 * from git:refs.g 563 * from git:refs.g
560 */ 564 */
561 565
562typedef int each_ref_fn(const char *refname, const unsigned char *sha1, int flags, void *cb_data); 566typedef int each_ref_fn(const char *refname, const unsigned char *sha1, int flags, void *cb_data);
563extern int head_ref(each_ref_fn, void *); 567extern int head_ref(each_ref_fn, void *);
564extern int for_each_ref(each_ref_fn, void *); 568extern int for_each_ref(each_ref_fn, void *);
565extern int for_each_tag_ref(each_ref_fn, void *); 569extern int for_each_tag_ref(each_ref_fn, void *);
566extern int for_each_branch_ref(each_ref_fn, void *); 570extern int for_each_branch_ref(each_ref_fn, void *);
567extern int for_each_remote_ref(each_ref_fn, void *); 571extern int for_each_remote_ref(each_ref_fn, void *);
568 572
569 573
570 574
571/* 575/*
572 * from git:revision.h 576 * from git:revision.h
573 */ 577 */
574 578
575struct rev_info; 579struct rev_info;
576struct log_info; 580struct log_info;
577 581
578typedef void (prune_fn_t)(struct rev_info *revs, struct commit *commit); 582typedef void (prune_fn_t)(struct rev_info *revs, struct commit *commit);
579 583
580struct rev_info { 584struct rev_info {
581 /* Starting list */ 585 /* Starting list */
582 struct commit_list *commits; 586 struct commit_list *commits;
583 struct object_array pending; 587 struct object_array pending;
584 588
585 /* Basic information */ 589 /* Basic information */
586 const char *prefix; 590 const char *prefix;
587 void *prune_data; 591 void *prune_data;
588 prune_fn_t *prune_fn; 592 prune_fn_t *prune_fn;
589 593
590 /* Traversal flags */ 594 /* Traversal flags */
591 unsigned intdense:1, 595 unsigned intdense:1,
592 no_merges:1, 596 no_merges:1,
593 no_walk:1, 597 no_walk:1,
594 remove_empty_trees:1, 598 remove_empty_trees:1,
595 simplify_history:1, 599 simplify_history:1,
596 lifo:1, 600 lifo:1,
597 topo_order:1, 601 topo_order:1,
598 tag_objects:1, 602 tag_objects:1,
599 tree_objects:1, 603 tree_objects:1,
600 blob_objects:1, 604 blob_objects:1,
601 edge_hint:1, 605 edge_hint:1,
602 limited:1, 606 limited:1,
603 unpacked:1, /* see also ignore_packed below */ 607 unpacked:1, /* see also ignore_packed below */
604 boundary:1, 608 boundary:1,
605 parents:1; 609 parents:1;
606 610
607 /* Diff flags */ 611 /* Diff flags */
608 unsigned intdiff:1, 612 unsigned intdiff:1,
609 full_diff:1, 613 full_diff:1,
610 show_root_diff:1, 614 show_root_diff:1,
611 no_commit_id:1, 615 no_commit_id:1,
612 verbose_header:1, 616 verbose_header:1,
613 ignore_merges:1, 617 ignore_merges:1,
614 combine_merges:1, 618 combine_merges:1,
615 dense_combined_merges:1, 619 dense_combined_merges:1,
616 always_show_header:1; 620 always_show_header:1;
617 621
618 /* Format info */ 622 /* Format info */
619 unsigned intshown_one:1, 623 unsigned intshown_one:1,
620 abbrev_commit:1, 624 abbrev_commit:1,
621 relative_date:1; 625 relative_date:1;
622 626
623 const char **ignore_packed; /* pretend objects in these are unpacked */ 627 const char **ignore_packed; /* pretend objects in these are unpacked */
624 int num_ignore_packed; 628 int num_ignore_packed;
625 629
626 unsigned intabbrev; 630 unsigned intabbrev;
627 enum cmit_fmtcommit_format; 631 enum cmit_fmtcommit_format;
628 struct log_info *loginfo; 632 struct log_info *loginfo;
629 int nr, total; 633 int nr, total;
630 const char*mime_boundary; 634 const char*mime_boundary;
631 const char*message_id; 635 const char*message_id;
632 const char*ref_message_id; 636 const char*ref_message_id;
633 const char*add_signoff; 637 const char*add_signoff;
634 const char*extra_headers; 638 const char*extra_headers;
635 639
636 /* Filter by commit log message */ 640 /* Filter by commit log message */
637 struct grep_opt*grep_filter; 641 struct grep_opt*grep_filter;
638 642
639 /* special limits */ 643 /* special limits */
640 int max_count; 644 int max_count;
641 unsigned long max_age; 645 unsigned long max_age;
642 unsigned long min_age; 646 unsigned long min_age;
643 647
644 /* diff info for patches and for paths limiting */ 648 /* diff info for patches and for paths limiting */
645 struct diff_options diffopt; 649 struct diff_options diffopt;
646 struct diff_options pruning; 650 struct diff_options pruning;
647 651
648 topo_sort_set_fn_t topo_setter; 652 topo_sort_set_fn_t topo_setter;
649 topo_sort_get_fn_t topo_getter; 653 topo_sort_get_fn_t topo_getter;
650}; 654};
651 655
652 656
653extern void init_revisions(struct rev_info *revs, const char *prefix); 657extern void init_revisions(struct rev_info *revs, const char *prefix);
654extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def); 658extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def);
655extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,int cant_be_filename); 659extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,int cant_be_filename);
656 660
657extern void prepare_revision_walk(struct rev_info *revs); 661extern void prepare_revision_walk(struct rev_info *revs);
658extern struct commit *get_revision(struct rev_info *revs); 662extern struct commit *get_revision(struct rev_info *revs);
659 663
660 664
661 665
662/* from git:log-tree.h */ 666/* from git:log-tree.h */
663 667
664int log_tree_commit(struct rev_info *, struct commit *); 668int log_tree_commit(struct rev_info *, struct commit *);