6 * from git:git-compat-util.h
11 #if defined(__GNUC__) && (__GNUC__ < 3)
14 #define FLEX_ARRAY /* empty */
29 #include <sys/param.h>
30 #include <netinet/in.h>
31 #include <sys/types.h>
36 static inline char* xstrdup(const char *str)
38 char *ret = strdup(str);
40 die("Out of memory, strdup failed");
44 static inline void *xmalloc(size_t size)
46 void *ret = malloc(size);
50 die("Out of memory, malloc failed");
52 memset(ret, 0xA5, size);
57 static inline void *xrealloc(void *ptr, size_t size)
59 void *ret = realloc(ptr, size);
61 ret = realloc(ptr, 1);
63 die("Out of memory, realloc failed");
67 static inline void *xcalloc(size_t nmemb, size_t size)
69 void *ret = calloc(nmemb, size);
70 if (!ret && (!nmemb || !size))
73 die("Out of memory, calloc failed");
77 static inline ssize_t xread(int fd, void *buf, size_t len)
81 nr = read(fd, buf, len);
82 if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
88 static inline ssize_t xwrite(int fd, const void *buf, size_t len)
92 nr = write(fd, buf, len);
93 if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
107 /* Convert to/from hex/sha1 representation */
108 #define MINIMUM_ABBREV 4
109 #define DEFAULT_ABBREV 7
112 extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size);
123 struct object_list *next;
129 struct object *ref[FLEX_ARRAY]; /* more */
132 struct object_array {
135 struct object_array_entry {
145 * The object type is stored in 3 bits.
150 unsigned type : TYPE_BITS;
151 unsigned flags : FLAG_BITS;
152 unsigned char sha1[20];
161 struct object object;
169 /* from git:commit.h */
173 struct commit_list *next;
177 struct object object;
180 struct commit_list *parents;
190 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,
197 CMIT_FMT_UNSPECIFIED,
202 struct commit *lookup_commit(const unsigned char *sha1);
203 struct commit *lookup_commit_reference(const unsigned char *sha1);
204 struct commit *lookup_commit_reference_gently(const unsigned char *sha1,
207 typedef void (*topo_sort_set_fn_t)(struct commit*, void *data);
208 typedef void* (*topo_sort_get_fn_t)(struct commit*);
220 struct diff_queue_struct;
222 typedef void (*change_fn_t)(struct diff_options *options,
223 unsigned old_mode, unsigned new_mode,
224 const unsigned char *old_sha1,
225 const unsigned char *new_sha1,
226 const char *base, const char *path);
228 typedef void (*add_remove_fn_t)(struct diff_options *options,
229 int addremove, unsigned mode,
230 const unsigned char *sha1,
231 const char *base, const char *path);
233 typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
234 struct diff_options *options, void *data);
236 #define DIFF_FORMAT_RAW 0x0001
237 #define DIFF_FORMAT_DIFFSTAT 0x0002
238 #define DIFF_FORMAT_NUMSTAT 0x0004
239 #define DIFF_FORMAT_SUMMARY 0x0008
240 #define DIFF_FORMAT_PATCH 0x0010
242 /* These override all above */
243 #define DIFF_FORMAT_NAME 0x0100
244 #define DIFF_FORMAT_NAME_STATUS 0x0200
245 #define DIFF_FORMAT_CHECKDIFF 0x0400
247 /* Same as output_format = 0 but we know that -s flag was given
248 * and we should not give default value to output_format.
250 #define DIFF_FORMAT_NO_OUTPUT 0x0800
252 #define DIFF_FORMAT_CALLBACK 0x1000
254 struct diff_options {
256 const char *orderfile;
258 const char *single_follow;
259 unsigned recursive:1,
265 find_copies_harder:1,
271 int line_termination;
280 const char *stat_sep;
290 add_remove_fn_t add_remove;
291 diff_format_fn_t format_callback;
292 void *format_callback_data;
313 * from git:revision.h
319 typedef void (prune_fn_t)(struct rev_info *revs, struct commit *commit);
323 struct commit_list *commits;
324 struct object_array pending;
326 /* Basic information */
329 prune_fn_t *prune_fn;
331 /* Traversal flags */
332 unsigned int dense:1,
335 remove_empty_trees:1,
344 unpacked:1, /* see also ignore_packed below */
356 dense_combined_merges:1,
357 always_show_header:1;
360 unsigned int shown_one:1,
364 const char **ignore_packed; /* pretend objects in these are unpacked */
365 int num_ignore_packed;
368 enum cmit_fmt commit_format;
369 struct log_info *loginfo;
371 const char *mime_boundary;
372 const char *message_id;
373 const char *ref_message_id;
374 const char *add_signoff;
375 const char *extra_headers;
377 /* Filter by commit log message */
378 struct grep_opt *grep_filter;
382 unsigned long max_age;
383 unsigned long min_age;
385 /* diff info for patches and for paths limiting */
386 struct diff_options diffopt;
387 struct diff_options pruning;
389 topo_sort_set_fn_t topo_setter;
390 topo_sort_get_fn_t topo_getter;
394 extern struct commit *get_revision(struct rev_info *revs);