summaryrefslogtreecommitdiffabout
path: root/git.h
Unidiff
Diffstat (limited to 'git.h') (more/less context) (ignore whitespace changes)
-rw-r--r--git.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/git.h b/git.h
index dfa3542..a3f977c 100644
--- a/git.h
+++ b/git.h
@@ -95,192 +95,205 @@ 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
127/* Convert to/from hex/sha1 representation */ 127/* Convert to/from hex/sha1 representation */
128#define MINIMUM_ABBREV 4 128#define MINIMUM_ABBREV 4
129#define DEFAULT_ABBREV 7 129#define DEFAULT_ABBREV 7
130 130
131extern int sha1_object_info(const unsigned char *, char *, unsigned long *); 131extern int sha1_object_info(const unsigned char *, char *, unsigned long *);
132 132
133extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size); 133extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size);
134 134
135extern int get_sha1(const char *str, unsigned char *sha1); 135extern int get_sha1(const char *str, unsigned char *sha1);
136extern int get_sha1_hex(const char *hex, unsigned char *sha1); 136extern int get_sha1_hex(const char *hex, unsigned char *sha1);
137 extern char *sha1_to_hex(const unsigned char *sha1);/* static buffer result! */ 137 extern char *sha1_to_hex(const unsigned char *sha1);/* static buffer result! */
138 138
139 139
140 140
141/* 141/*
142 * from git:object.h 142 * from git:object.h
143 */ 143 */
144 144
145struct object_list { 145struct object_list {
146 struct object *item; 146 struct object *item;
147 struct object_list *next; 147 struct object_list *next;
148}; 148};
149 149
150struct object_refs { 150struct object_refs {
151 unsigned count; 151 unsigned count;
152 struct object *base; 152 struct object *base;
153 struct object *ref[FLEX_ARRAY]; /* more */ 153 struct object *ref[FLEX_ARRAY]; /* more */
154}; 154};
155 155
156struct object_array { 156struct object_array {
157 unsigned int nr; 157 unsigned int nr;
158 unsigned int alloc; 158 unsigned int alloc;
159 struct object_array_entry { 159 struct object_array_entry {
160 struct object *item; 160 struct object *item;
161 const char *name; 161 const char *name;
162 } *objects; 162 } *objects;
163}; 163};
164 164
165#define TYPE_BITS 3 165#define TYPE_BITS 3
166#define FLAG_BITS 27 166#define FLAG_BITS 27
167 167
168/* 168/*
169 * The object type is stored in 3 bits. 169 * The object type is stored in 3 bits.
170 */ 170 */
171struct object { 171struct object {
172 unsigned parsed : 1; 172 unsigned parsed : 1;
173 unsigned used : 1; 173 unsigned used : 1;
174 unsigned type : TYPE_BITS; 174 unsigned type : TYPE_BITS;
175 unsigned flags : FLAG_BITS; 175 unsigned flags : FLAG_BITS;
176 unsigned char sha1[20]; 176 unsigned char sha1[20];
177}; 177};
178 178
179 179
180/* 180/*
181 * from git:tree.h 181 * from git:tree.h
182 */ 182 */
183 183
184struct tree { 184struct tree {
185 struct object object; 185 struct object object;
186 void *buffer; 186 void *buffer;
187 unsigned long size; 187 unsigned long size;
188}; 188};
189 189
190 190
191struct tree *lookup_tree(const unsigned char *sha1);
192int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);
193int parse_tree(struct tree *tree);
194struct tree *parse_tree_indirect(const unsigned char *sha1);
195
196typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const char *, unsigned int, int);
197
198extern int read_tree_recursive(struct tree *tree,
199 const char *base, int baselen,
200 int stage, const char **match,
201 read_tree_fn_t fn);
202
203extern int read_tree(struct tree *tree, int stage, const char **paths);
191 204
192 205
193/* from git:commit.h */ 206/* from git:commit.h */
194 207
195struct commit_list { 208struct commit_list {
196 struct commit *item; 209 struct commit *item;
197 struct commit_list *next; 210 struct commit_list *next;
198}; 211};
199 212
200struct commit { 213struct commit {
201 struct object object; 214 struct object object;
202 void *util; 215 void *util;
203 unsigned long date; 216 unsigned long date;
204 struct commit_list *parents; 217 struct commit_list *parents;
205 struct tree *tree; 218 struct tree *tree;
206 char *buffer; 219 char *buffer;
207}; 220};
208 221
209 222
210struct commit *lookup_commit(const unsigned char *sha1); 223struct commit *lookup_commit(const unsigned char *sha1);
211struct commit *lookup_commit_reference(const unsigned char *sha1); 224struct commit *lookup_commit_reference(const unsigned char *sha1);
212struct commit *lookup_commit_reference_gently(const unsigned char *sha1, 225struct commit *lookup_commit_reference_gently(const unsigned char *sha1,
213 int quiet); 226 int quiet);
214 227
215int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size); 228int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size);
216int parse_commit(struct commit *item); 229int parse_commit(struct commit *item);
217 230
218struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p); 231struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p);
219struct commit_list * insert_by_date(struct commit *item, struct commit_list **list); 232struct commit_list * insert_by_date(struct commit *item, struct commit_list **list);
220 233
221void free_commit_list(struct commit_list *list); 234void free_commit_list(struct commit_list *list);
222 235
223void sort_by_date(struct commit_list **list); 236void sort_by_date(struct commit_list **list);
224 237
225/* Commit formats */ 238/* Commit formats */
226enum cmit_fmt { 239enum cmit_fmt {
227 CMIT_FMT_RAW, 240 CMIT_FMT_RAW,
228 CMIT_FMT_MEDIUM, 241 CMIT_FMT_MEDIUM,
229 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM, 242 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,
230 CMIT_FMT_SHORT, 243 CMIT_FMT_SHORT,
231 CMIT_FMT_FULL, 244 CMIT_FMT_FULL,
232 CMIT_FMT_FULLER, 245 CMIT_FMT_FULLER,
233 CMIT_FMT_ONELINE, 246 CMIT_FMT_ONELINE,
234 CMIT_FMT_EMAIL, 247 CMIT_FMT_EMAIL,
235 248
236 CMIT_FMT_UNSPECIFIED, 249 CMIT_FMT_UNSPECIFIED,
237}; 250};
238 251
239extern 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); 252extern 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);
240 253
241 254
242typedef void (*topo_sort_set_fn_t)(struct commit*, void *data); 255typedef void (*topo_sort_set_fn_t)(struct commit*, void *data);
243typedef void* (*topo_sort_get_fn_t)(struct commit*); 256typedef void* (*topo_sort_get_fn_t)(struct commit*);
244 257
245 258
246 259
247 260
248/* 261/*
249 * from git:diff.h 262 * from git:diff.h
250 */ 263 */
251 264
252 265
253struct rev_info; 266struct rev_info;
254struct diff_options; 267struct diff_options;
255struct diff_queue_struct; 268struct diff_queue_struct;
256 269
257typedef void (*change_fn_t)(struct diff_options *options, 270typedef void (*change_fn_t)(struct diff_options *options,
258 unsigned old_mode, unsigned new_mode, 271 unsigned old_mode, unsigned new_mode,
259 const unsigned char *old_sha1, 272 const unsigned char *old_sha1,
260 const unsigned char *new_sha1, 273 const unsigned char *new_sha1,
261 const char *base, const char *path); 274 const char *base, const char *path);
262 275
263typedef void (*add_remove_fn_t)(struct diff_options *options, 276typedef void (*add_remove_fn_t)(struct diff_options *options,
264 int addremove, unsigned mode, 277 int addremove, unsigned mode,
265 const unsigned char *sha1, 278 const unsigned char *sha1,
266 const char *base, const char *path); 279 const char *base, const char *path);
267 280
268typedef void (*diff_format_fn_t)(struct diff_queue_struct *q, 281typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
269 struct diff_options *options, void *data); 282 struct diff_options *options, void *data);
270 283
271 #define DIFF_FORMAT_RAW 0x0001 284 #define DIFF_FORMAT_RAW 0x0001
272 #define DIFF_FORMAT_DIFFSTAT0x0002 285 #define DIFF_FORMAT_DIFFSTAT0x0002
273 #define DIFF_FORMAT_NUMSTAT0x0004 286 #define DIFF_FORMAT_NUMSTAT0x0004
274 #define DIFF_FORMAT_SUMMARY0x0008 287 #define DIFF_FORMAT_SUMMARY0x0008
275 #define DIFF_FORMAT_PATCH0x0010 288 #define DIFF_FORMAT_PATCH0x0010
276 289
277/* These override all above */ 290/* These override all above */
278 #define DIFF_FORMAT_NAME0x0100 291 #define DIFF_FORMAT_NAME0x0100
279 #define DIFF_FORMAT_NAME_STATUS0x0200 292 #define DIFF_FORMAT_NAME_STATUS0x0200
280 #define DIFF_FORMAT_CHECKDIFF0x0400 293 #define DIFF_FORMAT_CHECKDIFF0x0400
281 294
282/* Same as output_format = 0 but we know that -s flag was given 295/* Same as output_format = 0 but we know that -s flag was given
283 * and we should not give default value to output_format. 296 * and we should not give default value to output_format.
284 */ 297 */
285 #define DIFF_FORMAT_NO_OUTPUT0x0800 298 #define DIFF_FORMAT_NO_OUTPUT0x0800
286 299