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
@@ -1,634 +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 {
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
159/* 172/*
160 * from git:grep.h 173 * from git:grep.h
161 */ 174 */
162 175
163enum grep_pat_token { 176enum grep_pat_token {
164 GREP_PATTERN, 177 GREP_PATTERN,
165 GREP_PATTERN_HEAD, 178 GREP_PATTERN_HEAD,
166 GREP_PATTERN_BODY, 179 GREP_PATTERN_BODY,
167 GREP_AND, 180 GREP_AND,
168 GREP_OPEN_PAREN, 181 GREP_OPEN_PAREN,
169 GREP_CLOSE_PAREN, 182 GREP_CLOSE_PAREN,
170 GREP_NOT, 183 GREP_NOT,
171 GREP_OR, 184 GREP_OR,
172}; 185};
173 186
174enum grep_context { 187enum grep_context {
175 GREP_CONTEXT_HEAD, 188 GREP_CONTEXT_HEAD,
176 GREP_CONTEXT_BODY, 189 GREP_CONTEXT_BODY,
177}; 190};
178 191
179struct grep_pat { 192struct grep_pat {
180 struct grep_pat *next; 193 struct grep_pat *next;
181 const char *origin; 194 const char *origin;
182 int no; 195 int no;
183 enum grep_pat_token token; 196 enum grep_pat_token token;
184 const char *pattern; 197 const char *pattern;
185 regex_t regexp; 198 regex_t regexp;
186}; 199};
187 200
188enum grep_expr_node { 201enum grep_expr_node {
189 GREP_NODE_ATOM, 202 GREP_NODE_ATOM,
190 GREP_NODE_NOT, 203 GREP_NODE_NOT,
191 GREP_NODE_AND, 204 GREP_NODE_AND,
192 GREP_NODE_OR, 205 GREP_NODE_OR,
193}; 206};
194 207
195struct grep_opt { 208struct grep_opt {
196 struct grep_pat *pattern_list; 209 struct grep_pat *pattern_list;
197 struct grep_pat **pattern_tail; 210 struct grep_pat **pattern_tail;
198 struct grep_expr *pattern_expression; 211 struct grep_expr *pattern_expression;
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];
263}; 278};
264 279
265 280
266/* 281/*
267 * from git:tree.h 282 * from git:tree.h
268 */ 283 */
269 284
270struct tree { 285struct tree {
271 struct object object; 286 struct object object;
272 void *buffer; 287 void *buffer;
273 unsigned long size; 288 unsigned long size;
274}; 289};
275 290
276 291
277struct tree *lookup_tree(const unsigned char *sha1); 292struct tree *lookup_tree(const unsigned char *sha1);
278int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size); 293int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);
279int parse_tree(struct tree *tree); 294int parse_tree(struct tree *tree);
280struct tree *parse_tree_indirect(const unsigned char *sha1); 295struct tree *parse_tree_indirect(const unsigned char *sha1);
281 296
282typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const char *, unsigned int, int); 297typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const char *, unsigned int, int);
283 298
284extern int read_tree_recursive(struct tree *tree, 299extern int read_tree_recursive(struct tree *tree,
285 const char *base, int baselen, 300 const char *base, int baselen,
286 int stage, const char **match, 301 int stage, const char **match,
287 read_tree_fn_t fn); 302 read_tree_fn_t fn);
288 303
289extern int read_tree(struct tree *tree, int stage, const char **paths); 304extern int read_tree(struct tree *tree, int stage, const char **paths);
290 305
291 306
292/* from git:commit.h */ 307/* from git:commit.h */
293 308
294struct commit_list { 309struct commit_list {
295 struct commit *item; 310 struct commit *item;
296 struct commit_list *next; 311 struct commit_list *next;
297}; 312};
298 313
299struct commit { 314struct commit {
300 struct object object; 315 struct object object;
301 void *util; 316 void *util;
302 unsigned long date; 317 unsigned long date;
303 struct commit_list *parents; 318 struct commit_list *parents;
304 struct tree *tree; 319 struct tree *tree;
305 char *buffer; 320 char *buffer;
306}; 321};
307 322
308 323
309struct commit *lookup_commit(const unsigned char *sha1); 324struct commit *lookup_commit(const unsigned char *sha1);
310struct commit *lookup_commit_reference(const unsigned char *sha1); 325struct commit *lookup_commit_reference(const unsigned char *sha1);
311struct commit *lookup_commit_reference_gently(const unsigned char *sha1, 326struct commit *lookup_commit_reference_gently(const unsigned char *sha1,
312 int quiet); 327 int quiet);
313 328
314int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size); 329int 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))
379 413
380#define DIFF_PAIR_RENAME(p) ((p)->renamed_pair) 414#define DIFF_PAIR_RENAME(p) ((p)->renamed_pair)
381 415
382#define DIFF_PAIR_BROKEN(p) \ 416#define DIFF_PAIR_BROKEN(p) \
383 ( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \ 417 ( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \
384 ((p)->broken_pair != 0) ) 418 ((p)->broken_pair != 0) )
385 419
386#define DIFF_PAIR_TYPE_CHANGED(p) \ 420#define DIFF_PAIR_TYPE_CHANGED(p) \
387 ((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode)) 421 ((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode))
388 422
389#define DIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode) 423#define DIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode)
390 424
391extern void diff_free_filepair(struct diff_filepair *); 425extern void diff_free_filepair(struct diff_filepair *);
392 426
393extern int diff_unmodified_pair(struct diff_filepair *); 427extern int diff_unmodified_pair(struct diff_filepair *);
394 428
395struct diff_queue_struct { 429struct diff_queue_struct {
396 struct diff_filepair **queue; 430 struct diff_filepair **queue;
397 int alloc; 431 int alloc;
398 int nr; 432 int nr;
399}; 433};
400 434
401 435
402/* 436/*
403 * from git:diff.h 437 * from git:diff.h
404 */ 438 */
405 439
406 440
407struct rev_info; 441struct rev_info;
408struct diff_options; 442struct diff_options;
409struct diff_queue_struct; 443struct diff_queue_struct;
410 444
411typedef void (*change_fn_t)(struct diff_options *options, 445typedef void (*change_fn_t)(struct diff_options *options,
412 unsigned old_mode, unsigned new_mode, 446 unsigned old_mode, unsigned new_mode,
413 const unsigned char *old_sha1, 447 const unsigned char *old_sha1,
414 const unsigned char *new_sha1, 448 const unsigned char *new_sha1,
415 const char *base, const char *path); 449 const char *base, const char *path);
416 450
417typedef void (*add_remove_fn_t)(struct diff_options *options, 451typedef void (*add_remove_fn_t)(struct diff_options *options,
418 int addremove, unsigned mode, 452 int addremove, unsigned mode,
419 const unsigned char *sha1, 453 const unsigned char *sha1,
420 const char *base, const char *path); 454 const char *base, const char *path);
421 455
422typedef void (*diff_format_fn_t)(struct diff_queue_struct *q, 456typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
423 struct diff_options *options, void *data); 457 struct diff_options *options, void *data);
424 458
425 #define DIFF_FORMAT_RAW 0x0001 459 #define DIFF_FORMAT_RAW 0x0001
426 #define DIFF_FORMAT_DIFFSTAT0x0002 460 #define DIFF_FORMAT_DIFFSTAT0x0002
427 #define DIFF_FORMAT_NUMSTAT0x0004 461 #define DIFF_FORMAT_NUMSTAT0x0004
428 #define DIFF_FORMAT_SUMMARY0x0008 462 #define DIFF_FORMAT_SUMMARY0x0008
429 #define DIFF_FORMAT_PATCH0x0010 463 #define DIFF_FORMAT_PATCH0x0010
430 464
431/* These override all above */ 465/* These override all above */
432 #define DIFF_FORMAT_NAME0x0100 466 #define DIFF_FORMAT_NAME0x0100
433 #define DIFF_FORMAT_NAME_STATUS0x0200 467 #define DIFF_FORMAT_NAME_STATUS0x0200
434 #define DIFF_FORMAT_CHECKDIFF0x0400 468 #define DIFF_FORMAT_CHECKDIFF0x0400
435 469
436/* Same as output_format = 0 but we know that -s flag was given 470/* Same as output_format = 0 but we know that -s flag was given
437 * and we should not give default value to output_format. 471 * and we should not give default value to output_format.
438 */ 472 */
439 #define DIFF_FORMAT_NO_OUTPUT0x0800 473 #define DIFF_FORMAT_NO_OUTPUT0x0800
440 474
441 #define DIFF_FORMAT_CALLBACK0x1000 475 #define DIFF_FORMAT_CALLBACK0x1000
442 476
443struct diff_options { 477struct diff_options {
444 const char *filter; 478 const char *filter;
445 const char *orderfile; 479 const char *orderfile;
446 const char *pickaxe; 480 const char *pickaxe;
447 const char *single_follow; 481 const char *single_follow;
448 unsigned recursive:1, 482 unsigned recursive:1,
449 tree_in_recursive:1, 483 tree_in_recursive:1,
450 binary:1, 484 binary:1,
451 text:1, 485 text:1,
452 full_index:1, 486 full_index:1,
453 silent_on_remove:1, 487 silent_on_remove:1,
454 find_copies_harder:1, 488 find_copies_harder:1,
455 color_diff:1, 489 color_diff:1,
456 color_diff_words:1; 490 color_diff_words:1;
457 int context; 491 int context;
458 int break_opt; 492 int break_opt;
459 int detect_rename; 493 int detect_rename;
460 int line_termination; 494 int line_termination;
461 int output_format; 495 int output_format;
462 int pickaxe_opts; 496 int pickaxe_opts;
463 int rename_score; 497 int rename_score;
464 int reverse_diff; 498 int reverse_diff;
465 int rename_limit; 499 int rename_limit;
466 int setup; 500 int setup;
467 int abbrev; 501 int abbrev;
468 const char *msg_sep; 502 const char *msg_sep;
469 const char *stat_sep; 503 const char *stat_sep;
470 long xdl_opts; 504 long xdl_opts;
471 505
472 int stat_width; 506 int stat_width;
473 int stat_name_width; 507 int stat_name_width;
474 508
475 int nr_paths; 509 int nr_paths;
476 const char **paths; 510 const char **paths;
477 int *pathlens; 511 int *pathlens;
478 change_fn_t change; 512 change_fn_t change;
479 add_remove_fn_t add_remove; 513 add_remove_fn_t add_remove;
480 diff_format_fn_t format_callback; 514 diff_format_fn_t format_callback;
481 void *format_callback_data; 515 void *format_callback_data;
482}; 516};
483 517
484enum color_diff { 518enum color_diff {
485 DIFF_RESET = 0, 519 DIFF_RESET = 0,
486 DIFF_PLAIN = 1, 520 DIFF_PLAIN = 1,
487 DIFF_METAINFO = 2, 521 DIFF_METAINFO = 2,
488 DIFF_FRAGINFO = 3, 522 DIFF_FRAGINFO = 3,
489 DIFF_FILE_OLD = 4, 523 DIFF_FILE_OLD = 4,
490 DIFF_FILE_NEW = 5, 524 DIFF_FILE_NEW = 5,
491 DIFF_COMMIT = 6, 525 DIFF_COMMIT = 6,
492 DIFF_WHITESPACE = 7, 526 DIFF_WHITESPACE = 7,
493}; 527};
494 528
495 529
496extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new, 530extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
497 const char *base, struct diff_options *opt); 531 const char *base, struct diff_options *opt);
498 532
499extern int diff_root_tree_sha1(const unsigned char *new, const char *base, 533extern int diff_root_tree_sha1(const unsigned char *new, const char *base,
500 struct diff_options *opt); 534 struct diff_options *opt);
501 535
502extern int git_diff_ui_config(const char *var, const char *value); 536extern int git_diff_ui_config(const char *var, const char *value);
503extern void diff_setup(struct diff_options *); 537extern void diff_setup(struct diff_options *);
504extern int diff_opt_parse(struct diff_options *, const char **, int); 538extern int diff_opt_parse(struct diff_options *, const char **, int);
505extern int diff_setup_done(struct diff_options *); 539extern int diff_setup_done(struct diff_options *);
506 540
507 541
508extern void diffcore_std(struct diff_options *); 542extern void diffcore_std(struct diff_options *);
509extern void diff_flush(struct diff_options*); 543extern void diff_flush(struct diff_options*);
510 544
511 545
512/* diff-raw status letters */ 546/* diff-raw status letters */
513 #define DIFF_STATUS_ADDED 'A' 547 #define DIFF_STATUS_ADDED 'A'
514 #define DIFF_STATUS_COPIED 'C' 548 #define DIFF_STATUS_COPIED 'C'
515 #define DIFF_STATUS_DELETED 'D' 549 #define DIFF_STATUS_DELETED 'D'
516 #define DIFF_STATUS_MODIFIED 'M' 550 #define DIFF_STATUS_MODIFIED 'M'
517 #define DIFF_STATUS_RENAMED 'R' 551 #define DIFF_STATUS_RENAMED 'R'
518 #define DIFF_STATUS_TYPE_CHANGED'T' 552 #define DIFF_STATUS_TYPE_CHANGED'T'
519 #define DIFF_STATUS_UNKNOWN 'X' 553 #define DIFF_STATUS_UNKNOWN 'X'
520 #define DIFF_STATUS_UNMERGED 'U' 554 #define DIFF_STATUS_UNMERGED 'U'
521 555
522 556
523 557
524/* 558/*
525 * from git:refs.g 559 * from git:refs.g
526 */ 560 */
527 561
528typedef int each_ref_fn(const char *refname, const unsigned char *sha1, int flags, void *cb_data); 562typedef int each_ref_fn(const char *refname, const unsigned char *sha1, int flags, void *cb_data);
529extern int head_ref(each_ref_fn, void *); 563extern int head_ref(each_ref_fn, void *);
530extern int for_each_ref(each_ref_fn, void *); 564extern int for_each_ref(each_ref_fn, void *);
531extern int for_each_tag_ref(each_ref_fn, void *); 565extern int for_each_tag_ref(each_ref_fn, void *);
532extern int for_each_branch_ref(each_ref_fn, void *); 566extern int for_each_branch_ref(each_ref_fn, void *);
533extern int for_each_remote_ref(each_ref_fn, void *); 567extern int for_each_remote_ref(each_ref_fn, void *);
534 568
535 569
536 570
537/* 571/*
538 * from git:revision.h 572 * from git:revision.h
539 */ 573 */
540 574
541struct rev_info; 575struct rev_info;
542struct log_info; 576struct log_info;
543 577
544typedef void (prune_fn_t)(struct rev_info *revs, struct commit *commit); 578typedef void (prune_fn_t)(struct rev_info *revs, struct commit *commit);
545 579
546struct rev_info { 580struct rev_info {
547 /* Starting list */ 581 /* Starting list */
548 struct commit_list *commits; 582 struct commit_list *commits;
549 struct object_array pending; 583 struct object_array pending;
550 584
551 /* Basic information */ 585 /* Basic information */
552 const char *prefix; 586 const char *prefix;
553 void *prune_data; 587 void *prune_data;
554 prune_fn_t *prune_fn; 588 prune_fn_t *prune_fn;
555 589
556 /* Traversal flags */ 590 /* Traversal flags */
557 unsigned intdense:1, 591 unsigned intdense:1,
558 no_merges:1, 592 no_merges:1,
559 no_walk:1, 593 no_walk:1,
560 remove_empty_trees:1, 594 remove_empty_trees:1,
561 simplify_history:1, 595 simplify_history:1,
562 lifo:1, 596 lifo:1,
563 topo_order:1, 597 topo_order:1,
564 tag_objects:1, 598 tag_objects:1,
565 tree_objects:1, 599 tree_objects:1,
566 blob_objects:1, 600 blob_objects:1,
567 edge_hint:1, 601 edge_hint:1,
568 limited:1, 602 limited:1,
569 unpacked:1, /* see also ignore_packed below */ 603 unpacked:1, /* see also ignore_packed below */
570 boundary:1, 604 boundary:1,
571 parents:1; 605 parents:1;
572 606
573 /* Diff flags */ 607 /* Diff flags */
574 unsigned intdiff:1, 608 unsigned intdiff:1,
575 full_diff:1, 609 full_diff:1,
576 show_root_diff:1, 610 show_root_diff:1,
577 no_commit_id:1, 611 no_commit_id:1,
578 verbose_header:1, 612 verbose_header:1,
579 ignore_merges:1, 613 ignore_merges:1,
580 combine_merges:1, 614 combine_merges:1,
581 dense_combined_merges:1, 615 dense_combined_merges:1,
582 always_show_header:1; 616 always_show_header:1;
583 617
584 /* Format info */ 618 /* Format info */
585 unsigned intshown_one:1, 619 unsigned intshown_one:1,
586 abbrev_commit:1, 620 abbrev_commit:1,
587 relative_date:1; 621 relative_date:1;
588 622
589 const char **ignore_packed; /* pretend objects in these are unpacked */ 623 const char **ignore_packed; /* pretend objects in these are unpacked */
590 int num_ignore_packed; 624 int num_ignore_packed;
591 625
592 unsigned intabbrev; 626 unsigned intabbrev;
593 enum cmit_fmtcommit_format; 627 enum cmit_fmtcommit_format;
594 struct log_info *loginfo; 628 struct log_info *loginfo;
595 int nr, total; 629 int nr, total;
596 const char*mime_boundary; 630 const char*mime_boundary;
597 const char*message_id; 631 const char*message_id;
598 const char*ref_message_id; 632 const char*ref_message_id;
599 const char*add_signoff; 633 const char*add_signoff;
600 const char*extra_headers; 634 const char*extra_headers;
601 635
602 /* Filter by commit log message */ 636 /* Filter by commit log message */
603 struct grep_opt*grep_filter; 637 struct grep_opt*grep_filter;
604 638
605 /* special limits */ 639 /* special limits */
606 int max_count; 640 int max_count;
607 unsigned long max_age; 641 unsigned long max_age;
608 unsigned long min_age; 642 unsigned long min_age;
609 643
610 /* diff info for patches and for paths limiting */ 644 /* diff info for patches and for paths limiting */
611 struct diff_options diffopt; 645 struct diff_options diffopt;
612 struct diff_options pruning; 646 struct diff_options pruning;
613 647
614 topo_sort_set_fn_t topo_setter; 648 topo_sort_set_fn_t topo_setter;
615 topo_sort_get_fn_t topo_getter; 649 topo_sort_get_fn_t topo_getter;
616}; 650};
617 651
618 652
619extern void init_revisions(struct rev_info *revs, const char *prefix); 653extern void init_revisions(struct rev_info *revs, const char *prefix);
620extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def); 654extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def);
621extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,int cant_be_filename); 655extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,int cant_be_filename);
622 656
623extern void prepare_revision_walk(struct rev_info *revs); 657extern void prepare_revision_walk(struct rev_info *revs);
624extern struct commit *get_revision(struct rev_info *revs); 658extern struct commit *get_revision(struct rev_info *revs);
625 659
626 660
627 661
628/* from git:log-tree.h */ 662/* from git:log-tree.h */
629 663
630int log_tree_commit(struct rev_info *, struct commit *); 664int log_tree_commit(struct rev_info *, struct commit *);
631 665
632 666
633 667
634#endif /* GIT_H */ 668#endif /* GIT_H */